Before creating other mods, I would like to know the cost of the district's production when a district is added.
After applying this lua code, when I actually build the District, the log is as shown below.
I understand that there is no GetDistrictCost function, but I couldn't find another alternative.
Any help on how to fix the error would be appreciated.
Code:
function OnDistrictAddedToMap( playerID:number, districtID:number, cityID:number, districtX:number, districtY:number, districtType:number, percentComplete:number )
local city = CityManager.GetCity(playerID, cityID); -- collect
local districtInfo = GameInfo.Districts[districtType]; -- collect
local pBuildQueue = city:GetBuildQueue(); -- collect (not error)
print( string.format("TARGET DISTRICT : %s", districtInfo.DistrictType) ); -- PRINT
local cost = pBuildQueue:GetDistrictCost(districtInfo.Index); -- line 8, error
print( string.format("COST : %d", cost) ); -- NOT PRINT
end
function Initialize()
Events.DistrictAddedToMap.Add( OnDistrictAddedToMap );
end
Initialize();
After applying this lua code, when I actually build the District, the log is as shown below.
Code:
...
My_Lua: TARGET DISTRICT : DISTRICT_CAMPUS
Runtime Error: "LUA_FILE_PATH":8: function expected instead of nil
stack traceback:"LUA_FILE_PATH":8: in function 'OnDistrictAddedToMap'
[C]: in function 'func'
[C]: in function '(anonymous)'
...
I understand that there is no GetDistrictCost function, but I couldn't find another alternative.
Any help on how to fix the error would be appreciated.