Thalassicus
Bytes and Nibblers
So I have a function:
I call it twice:
GetCityRewards(majorCivID, true)
GetCityRewards(city:GetOwner())
The output is:
Update
Ramkhamhaeng is table: 15BF0938
Do nothing
Ramkhamhaeng is nil
These are the only times the playerCityRewards variable is referenced. The global variable's defined one moment, I do nothing, and it becomes nil... arggh!
What did I do wrong?
PHP:
playerCityRewards = {}
function GetCityRewards(majorCivID, doUpdate)
if doUpdate then
print("Update")
playerCityRewards[majorCivID] = {}
...do stuff...
playerCityRewards[majorCivID][cityIDs[k]] = {food=v, culture=0, spawn=0}
else
print("Do nothing")
end
print(Players[majorCivID]:GetName().." is "..tostring(playerCityRewards[majorCivID]))
return playerCityRewards[majorCivID]
end
GetCityRewards(majorCivID, true)
GetCityRewards(city:GetOwner())
The output is:
Update
Ramkhamhaeng is table: 15BF0938
Do nothing
Ramkhamhaeng is nil
These are the only times the playerCityRewards variable is referenced. The global variable's defined one moment, I do nothing, and it becomes nil... arggh!

What did I do wrong?