Checking if the current era is less than another era with lua

turingmachine

Emperor
Joined
May 4, 2008
Messages
1,438
Okay, so I was trying something like:

local mEra = GameInfoTypes.ERA_MODERN;

[...]

if (pTeam:GetCurrentEra() < mEra) then

but I don't think I'm defining the era correctly?

Can anyone help?
 
Works for Firaxis (from SocialPolicyPopup.lua)

local iEraPrereq = GameInfoTypes[policyBranchInfo.EraPrereq]
if (iEraPrereq ~= nil and pTeam:GetCurrentEra() < iEraPrereq) then
 
Works for Firaxis (from SocialPolicyPopup.lua)

local iEraPrereq = GameInfoTypes[policyBranchInfo.EraPrereq]
if (iEraPrereq ~= nil and pTeam:GetCurrentEra() < iEraPrereq) then

Yeah, I had seen the if line, which is were I got the idea, but my code seems to hit a brick wall once it comes up.

I figured "local mEra = GameInfoTypes.ERA_MODERN;" doesn't work (and I hadn't seen the local line in the official lua), but if that's also using gameinfotypes, then I have no idea.

Oh well, guess I'll fool around with it some more. Thanks for your help.
 
The only way they won't be equal is if a mod has created another table that uses ERA_MODERN as a Type value with an auto-increment ID column that doesn't correspond to the expected value - see the discussion here http://forums.civfanatics.com/showthread.php?t=485884
 
Indeed, so can we agree that the 2 methods of obtaining the desired value are not as you claimed "(for all purposes) identical"? :)
 
No.

If the two values are not the same numerically, because another table has been added that changes them, for all purposes the two values are both still identical - in this case "broken"

But it's easy to heck, start up FireTuner and print the two approaches - will very quickly identify if the problem is in the mods logic or coming from another mod that has broken the values
 
Wow, talk about refusing to admit when you are wrong even to the point of contradicting yourself in the same post where you are refusing it. :p

Ie. the following will ALWAYS be false (assuming a Type named ERA_MODERN exists at all) and because of that then the 2 methods of obtaining the value cannot be said to be identical.
Code:
if ((GameInfoTypes.ERA_MODERN == GameInfo.Eras.ERA_MODERN.ID) and
	(GameInfoTypes.ERA_MODERN == GameInfo.Buildings.ERA_MODERN.ID)) then
(Only using Buildings as an example here - it could be any GameInfo Table ... or any other suspected/dileberate duplicate Type name than ERA_MODERN for that matter)


EDIT: Actually then the above check wont necessarily ALWAYS come out false. In an extreme case where the duplicate Type names also have the same ID's within their respective tables then it will ofc return TRUE.
 
Back
Top Bottom