Troller0001
I've anxiously awaited your arrival!
Im kinda new to Lua and had a few questions about this function that I found on the Modwiki:
void Events.SerialEventUnitCreated(PlayerID player, UnitID unitID, int hexVec, int unitType, int cultureType, int civID, int primaryColor, int secondaryColor, int unitFlagIndex, int fogState)
These are my questions:
So here's my other question:
If I want to check for the movement of a specific unit how would I do this without causing much lag/crash potential (The code below probably illustrates a bad example which will cause lag, especially in the late-game)
Last question, does UnitSetXY execute if a unit is given a new move command, or when it has moved to a new hex? (So also if a unit is given a move command 2 tiles further away, does it execute for every tile it will move over?) Answer: Yes it does. It also fires when a unit is created or when it embarks. The unit walking animation will still fire first though (even if it moves more than 1 tile) (Thanks to Civitar, bane_ and Civitar)
Sorry if these questions seem very easy to answer, I'm just starting out with Lua.
Thanks in advance!
-Troller0001
void Events.SerialEventUnitCreated(PlayerID player, UnitID unitID, int hexVec, int unitType, int cultureType, int civID, int primaryColor, int secondaryColor, int unitFlagIndex, int fogState)
These are my questions:
This function is executed every time a unit is created right?If yes, does this include city state gifting as well (so when a city state has gifted you a unit) Partial Answer: Yes. (Thanks to Klisz, bane_ and LeeS)- What does hexVec mean? Is it the hex-ID that the unit was created on?
- What does fogState mean? Does it have to do with the fog of war?
- Does cultureType have anything to do with the art-style of the Civ? (E.g. Mediterranean)
- If #1 is true, do I use the function as this:
Code:Events.SerialEventUnitCreated.Add(function(iPlayer, iUnitID, iHexVec, iUnitType, iCultureType, iCivID, iPrimaryColor, iSecondaryColor, iUnitFlagIndex, iFogState) --further code blah blah end)
So here's my other question:
If I want to check for the movement of a specific unit how would I do this without causing much lag/crash potential (The code below probably illustrates a bad example which will cause lag, especially in the late-game)
Spoiler :
Code:
local iUnitToCheck = GameInfoTypes.UNIT_ARCHER --this could either be a unit type or a unit ID; It's here just to illustrate
GameEvents.UnitSetXY.Add(function(iPlayer, iUnit, iPlotX, iPlotY)
if(iUnit==iUnitToCheck)then
--further code blah blah
end
end)
Sorry if these questions seem very easy to answer, I'm just starting out with Lua.
Thanks in advance!
-Troller0001