[Lua] Reliable way to test what Civ a player is playing?

Irkalla

ENTP POWWWEEEEEER
Joined
Sep 25, 2012
Messages
1,009
Location
Way down around Vicksburg
What's a reliable, foolproof way to tell which civ a player is playing? For example, say I wanted to test to see if a city's owner was French Empire.

I'm thinking there's a high possibility that I can do ProjectCiv: Sparta's trait with Lua. I've worked with this in my head, and this is the method I've come up with.

Count the number of Civs bearing TRAIT_WALLS_OF_SPARTA at the beginning of the game. Make a variable (iPop_old) for each one that starts at 1. On city pop growth, test these conditions in the following order. Is the city's owner's civ's trait TRAIT_WALLS_OF_SPARTA? Is the city their capital? Is the city's current population (after growth) greater than iPop_old?

If all these conditions are true, check for another set of circumstances. I'll leave this out, but it's to check to see what their most recent unitclass is.

Once these checks have given us a unitclass, increment iPop_old to the current population, force the city to instantly produce the given unitclass (with proper XP from barracks etc.) and then end.

Is there anything wrong with that method I've come up with? The biggest thing for me is figuring out how to do all this, as it isn't readily evident.

Also, on a side note, can we make it a bannable offence to say "LUA"? Pls?
 
What's a reliable, foolproof way to tell what civ a player is playing? For example, say I wanted to test to see if a city's owner was france.

I think it should be Player:GetCivilizationType(), but I'm not sure if it's reliable, foolproof etc.

Also, on a side note, can we make it a bannable offence to say "LUA"? Pls?

I must admit I do it sometimes... I promise I won't do it again ;) Also I don't like when people write "MOD" instead of "mod", as if it was an acronym...
 
I think it should be Player:GetCivilizationType(), but I'm not sure if it's reliable, foolproof etc.



I must admit I do it sometimes... I promise I won't do it again ;) Also I don't like when people write "MOD" instead of "mod", as if it was an acronym...


How do I get the player object from the city? Also, is there a decent reference I can look at?
 
Players[pCity:GetOwner()]

(I added links to the wiki to my posts.)

Poor wiki, no love. We should see about trying to get people together to fill this thing out. Also, thanks.

Also what does the Players[] do? In the implementations of Lua I'm familiar with, that isn't a thing.
 
Also what does the Players[] do? In the implementations of Lua I'm familiar with, that isn't a thing.

It's an array containing all player objects.
 
It's an array containing all player objects.

I see. In the implementation I'm familiar with they just edited the metatables :p

How hard is it to insert your own custom keys into the array?
 
You mean adding new players to the game? It's beyond my knowledge...

No, I mean adding methods and variables to the Player object.
 
I wish I had the time to do more tutorials, but I can't even get enough to update my mods. Clearly, the guy who has decided that there will be only 24h in a day was not a modder :(

What kind of Q&A are you talking about ? Because there are a lot of questions, and answers are usually not short (see the tutorials subforum).

About the wiki it was in beta (change could be erased with new version), I don't know if we can add to it now.
 
Back
Top Bottom