Starrynite120
Prince
- Joined
- Jul 15, 2015
- Messages
- 472
I'm trying to make a workaround to allow colonists to grant yields to specialist. I'm using the loadouts grant perks to create a playerperk that is assigned to each colonist, then I made a building for each colonist to increase the yields of their respective specialists (ex. artists grant extra yields to artists). Then, I made this lua code to on turn one detect if the player has the playerperk and then grant the corresponding building in the capital city. Unfortunately, the lua script is not working and firetuner did not detect any errors. Could anyone give me a hand?
Code:
function ColonistSpecialists(playerID, buildingID, cityID, bComplete)
local currentTurn = Game.GetGameTurn();
local refugee = GameInfo.Buildings["BUILDING_COLONIST_REFUGEES"].ID
local engineer = GameInfo.Buildings["BUILDING_COLONIST_ENGINEERS"].ID
local aristocrat = GameInfo.Buildings["BUILDING_COLONIST_ARISTOCRATS"].ID
local scientist = GameInfo.Buildings["BUILDING_COLONIST_SCIENTISTS"].ID
local artist = GameInfo.Buildings["BUILDING_COLONIST_ARTISTS"].ID
local refugeePerk = GameInfo.PlayerPerks["PLAYERPERK_COLONIST_REFUGEES"].ID;
local engineerPerk = GameInfo.PlayerPerks["PLAYERPERK_COLONIST_ENGINEERS"].ID;
local aristocratPerk = GameInfo.PlayerPerks["PLAYERPERK_COLONIST_ARISTOCRATS"].ID;
local scientistPerk = GameInfo.PlayerPerks["PLAYERPERK_COLONIST_SCIENTISTS"].ID;
local artistPerk = GameInfo.PlayerPerks["PLAYERPERK_COLONIST_ARTISTS"].ID;
local Player = Players[playerID];
local City = Player:GetCapitalCity();
if (currentTurn == 1 and Player:HasPerk(refugeePerk)) then
City:SetNumRealBuilding(refugee, 1)
elseif (currentTurn == 1 and Player:HasPerk(engineerPerk)) then
City:SetNumRealBuilding(engineer, 1)
elseif (currentTurn == 1 and Player:HasPerk(aristocratPerk)) then
City:SetNumRealBuilding(aristocrat, 1)
elseif (currentTurn == 1 and Player:HasPerk(scientistPerk)) then
City:SetNumRealBuilding(scientist, 1)
elseif (currentTurn == 1 and Player:HasPerk(artistPerk)) then
City:SetNumRealBuilding(artist, 1)
end
end
GameEvents.PlayerDoTurn.Add(ColonistSpecialists);