LeeS
Imperator
I need a double-check on whether my code for lua table creation is good or whether I am still misunderstanding how to create lua tables in this way. Here is the starting code for creating the lua table:
I am more concerned with whether I am doing the correct set-up for the lua table I am calling gUnitSpawns than what the current ID #'s would actually be for those units, since the game will fill in the proper ID #'s if I have my lua formats done correctly.
As an example, if a print command was run on the k,v pairs within table gUnitSpawns, where the "v" values should be the unit ID #, would I actually get a print-out that looked like this:
K V
Warrior 83
Archer 81
CompBowman 11
Crossbowman 63
MusketMan 52
Rifleman 48
GWInfantry 13
Infantry 44
MechInfantry 32
-------------------------------------------------------------------------------------------------
And am I doing this correctly so that later on I can simply do something like the following when I want to extract back out of the table the ID for a Musketman:
Or do I need to do it like this:
------------------------------------------------------------------------------------------------
I am making a mod where the spawning of units will only be effective for the human player, and regardless of what civilization they are playing as, hence the desire to pull the correct unique units.
I am thinking that use of LoadScreenClose will circumvent any mod load order issues, so that the lua will only fire after any custom-civ mods make changes to the DataBase so far as unique units are concerned.
I don't want to use <Building_FreeUnits> with a dummy building because such units are born without experience.
Code:
gUnitSpawns = {}
function SeekForUniqueUnits()
gUnitSpawns.Warrior = GameInfoTypes.UNIT_WARRIOR --default unit to spawn at game start
gUnitSpawns.Archer = GameInfoTypes.UNIT_ARCHER -- Archer
gUnitSpawns.CompBowman = GameInfoTypes.UNIT_COMPOSITE_BOWMAN -- Composite Bowman
gUnitSpawns.Crossbowman = GameInfoTypes.UNIT_CROSSBOWMAN -- Crossbowman
gUnitSpawns.MusketMan = GameInfoTypes.UNIT_MUSKETMAN -- Musketman
gUnitSpawns.Rifleman = GameInfoTypes.UNIT_RIFLEMAN -- Rifleman
gUnitSpawns.GWInfantry = GameInfoTypes.UNIT_GREAT_WAR_INFANTRY -- Great War Infantry
gUnitSpawns.Infantry = GameInfoTypes.UNIT_INFANTRY -- Infantry
gUnitSpawns.MechInfantry = GameInfoTypes.UNIT_MECHANIZED_INFANTRY -- Mech Infantry
end
Events.LoadScreenClose.Add(SeekForUniqueUnits)
I am more concerned with whether I am doing the correct set-up for the lua table I am calling gUnitSpawns than what the current ID #'s would actually be for those units, since the game will fill in the proper ID #'s if I have my lua formats done correctly.
As an example, if a print command was run on the k,v pairs within table gUnitSpawns, where the "v" values should be the unit ID #, would I actually get a print-out that looked like this:
Warrior 83
Archer 81
CompBowman 11
Crossbowman 63
MusketMan 52
Rifleman 48
GWInfantry 13
Infantry 44
MechInfantry 32
- note that the ID #'s I am showing in the table below are taken from the ModWiki page for UnitType, which I do not think (perhaps) is accurate for BNW, but I used them as an example of the type of data I believe the lua function as shown would give me.
-------------------------------------------------------------------------------------------------
And am I doing this correctly so that later on I can simply do something like the following when I want to extract back out of the table the ID for a Musketman:
Code:
iUnitToSpawn = gUnitSpawns.MusketMan
Code:
iUnitToSpawn = gUnitSpawns["MusketMan"]
- I intend to use the table to store the ID # of any unique unit a human player may be entitled to based on the civ they are playing as, so that if a human player were playing as America the lua would Spawn a Minuteman instead of a Mustketman. If they were playing as Rome, then they'd get the Musketman.
- 1st I want to make sure my table-creation method is correct, and then later I'll figure out a best-method for looking through the <Civilizations_UnitClassOverrides> table to determine whether for these units the player should get the default or the unique. I'm also using a "fill-in-a-table" method so that I only have to have the game look through the SQL/XML tables once per game session.
------------------------------------------------------------------------------------------------
I am making a mod where the spawning of units will only be effective for the human player, and regardless of what civilization they are playing as, hence the desire to pull the correct unique units.
I am thinking that use of LoadScreenClose will circumvent any mod load order issues, so that the lua will only fire after any custom-civ mods make changes to the DataBase so far as unique units are concerned.
I don't want to use <Building_FreeUnits> with a dummy building because such units are born without experience.