Created
August 14, 2019 00:27
-
-
Save The-Speck/f949bd1adb2401a40c820707d96e262e to your computer and use it in GitHub Desktop.
Era Gate Script for Civ 6
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- 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