Skip to content

Instantly share code, notes, and snippets.

@The-Speck
Created August 14, 2019 00:27
Show Gist options
  • Save The-Speck/f949bd1adb2401a40c820707d96e262e to your computer and use it in GitHub Desktop.
Save The-Speck/f949bd1adb2401a40c820707d96e262e to your computer and use it in GitHub Desktop.
Era Gate Script for Civ 6
-- Era Gate 2 Script by Alex P.
EraType2ChronoIdxMap = {};
function populateEraType2ChronoIdxMap()
for row in GameInfo.Eras() do
EraType2ChronoIdxMap[row.EraType] = row.ChronologyIndex;
end
end
function EraGate ()
print("Running Era Gate Script");
local currentEraIndex :number = Game.GetEras():GetCurrentEra();
local aPlayers = PlayerManager.GetAliveMajors();
for _, pPlayer in ipairs(aPlayers) do
local playerTechs = pPlayer:GetTechs();
local playerCivics = pPlayer:GetCulture();
local techId = 0;
local civicId = 0;
for tech in GameInfo.Technologies() do
if (EraType2ChronoIdxMap[tech.EraType] > currentEraIndex + 1 and not playerTechs:HasTech(techId)) then
print("Increase cost for " .. tech.TechnologyType);
playerTechs:SetResearchProgress(tech.Index, -99999);
elseif (EraType2ChronoIdxMap[tech.EraType] == currentEraIndex + 1 and not playerTechs:HasTech(techId)) then
print("Set original cost for " .. tech.TechnologyType);
playerTechs:SetResearchProgress(tech.Index, 0);
end
techId = techId + 1;
end
for civic in GameInfo.Civics() do
if (EraType2ChronoIdxMap[civic.EraType] > currentEraIndex + 1 and not playerCivics:HasCivic(civicId)) then
print("Increase cost for " .. civic.CivicType);
playerCivics:SetCulturalProgress(civic.Index, -99999);
elseif (EraType2ChronoIdxMap[civic.EraType] == currentEraIndex + 1 and not playerCivics:HasCivic(civicId)) then
print("Set original cost for " .. civic.CivicType);
playerCivics:SetCulturalProgress(civic.Index, 0);
end
civicId = civicId + 1;
end
end
end
populateEraType2ChronoIdxMap();
-- Use for FireTuner in 'GameCore_Tuner' mode
--EraGate();
-- This needs a proper hook. Something for when entering a new era.
--GameEvents.OnNewEra.Add(EraGate)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment