View Issue Details

IDProjectCategoryView StatusLast Update
0002259Spring engineGeneralpublic2010-12-26 11:55
ReporterLicho Assigned To 
PrioritynormalSeveritymajorReproducibilityalways
Status closedResolutionno change required 
Product Version0.82.6.1 
Summary0002259: Engine is ignoring modoptions default
DescriptionModOptions.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

TagsNo tags attached.
Checked infolog.txt for Errors

Activities

Kloot

2010-12-21 19:17

developer   ~0006119

Last edited: 2010-12-21 19:25

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).

Licho

2010-12-21 19:29

reporter   ~0006120

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.

Kloot

2010-12-21 20:53

developer   ~0006122

Last edited: 2010-12-21 21:00

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).

Licho

2010-12-21 21:10

reporter   ~0006123

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.

Kloot

2010-12-21 21:32

developer   ~0006124

They are kept, you can access the values that were present in script.txt with Spring.GetModOptions() which returns a plain {option1 = value1, ...} table.

jK

2010-12-21 21:34

developer   ~0006125

Lua differs between zero & nil ...

Licho

2010-12-21 21:48

reporter   ~0006126

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.

Kloot

2010-12-21 22:11

developer   ~0006127

Last edited: 2010-12-21 22:20

"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

Licho

2010-12-21 22:31

reporter   ~0006128

I will test, hold on, perhaps we have overriden GetModOptions in CA

Licho

2010-12-26 01:18

reporter   ~0006151

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.

Kloot

2010-12-26 11:55

developer   ~0006152

aiiight

Issue History

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