Detecting Game Options

Charsi

Chieftain
Joined
Mar 18, 2015
Messages
45
Hi all,

I'm the author of Barbarians Evolved (formerly Barbarian Lands) and I am having trouble with something that should be very simple:

Detecting whether the "Raging Barbarians" option is checked.

I've tried three different approaches. All work for me, but i'm getting reports that it's simply not working for users of my mod whichever method I try. I have no idea why.

My approaches are:
  1. bRagingBarbarians = Game.GetCustomOption("GAMEOPTION_RAGING_BARBARIANS")
  2. bRagingBarbarians = PreGame.GetGameOption("GAMEOPTION_RAGING_BARBARIANS")
  3. bRagingBarbarians = Game.IsOption(GameOptionTypes.GAMEOPTION_RAGING_BARBARIANS)

Can anyone tell me what the right way to do this is? Note that on my local machine all three methods are evaluating to true when Raging Barbarians is checked (and subsequently altering the mod's gameplay). But according to Workshop posts, checking Raging Barbarians has no effect on gameplay for some users.

Any help would be appreciated...
 
http://modiki.civfanatics.com/index.php?title=PreGame.GetGameOption_(Civ5_API)

note the methods as used by Firaxis. They are not attempting to directly evaluate the "return" from a PreGame.GetGameOption() as a boolean, they are evaluating as an integer, which the reference page to which I linked is confirming. It looks as if the option should return "-1" when not selected, and I guess "1" when selected.

I think you would want:
Code:
bRagingBarbarians = (PreGame.GetGameOption("GAMEOPTION_RAGING_BARBARIAN S") == 1)
You would have to confirm that the "return" is actually "1" when the option is turned on.

But this should evaluate bRagingBarbarians to "true" when the option is turned on, and should evaluate to "false" when the option is not turned on, while at the same time avoiding the issues wrt to evaluation of "-1" equating/not-equating to "false".
 
I'll give that a try, thank you.

Edit: It works for me (but then, it always worked for me) and is failing for others. I'm completely stumped by this...
 
Back
Top Bottom