LUA and Pillaging

Joebles

Chieftain
Joined
Jun 9, 2014
Messages
62
Okay, so I'm running into a roadblock with a UA. Essentially, I want the trait to add progress toward your next golden age every time one of your units pillages an enemy tile. While I think I know exactly how to do this in the DLL, I want to do it through LUA in order to maximize compatibility.

The problem I have is I can't seem to find any lua functions to hook into relating to pillaging. The Plot object has a potential function, SetImprovementPillaged, but this test code:
Code:
function PillageTest(pillaged)
	print("SetImprovementPillaged fired.")
end

Plot.SetImprovementPillaged.Add(PillageTest)

does not appear to work - it gives me "attempt to index field 'Plot' (a nil value)" error. I'm assuming that means that since Plot is related to an object, I can't hook a new function into it this way (or probably at all)

Are the only functions you can properly hook into in the GameEvents / Events / LuaEvents objects? Or am I missing a critical bit that would allow me to get into other kinds of functions?

I apologize if this is a really basic and/or obvious LUA question, I'm slowly learning about the language but it's kind of patchwork and I'm obviously missing things.
 
You are correct that you can only hook into events. Plots are not something you can hook into.

As for giving a bonus when pillaging a tile, there isn't a way to detect when a tile is pillaged unless you mod the DLL. The SerialEvent won't work because it is for the UI and won't fire for things like tiles that the player can't see. There was an improvement event added in BNW that may work but I haven't looked closely at it.
 
Damn, I was afraid of that. From the looks of it the, the improvement events (at the least SerialEventImprovementCreated and SerialEventImprovementDestroyed) are related to drawing improvements on the map, and not necessarily to their creation in the game world. I'm going to dig through the actual .lua files but I may have to call this one a lost cause.
 
Back
Top Bottom