• We are currently performing site maintenance, parts of civfanatics are currently offline, but will come back online in the coming days (this includes any time you see the message "account suspended"). For more updates please see here.

SetNumRealBuilding

Thalassicus

Bytes and Nibblers
Joined
Nov 9, 2005
Messages
11,057
Location
Texas
I have two variables, city and buildingID. I print the city name and building ID, then call city:SetNumRealBuilding(buildingID, 1) with this code:
PHP:
logger:Error("CheckFreeBuildings %10s best %10s building: %20s", city:GetName(), row.FlavorType, (buildingID == -1) and "None Available" or GameInfo.Buildings[buildingID].Type)
if buildingID ~= -1 then
  city:SetNumRealBuilding(buildingID, 1)
  logger:Error("Awarded Building")
end
This is the output:
Code:
ERROR  CheckFreeBuildings     London best FLAVOR_CULTURE building:      BUILDING_TEMPLE
ERROR  Awarded Building
No temple appears in London... how the heck is this possible? :confused:
 
I've been using that function for a long time now with no problems, although in my case it's a simpler
Code:
pCity:SetNumRealBuilding(GameInfoTypes.BUILDING_PLUS_1,happyCount);
since I already know exactly what building type I want to be adding. (I've got several of these as part of my "Head Start" mechanism.)

So if your BuildingID equals GameInfoTypes.BUILDING_TEMPLE, then it should work just fine. Now, I'm not sure how it deals with prerequisites for this; if the city doesn't have a Monument, will placing a Temple work? I know that it fails when doing that for the FreeStartEra stubs, so it's possible that the function limits you like that.
 
I city:CanConstruct(buildingID) returns true, so in theory the prerequisite should be met. Maybe I'm getting the parameters wrong for CanConstruct? There are:

boolean city:canConstruct(int iBuilding, boolean bContinue, boolean bTestVisible, boolean bIgnoreCost);

There's only one example of where these parameters are used: "city:CanConstruct( buildingID, 0, 1 )" in ProductionPopup.lua.
 
The problem is that some places that have that sort of index want the building CLASS, not the entry in the Buildings table. The SetNumRealBuildings definitely uses the Buildings entry, but the CanConstruct might go by class...
 
Back
Top Bottom