LUA Function that only occurs on Wonder Completion

FieryCharizard7

Chieftain
Joined
Jul 8, 2016
Messages
62
Location
Chicaaago
Hello all,

I am working on a Wonder that was said to have "given birth to the Renaissance" so I was planning on this wonder giving the player the Acoustics tech upon completion if not already discovered. I am unsure where to implement this function as it only needs to run once, so Running it on every players turn would be redundant.

I figured I'd have the code along the lines of

Code:
function CampanileTech(iPlayer)
    if (Teams[pPlayer:GetTeam()]:IsHasTech(GameInfoTypes.TECH_ACOUSTICS,) == false) then
            Teams[pPlayer:GetTeam()]:SetHasTech(GameInfoTypes.TECH_ACOUSTICS, true)
    end
end   
    
GameEvents.--Production Complete--.Add(CampanileTech)

Other than where to add the function, is this correct?
 
Code:
function CampanileTech(ownerId, cityId, buildingType, bGold, bFaithOrCulture)
	if buildingType == GameInfoTypes.BUILDING_SOME_WONDER then
		local pPlayer = Players[ownerId]
		local pTeam = Teams[pPlayer:GetTeam()]
		if not pTeam:IsHasTech(GameInfoTypes.TECH_ACOUSTICS) then
			pTeam:SetHasTech(GameInfoTypes.TECH_ACOUSTICS, true)
		end
	end
end
GameEvents.CityConstructed.Add(CampanileTech)
The code needs to be placed within an lua file and that lua file needs to be setup in ModBuddy as an "InGameUIAddin". See post #3 of whoward69's what ModBuddy setting for what file types tutorial

For listing of Event types the game uses, see:
http://modiki.civfanatics.com/index.php?title=GameEvents_(Civ5_Type)
http://modiki.civfanatics.com/index.php?title=Events_(Civ5_Type)
http://modiki.civfanatics.com/index.php?title=LuaEvents_(Civ5_Type)

and

https://forums.civfanatics.com/threads/bnw-lua-api-reference.558353/

William's reference gives an up-to-date listing of all the methods & events that are valid for BNW, though seeing the links to the attached files within his thread are not always easy to see since the forum software was updated and made a bit of a mess of the thread posts. There are downloadable spreadsheet files linked in William's thread, as well as downloadable zip folders that show the various events and methods as xml text that can be more easily searched and referenced.
 
Back
Top Bottom