Craig_Sutter
Deity
The following function is supposed to look for iron and horses in a cities of a certain minor state and install a building if that resource is within the city radius.
It is not functioning.
The even handle at the end works for various other functions that I use to install buildings in cities (the ones commented out at the end), but the FrankSpawnPoint() function is not working as expected.
The Weaponsmith building is installed and can be placed using IGE. The stable is the normal one.
I am not getting a print statement from the function and the buildings are not appearing even though I place requisite resources in the city radius.
Thank-you in advance for your assistance.
It is not functioning.
The even handle at the end works for various other functions that I use to install buildings in cities (the ones commented out at the end), but the FrankSpawnPoint() function is not working as expected.
The Weaponsmith building is installed and can be placed using IGE. The stable is the normal one.
I am not getting a print statement from the function and the buildings are not appearing even though I place requisite resources in the city radius.
Code:
-- for player civ Frank, loop through the players
-- for Franks loop through cities to see eligible for stable or weaponsmith and place if eligible
function FrankSpawnPoint()
-- find Franks
for PlayerID=GameDefines.MAX_MAJOR_CIVS, GameDefines.MAX_CIV_PLAYERS-1, 1 do
local pPlayer = Players[PlayerID];
if pPlayer:IsEverAlive() then
if (GameInfo.MinorCivilizations.MINOR_CIV_FRANKS.ID == pPlayer:GetMinorCivType()) then
-- Enumerate cities
for pCity in pPlayer:Cities() do
-- City exists and and has horses or iron... build stable or weaponsmith if eligible
Stables = pCity:GetNumRealBuilding(GameInfoTypes["BUILDING_STABLE"])
Weaponsmiths = pCity:GetNumRealBuilding(GameInfoTypes["BUILDING_WEAPONSMITH"])
if pCity ~= nil and pCity:IsHasResourceLocal(GameInfoTypes["RESOURCE_HORSE"]) then
if Stables == 0 then
pCity:SetNumRealBuilding(GameInfoTypes["BUILDING_STABLE"], 1);
print(pCity:GetName(), "spawning Stable")
end
elseif pCity ~= nil and pCity:IsHasResourceLocal(GameInfoTypes["RESOURCE_IRON"]) then
if Weaponsmiths == 0 then
pCity:SetNumRealBuilding(GameInfoTypes["BUILDING_WEAPONSMITH"], 1);
print(pCity:GetName(), "spawning Weaponsmith")
end
end
end
end
end
end
end
--to set trait changes
local g_lastTurn = -1
local function OnPlayerDoTurn(iPlayer)
local gameTurn = Game.GetGameTurn()
if g_lastTurn < gameTurn then
g_lastTurn = gameTurn
--per game turn function here
--MerciaBretwalda()
--NorthumbriaBretwalda()
--WessexBretwalda()
--LlandrindadHall()
--CaerwentHall()
--CarmarthenHall()
--PictTrait()
FrankSpawnPoint()
end
end
GameEvents.PlayerDoTurn.Add(OnPlayerDoTurn)
Thank-you in advance for your assistance.