Registering game rule mods, (was: Hooking next turn)

Pococurante

Chieftain
Joined
Dec 22, 2005
Messages
40
I'm using Kael's (superb) modding guide to create a new feature that can change for all players (AI and human), very similar to Bhuir's TreeGrowth mod.

I can see my script in memory but it does not trigger when I end the turn. What am I doing wrong? Thx folks.

Code:
function OnNextTurn()
      print("Bouncing for Joy");
end
function Create()
   IsDebug = true;
   print("Happy happy");
end

Events.SerialEventTurnTimerDirty.Add(OnNextTurn);
-- Events.ActivePlayerTurnEnd.Add(OnNextTurn);
Create();

Edit: What I expect to see in Tuner are my print statements, that I was able to init constants and then see my handler print more comments every time I end the turn (and for every "player" AI or human). Tuner is set to mainstate, I end the turn, and see nothing.
 
SerialEventTurnTimerDirty doesn't do what you think it does. It is called when someone clicks the end turn button, but doesn't run for the AI.
 
Thanks Arness - on reflection that's fine for what I want to do.

But I never see my print statements so I assume my routine is not triggering. My Fire Tuner is set to MainView and I've experimented with other views - all with no luck.

I've seen in other posts that an LUA script can fail silently - could this be be problem and if so how do I detect the fail point?

I love that they used Visual Studio but it is mildly frustrating that none of its features are really leveraged for us, i.e. intellisense, stepped debug etc.
 
I don't mean to insult you or anything, but you've added the lua file to the appropriate tab in the mod properties window, right?
 
Okay found what I was doing wrong - I had failed to update the "Content" tab of the project properties so that Civ knew I was hooking the "Game Rules" type for my mod. And now I get feedback on my syntax error... ah well, one more step up the learning curve!
 
I don't mean to insult you or anything, but you've added the lua file to the appropriate tab in the mod properties window, right?
Err umm ahhh well you see...

No I hadn't. :sad:

I'm never insulted when folks try to save me from myself! :goodjob:
 
I've forgotten it enough times now that it's always the very first thing that I check once I suspect my code isn't being executed.

Glad to help.
 
Top Bottom