Is there a way to change the auto next turn option?

trevholland

Chieftain
Joined
Feb 6, 2014
Messages
4
I'm trying to find a way, from lua, to get/set the auto next turn option.

I'm hoping to make a mod that simply puts a check box on the minimap, next to where the "next turn" button is, that toggles auto next turn without having to go into the game options every time. I have my check box. I have my event handler for it in lua. I just need to figure out how to get at that option.

Thanks!
 
The text on the options screen that sets this is "Single Player Auto End Turn", so if you search all the civ5*.xml files for this string you will find it in Civ5GameTextInfos_InGameScreens.xml.

In that file you will find it is associated with the text key TXT_KEY_OPSCREEN_SPLAYER_AUTO_END_TURN

Searching all the UI xml files for that key locates it in OptionsMenu.xml associated with the control with ID SinglePlayerAutoEndTurnCheckBox

Searching the OptionsMenu.lua file for that control name turns up

Code:
Controls.SinglePlayerAutoEndTurnCheckBox:SetCheck(OptionsManager.GetSinglePlayerAutoEndTurnEnabled_Cached());

and

Code:
function OnSinglePlayerAutoEndTurnCheck( bIsChecked )
   OptionsManager.SetSinglePlayerAutoEndTurnEnabled_Cached(bIsChecked);
end
Controls.SinglePlayerAutoEndTurnCheckBox:RegisterCheckHandler(OnSinglePlayerAutoEndTurnCheck);

which is pretty much the code you'll need in your own UI mod
 
Thanks for teaching me how to fish. :)

It would appear my call to...
Code:
OptionsManager.SetSinglePlayerAutoEndTurnEnabled_Cached(bIsChecked);
...does nothing. Is there some sort of importing I need to do in order to have access to the OptionsManager?
 
It seems to do nothing because it can only change the cached, not the actual, setting value. For example, this code would work:
Controls.SinglePlayerAutoEndTurnCheckBox:RegisterCheckHandler(
function(isChecked)
OptionsManager.SyncGameOptionsCache();
OptionsManager.SetSinglePlayerAutoEndTurnEnabled_Cached(isChecked);
OptionsManager.CommitGameOptions();
end);
 
Awesome. Sadly, I'm at work right now and can't test this out, but I see what you're saying about only affecting the cached value.

Is there any was of discovering this type of thing? Or is this just tribal knowledge that you either know or you don't? In other words, how did you know you'd need to call OptionsManager.SyncGameOptionsCache() before and OptionsManager.CommitGameOptions() after the call to set the cached value?
 
Back
Top Bottom