How do I create a handler for Event.SerialEventDawnOfManShow?

General Tso

Panzer General
Joined
Oct 12, 2007
Messages
1,547
Location
U. S. of A.
I've made event handlers in Lua before and I usually do something like this:

Code:
function OnDawnOfManShow(civID)
	print("OnDawnOfManShow!");
end
Events.SerialEventDawnOfManShow.Add(OnDawnOfManShow);

For some reason I can't get the above code to work.

It appears that the SerialEventDawnOfManShow event is triggered in UI\FrontEnd\LoadScreen. I added that file to my mod and ran some tests. The event is being triggered but my handler is never called. Any ideas?
 
I admit that the whole operation of including files in a mod confuses me but I think I tried everything.

I tried creating a lua and xml file combination with the same name and VFS = true for both. That didn't work.

I tried adding the code to my UI files that are started from AdvancedSetup.lua (in the front end). That didn't work.
 
You won't be able to trap that event with a standard handler (ie in it's own Lua file and loaded via InGamUIAddin) as the event is fired BEFORE the InGame.lua file loads the mod's event handlers.

You could only trap it from a replacement for a core game Lua file (ie one with VFS=true), it which case you may as well replace LoadScreen.lua and just directly call your method at the point the event is fired
 
I used that thread in the past and it was very helpful. I'm using those concepts in my mod. I'll explain what I'm doing. Maybe that will help.

My mod is divided into two parts. The first part runs when the front end is active. The second part runs in game.

The first part hooks into the game by overriding the game file AdvancedSetup.lua. All of my mod files are either included or are LuaContext's.

The second part is hooked into the game by using InGameUIAddin.

If I try to add a handler during either phase it appears to work (the table appears in Events) but it never gets called. It looks like the entry that was added in the front end is ignored and the entry created in game is created after the DawnOfMan screen closes. So it to is ignored. I may be wrong but that's what appears to be happening.
 
the entry created in game is created after the DawnOfMan screen closes. So it to is ignored.

Correct. Because your code is being loaded by the standard InGame.lua file and that (as per previous post) is being executed AFTER the DoM screen
 
Thanks for the input people. I didn't want to do it but I just overrode the LoadScreen.lua game file in my mod. That solved the problem at the risk of making my mod incompatible with certain other mods. I guess it's worth the restriction. Now users won't have to save and load the game to see the graphics changes when terrain is changed. :)
 
Yeah I always use UI stuff as pairs. Just to be on the safe side.
 
Wow. I wasn't aware of that.
 
Top Bottom