I just do this towards the top of my lua, before any of the functions for PlayerDoTurn, CityConstructed, etc., are presented in the code:
Code:
gLeonardoBClass = GameInfoTypes.BUILDINGCLASS_LEONOARDOS_WORKSHOP
Then in the PlayerDoTurn function I do this:
Code:
if pPlayer:GetBuildingClassCount(gLeonardoBClass) > 0 then
--do some stuff, ie, your code for adding and removing dummies based on whether the city is connected to the capital
end
Obviously you would change the name of the variable to something else besides
gLeonardoBClass and you will need the proper name of the Hoover Dam Wonder's Building-
Class
For the purposes of Civ5 modding, forget your C++ instructor's fetish about 'global' variables. Every time the game has to find the info that matches for a
GameInfoTypes["SOMETHING_OR_OTHER"] or
GameInfoTypes.SOMETHING_OR_OTHER takes time because the game has to go through the list of all the valid GameInfoTypes that are in the XML/SQL database. If your code is doing this every turn, or multiple times per turn, it takes far less time to do this look-up once, stick it in a variable, and have it available for the rest of the player's play-session than it does to look that info up and grab it from the game's database every time it needs to refer to that information.
Remember that your code is also going to be running alongside everyone else's code, and if everyone programs their lua so that every turn and for every player (human, AI, city-state, barbarian) the game has to look up all these different pieces of information from the game's database every time (or multiple times per turn) for every player, this can very quickly reach a point where the player sees a quite noticable turn-processing lag.
By grabbing the info and sticking it into a variable at the top of your lua (before your lua does anything else) that info will be available everywhere else in the same lua
file so that all functions in the same
file can use it without ever having to re-look-up the info from the game's database, and by using this method it forces you to be consistent with the way you name the variable in all your functions within the same
file, which means all those functions will be "playing the same tune".