Sometimes we add new options to preferences file. If user has valid preferences file and upgrade to new Wargus version (in which was change introduced) and do not delete or fix preferences file, Stratagus show similar lua error:
[string "/usr/share/games/stratagus/wargus/scripts/s..."]:348: bad argument #1 to 'SetMouseScrollSpeed' (number expected, got nil)
stack traceback:
[C]: in function 'SetMouseScrollSpeed'
[string "/usr/share/games/stratagus/wargus/scripts/s..."]:348: in main chunk
It is cased by script scripts/stratagus.lua where is:
Load("preferences.lua")
if (wc2.preferences == nil) then
wc2.preferences = { ... }
end
...
SetMouseScrollSpeed(wc2.preferences.MouseScrollSpeed)
So with old config wc2.preferences.MouseScrollSpeed is nil.
What do you think, how to fix this problem? It is possible to patch lua functions (SetMouseScrollSpeed) that will also accept nil? Or should we add before each function condition like this? Or is there any other option?
if (wc2.preferences.MouseScrollSpeed == nil) then
wc2.preferences.MouseScrollSpeed = 1
fi
This is blocker which should be fixed before 2.2.7. Also this affects all games (not only Wargus).
Imported from Launchpad using lp2gh.