ww2commander
Emperor
Have written some code to capture units in production with 1 turn left. The code seems to work from what I can tell, but when I try to print out the multi-array values the Firetuner shows no print statements. Note that Dprint is a print function which works just fine.
The section in red fails to trigger. Any suggestions as to what I am doing wrong?
The section in red fails to trigger. Any suggestions as to what I am doing wrong?
Code:
function ProcessEndTurnInfos ()
Dprint("FUNCTION: ProcessEndTurnInfos")
g_UnitAvailableNextTurn = {}
for playerID = 0, GameDefines.MAX_CIV_PLAYERS - 1 do
local player = Players[playerID]
if ( player:IsAlive() ) then
civID = GetCivIDFromPlayerID(playerID)
g_UnitAvailableNextTurn[civID] = {} -- Create array for civ's units
Dprint ("Identifying new units that will be available next turn for player "..player:GetName())
local index = 1
for city in player:Cities() do
local unitType = city:GetProductionUnit() -- Get any unit being produced by this city
if unitType ~= -1 then
if city:GetUnitProductionTurnsLeft(unitType) == 1 then -- Capture units that will be completed next turn
local unitID = GameInfo.Units[unitType].ID
g_UnitAvailableNextTurn[civID][index] = {}
g_UnitAvailableNextTurn[civID][index].CityPlot = GetPlotKey(city:Plot())
g_UnitAvailableNextTurn[civID][index].UnitTypeID = unitID
g_UnitAvailableNextTurn[civID][index].TurnExpected = (Game.GetGameTurn() + 1)
index = index + 1
end
end
end
[COLOR="Red"] for key, data in ipairs(g_UnitAvailableNextTurn) do
for key2, unitData in ipairs(data) do
Dprint("CityPlot: "..unitData.CityPlot.." - UnitTypeID: "..unitData.UnitTypeID.." - TurnExpected: "..unitData.TurnExpected)
end
end[/COLOR]
end
end
end