How to use "SerialEventForestRemoved"

bismark439

Chieftain
Joined
Aug 26, 2013
Messages
34
I found this from here
http://modiki.civfanatics.com/index.php/Lua_Game_Events

SerialEventFeatureCreated
SerialEventFeatureDestroyed
SerialEventForestCreated
SerialEventForestRemoved
SerialEventJungleCreated
SerialEventJungleRemoved

there are multiple things that i am interested in but there is no further description about this code.

I want to make a code that creates unit on where forest is destroyed.

then I would need iX iY and player who destroyed stuff:crazyeye:

Is there any reference that I can find codes? or anyone knows this?:confused::confused:
 
Those events are for updating the graphics on the visible map, so only fire if the active player can see the tile the action happened for - ie, if the AI chops a forest on a tile the player can't see, no event is fired - which makes them pretty much useless.
 
All of the "Events" are about graphics or something to do with user interface. Using them for game rule effects is, at best, very dangerous.

You should look at "GameEvents" for consistent behavior that is not tied to UI. One that may (or may not) be useful to you is BuildFinished( playerID, x, y, improvementID ). I have no idea if this fires for forest removal. Maybe, since it is a "Build". Set up a "listener" to find out:

Code:
print("Loading OnBuildFinishedListener...")
function OnBuildFinishedListener( playerID, x, y, improvementID )
	print("OnBuildFinishedListener: ", playerID, x, y, improvementID)
end
GameEvents.BuildFinished.Add(OnBuildFinishedListener)

Then run a worker around and build stuff and chop to see when it fires.


Otherwise, you can just do a check of the whole map each turn.
 
BuildFinished is only useful for detecting improvements - there is no way to differentiate building a road, chopping a forest or pillaging a tile - all of them will pass -1 in the improvement parameter
 
- all of them will pass -1 in the improvement parameter
I wasn't even sure if it would fire at all. If it does fire, then you could figure that out some other way. For example, in my mod every plot "knows" whether it was ever a forest, jungle or marsh (and if it was but isn't now, what turn it was removed). That info is all held using plot:SetScriptData(), plot:GetScriptData(). So BuildFinished (with -1) tells me something happened here. The plot can then check itself to see if it was a forest but isn't now.
 
I wasn't even sure if it would fire at all. If it does fire, then you could figure that out some other way. For example, in my mod every plot "knows" whether it was ever a forest, jungle or marsh (and if it was but isn't now, what turn it was removed). That info is all held using plot:SetScriptData(), plot:GetScriptData(). So BuildFinished (with -1) tells me something happened here. The plot can then check itself to see if it was a forest but isn't now.
Sorry to necrobump this thread. Could you possibly elaborate on how you're doing this. Or direct me to the relevant code?
 
Top Bottom