Game Options and affecting Defines

Bosparan

Chieftain
Joined
Oct 27, 2014
Messages
23
Hi,

I've recently started to try adding option to my mods (so players can pick what part they actually want). Works like a charm, except for when the changes involve Game Defines ...

What I'm trying to do
Have Game Options affect Game Defines.

Issue
- The only way I know how to interact with options is through lua.
- Defines are constants that are finalized during game initialization and cannot be changed afterwards

Question
Either ...
... What event do I need to subscribe to, in order to have my function run as Advanced Game Configuration ends and game initialization starts?
... How else can I affect Game Defines depending on Game Options?

What I tried so far (without success)
Code:
Events.SerialEventStartGame.Add( ImplementOptionTradeRoutes );
Events.PreGameDirty.Add( ImplementOptionTradeRoutes );
GameEvents.PreGameStart.Add( ImplementOptionTradeRoutes );
Events.SequenceGameInitComplete.Add( ImplementOptionTradeRoutes );
Events.GameOptionsChanged.Add( ImplementOptionTradeRoutes );
When using the SequenceGameInitComplete event, the function will be called and work properly, however changing the GameDefines fails and updates to the Defines table have no effect.

Cheers and thanks,
Bosparan

Ps.: Just to make this absolutely clear:
I know how to implement a constant change to the data, by changing defines using Xml. This however does not mesh with modular options. Going with XML, if I wanted to affect three parameters, each with four options, I'd need to build 125 mods to cover all possible combinations in a single mod, or 12 and have the player select up to three different mods for each game.
 
The only way I'm aware of to accomplish what you want is to replace the setup screens. I haven't personally tried this kind of thing, but take a look at Custom Advanced Setup for Civ5.
 
Hi Nutty,

thanks for the advice. Buuut ... I actually found a way to make it work!
I'll make a dedicated mod for Mapping Options to defines, so it can be implemented using good ol' XML by anybody who cares to, since otherwise the solution would probably be incompatible with other mods doing the same.

So how it works ...
I mod the MapGenerator.lua
Added calling a lua Event at the top of the script after including my custom script (which registers the same Lua Event).

As it turns out, defines are finalized only after the map has been generated :)

Cheers,
Bosparan
 
Yeah right. Works wonders, GameDefines and Defines both change as desired. They just don't have any effect *sigh*
Back to the drawing table ...
 
Back
Top Bottom