View Issue Details
| ID | Project | Category | View Status | Date Submitted | Last Update |
|---|---|---|---|---|---|
| 0002259 | Spring engine | General | public | 2010-12-15 02:05 | 2010-12-26 11:55 |
| Reporter | Licho | Assigned To | |||
| Priority | normal | Severity | major | Reproducibility | always |
| Status | closed | Resolution | no change required | ||
| Product Version | 0.82.6.1 | ||||
| Summary | 0002259: Engine is ignoring modoptions default | ||||
| Description | ModOptions.lua file can specify default modoption values. However, if modoption value is not set in script, engine uses zero value (0/false) instead of default value defined in ModOptions.lua | ||||
| Tags | No tags attached. | ||||
| Checked infolog.txt for Errors | |||||
|
|
Why should the engine take responsibility for this? Lobbies should just write all the default unused modoption values to script.txt beforehand, since they can parse them easily via unitsync. Reading them in Spring would get complex (==> script.txt arrives at clients _before_ they have loaded the mod archive obviously). |
|
|
Hmm, problem is when you start spring.exe directly for example. Or whit missions and autohosts not supporting mapoptions etc.. Does it matter that script arrives before archive is loaded? It can just remember overrides.. We could fix that in lua by reading script and comparing with default modoptions, but engine already reads script so i thought it would be easier for it. |
|
|
Yeah, it matters because mod options are currently extracted from script.txt as soon as it arrives and the script text is discarded. The engine could parse ModOptions.lua itself somewhere between that time and the point when LuaRules is loaded to insert missing default values, but it would complicate things (there is no clean place to do that). |
|
|
Ok so could you keep parsed values somewhere? (Values parsed from script). Basically if i can tell value which was set in script from "zero" value I could code my own defaults handling in lua. I can read defaults in ModOptions but I can't tell what was zeroed due to missing entry in script and what was explicitly zeroed by the script. |
|
|
They are kept, you can access the values that were present in script.txt with Spring.GetModOptions() which returns a plain {option1 = value1, ...} table. |
|
|
Lua differs between zero & nil ... |
|
|
problem is Spring.GetModOptions also contains modoptions NOT in the script with values set to 0/false (instead of "nil" as nothing) I need to tell those unset from those set. |
|
|
"problem is Spring.GetModOptions also contains modoptions NOT in the script" ==> sorry, but that is impossible. script.txt: [game] { [modoptions] { gamemode=3; maxspeed=25; } ... } gadget: function gadget:Initialize() local opts = Spring.GetModOptions() for k,v in pairs(opts) do Spring.Echo(k, v) end end output: gamemode, 3 maxspeed, 25 |
|
|
I will test, hold on, perhaps we have overriden GetModOptions in CA |
|
|
You were absolutely right. Engine only returns values set by script. That means we can easily fix the problem in widget and gadget handler and no engine change is needed. |
|
|
aiiight |
| Date Modified | Username | Field | Change |
|---|---|---|---|
| 2010-12-15 02:05 | Licho | New Issue | |
| 2010-12-21 19:17 | Kloot | Note Added: 0006119 | |
| 2010-12-21 19:17 | Kloot | Status | new => feedback |
| 2010-12-21 19:19 | Kloot | Note Edited: 0006119 | |
| 2010-12-21 19:21 | Kloot | Note Edited: 0006119 | |
| 2010-12-21 19:25 | Kloot | Note Edited: 0006119 | |
| 2010-12-21 19:29 | Licho | Note Added: 0006120 | |
| 2010-12-21 20:53 | Kloot | Note Added: 0006122 | |
| 2010-12-21 20:53 | Kloot | Note Edited: 0006122 | |
| 2010-12-21 20:59 | Kloot | Note Edited: 0006122 | |
| 2010-12-21 21:00 | Kloot | Note Edited: 0006122 | |
| 2010-12-21 21:10 | Licho | Note Added: 0006123 | |
| 2010-12-21 21:32 | Kloot | Note Added: 0006124 | |
| 2010-12-21 21:34 | jK | Note Added: 0006125 | |
| 2010-12-21 21:48 | Licho | Note Added: 0006126 | |
| 2010-12-21 22:11 | Kloot | Note Added: 0006127 | |
| 2010-12-21 22:12 | Kloot | Note Edited: 0006127 | |
| 2010-12-21 22:12 | Kloot | Note Edited: 0006127 | |
| 2010-12-21 22:13 | Kloot | Note Edited: 0006127 | |
| 2010-12-21 22:20 | Kloot | Note Edited: 0006127 | |
| 2010-12-21 22:31 | Licho | Note Added: 0006128 | |
| 2010-12-26 01:18 | Licho | Note Added: 0006151 | |
| 2010-12-26 11:55 | Kloot | Note Added: 0006152 | |
| 2010-12-26 11:55 | Kloot | Status | feedback => closed |
| 2010-12-26 11:55 | Kloot | Resolution | open => no change required |