fa
fa copied to clipboard
Mod options
Added options sections/functionality to lobby options list for mods (each options file gets its own section)
Provided options functionality for blueprint modding
Created ImportModOptions()
Created AddModOptions()
Removed ImportModAIOptions() - AI mod options are now included in mod options (this has backwards compatibility)
Created IsEnabledSimMod(mod)
Created 'Mod Options' loc in US/RU/CN
Made option file formatting consistent with map option formatting (users can literally copy and paste a functioning map's option file into a mod's primary folder, rename the file 'mod_options', and the formatting should be correct)
Created OptionChoices local (which has the lobby option choices from the prefs file) on blueprints.lua (for use in modding)
Changed LoadPreGameData() to LoadPrefsData()
Increased efficiency on blueprints.lua
Made it so that mod(s) having faulty mod options file(s) doesn't break the lobby (prior to this pr, improperly formatting additional AI options with a mod would often cause lobby crashes)
Minor cleanup and explanatory comments
Here is an example mod that demonstrates using mod options with this pr: Example Mod.zip
Note this is the same as https://github.com/FAForever/fa/pull/3144 so only one should be merged at the end of the day
Note this is the same as #3144 so only one should be merged at the end of the day
#3144 is more ambitious, but it's also not finished despite being around for about 1.5 years, and it doesn't seem like it will be finished soon (if ever) based on its rate of progress for most of that time... #3654 is already functional and ready to merge if no one has issues with it. So, I think it would make sense to merge #3654, and if #3144 is ever finished, it could potentially replace or add to the functionality provided by #3654.
#3144 branched out a bit too much. Some of its functionality is already implemented by other PRs. I'll review this one tomorrow.
This is looking good - I'll review it again on Friday.
When a user has a faulty mod enabled it prevents the entire lobby from functioning:
WARNING: SCR_LuaDoFileConcat: Loading "c:\programdata\faforever\user\my games\gas powered games\supreme commander forged alliance\mods\battle-royale\lua\ai\lobbyoptions\lobbyoptions.lua" failed: ... forged alliance\mods\battle-royale\lua\ai\lobbyoptions\lobbyoptions.lua(9): `}' expected (to close `{' at line 4) near `values'
WARNING: ...ocuments\supreme commander\fa\lua\ui\lobby\lobby.lua(117): access to nonexistent global variable "AIOpts"
WARNING: stack traceback:
WARNING: [C]: in function `error'
WARNING: ...alliance\gamedata\mohodata.scd\lua\system\config.lua(53): in function <...alliance\gamedata\mohodata.scd\lua\system\config.lua:52>
WARNING: ...ocuments\supreme commander\fa\lua\ui\lobby\lobby.lua(117): in function `ImportModOptions'
WARNING: ...ocuments\supreme commander\fa\lua\ui\lobby\lobby.lua(133): in main chunk
WARNING: [C]: in function `doscript'
WARNING: [C]: ?
WARNING: ...documents\supreme commander\fa\lua\system\import.lua(87): in function `import'
WARNING: ...documents\supreme commander\fa\lua\system\import.lua(72): in function `import'
WARNING: ...documents\supreme commander\fa\lua\ui\menus\main.lua(835): in function `StartLobby'
WARNING: ...documents\supreme commander\fa\lua\ui\menus\main.lua(840): in function <...documents\supreme commander\fa\lua\ui\menus\main.lua:832>
WARNING: ...documents\supreme commander\fa\lua\ui\menus\main.lua(749): in function <...documents\supreme commander\fa\lua\ui\menus\main.lua:741>
WARNING: ...documents\supreme commander\fa\lua\ui\menus\main.lua(310): in function <...documents\supreme commander\fa\lua\ui\menus\main.lua:295>
WARNING: Error running OnFrame script in CScriptObject at 101a92c0: ...documents\supreme commander\fa\lua\system\import.lua(72): Error importing '/lua/ui/lobby/lobby.lua'
stack traceback:
[C]: in function `error'
...documents\supreme commander\fa\lua\system\import.lua(92): in function `import'
...documents\supreme commander\fa\lua\system\import.lua(72): in function `import'
...documents\supreme commander\fa\lua\ui\menus\main.lua(835): in function `StartLobby'
...documents\supreme commander\fa\lua\ui\menus\main.lua(840): in function <...documents\supreme commander\fa\lua\ui\menus\main.lua:832>
...documents\supreme commander\fa\lua\ui\menus\main.lua(749): in function <...documents\supreme commander\fa\lua\ui\menus\main.lua:741>
...documents\supreme commander\fa\lua\ui\menus\main.lua(310): in function <...documents\supreme commander\fa\lua\ui\menus\main.lua:295>
Best to use pcall
when you load in these options and then inform the user using 'WARN" instead of 'error'. For more information about pcall:
- http://www.lua.org/pil/8.4.html
When you change an option in the map select dialogue you need to invoke CalcVisible (the function that updates the list) again to prevent this: