Building requires gold code?

Both functions are being passed the info for a Building, so you need your GameInfoTypes["Something"] to refer to the Building and not the Building-Class.

These:
Code:
function FortKnoxBuilt([COLOR="Blue"]playerId, cityId, buildingType, bGold, bFaithOrCulture[/COLOR])
are called "arguments", and they are automatically passed from the game to any function that is "Add"-ed to GameEvents.CityConstructed. The arguments are given the appropriate data by the game each time the function FortKnoxBuilt needs to run. The arguments give pre-defined (by Firaxis) types of information, and must be placed in pre-defined order. buildingType will be the game's internal ID# for the building that was just constructed. What you are telling the lua to do when you state GameInfoTypes["BUILDING_FORT_KNOX"] is to go look through the XML/SQL database and give you the internal ID# for BUILDING_FORT_KNOX.

This line:
Code:
if(buildingType == GameInfoTypes["BUILDING_FORT_KNOX"]) then
is comparing the ID# the game passed to function FortKnoxBuilt for its argument buildingType to what is assigned as an internal ID# for BUILDING_FORT_KNOX and only running the next line:
Code:
player:ChangeGold(-300);
when the two are the same ID# (hence the == symbology).

With regard to spending-away all your gold and still being able to build the wonder, are you spending away all your gold before or after you start constructing the wonder in one of your cities?
 
...however when I dump all of my gold into other buildings to put me under 300 gold, I can still build the wonder.
That is because I had some mistakes in the restriction code that I've edited the previous post to fix. Essentially I had the wrong argument list.

With regard to spending-away all your gold and still being able to build the wonder, are you spending away all your gold before or after you start constructing the wonder in one of your cities?
Unless the behavior of the CanConstruct events has changed, they should be checked whenever a player opens up their production queue and at the start of each turn. I know of no way to sneak around them.
 
That is because I had some mistakes in the restriction code that I've edited the previous post to fix. Essentially I had the wrong argument list.


Unless the behavior of the CanConstruct events has changed, they should be checked whenever a player opens up their production queue and at the start of each turn. I know of no way to sneak around them.
That would explain it then. I've only used the City version for buildings-restrictions and wasn't sure whether the player-version only ran when adding the building/wonder to a city build qeue (ie, I thought maybe the player version would not care about buildings already in a city's construction qeue)

I guess we all make those copy-paste errors, so maybe I shouldn't present it as being only a novice-modder mistake. :)
 
It works!

Whenever I ended a turn under 300 gold the building was kicked out on the next turn with no production added to it (doesn't even show up on the list of what to build).

I even tested it on turns when I ended under 300 gold but would be at 300+ gold on the next turn and sure enough no production went towards it.

Thank you Machiavelli24 and LeeS for your time and help with this! Gods among men. :bowdown:
 
Back
Top Bottom