Mikhaelstan
Chieftain
- Joined
- Dec 10, 2016
- Messages
- 18
Hi everyone, I've recently finished my first LUA code and would be very grateful if someone could proofread it to identify errors and make suggestions.
The first provides Great Writer points equal to the number of Landmarks in your territory and the happiness derived from discovered Natural Wonders.
function TjukurpaGP(playerID, city)
local pCapital = pPlayer:GetCapitalCity()
local iNatureHappy = pPlayer:GetHappinessFromNaturalWonders()
local iLandmark = GameInfoType["Improvement_Landmark"]
local iLandmarkCount = pPlayer:GetImprovementCount(iLandmark)
local iAlteration = iNatureHappy + iLandmarkCount
if pCapital then
else pCapital:ChangeSpecialistGreatPersonProgressTimes100(GameInfoTypes.SPECIALIST_WRITER, 100*iAlteration)
end
end
GameEvents.PlayerDoTurn.Add(TjukurpaGP)
The second gifts a free Great Writer after the completion of a Landmark 30% of the time
function AllBecomesHidden(playerID, improvementID)
local pPlayer = Players[player]
local iThreshold = pCity:GetSpecialistUpgradeThreshold(Specialist_Writer)
local iProgress = pCity:GetSpecialistGreatPersonProgressTimes100(Specialist_Writer*100)
local iThreshold = pCity:GetSpecialistUpgradeThreshold(Specialist_Writer)
local iDice = Math.Random(0.1, 1.0)
local iCanAdd = iThreshold - iProgress
if pPlayer:GetCivilizationType() == GameInfoTypes.CIVILIZATION_PITJANTJATJARA then
if (pCity == nil) then return end
if improvementID = Improvement_Landmark then
if iDice > 0.3 then end
else iDice <= 0.3 then
pCity:ChangeSpecialistGreatPersonProgressTimes100(Specialist_Writer, iCanAdd*100)
end
end
end
end
GameEvent.BuildFinished.Add(AllBecomesHidden)
Thanks in advance.
The first provides Great Writer points equal to the number of Landmarks in your territory and the happiness derived from discovered Natural Wonders.
Spoiler :
function TjukurpaGP(playerID, city)
local pCapital = pPlayer:GetCapitalCity()
local iNatureHappy = pPlayer:GetHappinessFromNaturalWonders()
local iLandmark = GameInfoType["Improvement_Landmark"]
local iLandmarkCount = pPlayer:GetImprovementCount(iLandmark)
local iAlteration = iNatureHappy + iLandmarkCount
if pCapital then
else pCapital:ChangeSpecialistGreatPersonProgressTimes100(GameInfoTypes.SPECIALIST_WRITER, 100*iAlteration)
end
end
GameEvents.PlayerDoTurn.Add(TjukurpaGP)
The second gifts a free Great Writer after the completion of a Landmark 30% of the time
Spoiler :
function AllBecomesHidden(playerID, improvementID)
local pPlayer = Players[player]
local iThreshold = pCity:GetSpecialistUpgradeThreshold(Specialist_Writer)
local iProgress = pCity:GetSpecialistGreatPersonProgressTimes100(Specialist_Writer*100)
local iThreshold = pCity:GetSpecialistUpgradeThreshold(Specialist_Writer)
local iDice = Math.Random(0.1, 1.0)
local iCanAdd = iThreshold - iProgress
if pPlayer:GetCivilizationType() == GameInfoTypes.CIVILIZATION_PITJANTJATJARA then
if (pCity == nil) then return end
if improvementID = Improvement_Landmark then
if iDice > 0.3 then end
else iDice <= 0.3 then
pCity:ChangeSpecialistGreatPersonProgressTimes100(Specialist_Writer, iCanAdd*100)
end
end
end
end
GameEvent.BuildFinished.Add(AllBecomesHidden)
Thanks in advance.