Colonists give yields to specialists

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);
 
I've wanted to expand Loadouts grant perks to include support for capital only buildings, but since I didn't need that functionality for my own stuff it was low priority. I've put together a new version that can do it, but I want some time to regression test it before I push it out on the workshop.

I'll PM you a link to the untested version you can use in the mean time. So long as you're ok with waiting for the updated version on the workshop before releasing your mod.
 
Top Bottom