Thalassicus
Bytes and Nibblers
I pass a variable to a function. The variable is a number, but the function receives a table, which breaks later actions. What's going on here?
Code:
TU - Event Registration: ERROR OnBuildingConstructed cityID = 295
TU - Event Registration: ERROR SaveCity cityID = table: 4F74D8D8
PHP:
Events.SavegameData = Events.SavegameData or {}
Events.SavegameData.New = Events.SavegameData.New or function(self)
local saveData = Modding.OpenSaveData()
local o = {}
setmetatable(o, self)
self.__index = self
o.modName = "DefaultModName"
o.SetModName = function (self, modName)
self.modName = modName
end
o.SaveCity = function (cityID, key, value)
log:Error("SaveCity cityID = %s", cityID)
return saveData.SetValue(string.format("%s_city%s_%s", self.modName, cityID, key), value)
end
...
end
local store = Events.SavegameData:New()
store:SetModName("CiVUP")
function OnBuildingConstructed(player, city, buildingID)
local cityID = City_GetID(city)
MapModData.buildingsAlive[cityID][buildingID] = true
log:Error("OnBuildingConstructed cityID = %s", cityID)
store:SaveCity(cityID, "buildingsAlive_"..buildingID, true)
end