LUA getNumMilitaryUnits()

That is a method for a Player object. I don't know if it can be used in a map script because the map is generated before the game starts, so when it is running there would be no Players; or at least if there are Players, they wouldn't yet have any units.
 
That is a method for a Player object. I don't know if it can be used in a map script because the map is generated before the game starts, so when it is running there would be no Players; or at least if there are Players, they wouldn't yet have any units.

Yes i know that it is Player object. I think that i could use it but i need to include some additional lua file. I remember that somebody wrote that he can use KillAllUnits() or sth like that so I can use getNumMilitaryUnits() too.

I have problem with DISCARDING CityState by map engine.

Map Script: ALERT: No eligible city state sites remain. DISCARDING 11 city states. BYE BYE!

I dont know how to dectect such discarded CS, IsAlive() IsEverAlive() doesn't work becouse for civ such CS is still alive. The problem is that if such CS is included in any loop and I tray to get some information about this CS it crash the script with error:

Runtime Error: [string "Assets\Maps\nOval_mirror_v2_5.lua"]:116: attempt to index local 'plot' (a nil value)
stack traceback:
[string "Assets\Maps\nOval_mirror_v2_5.lua"]:116: in function 'getMirroredPlot'
[string "Assets\Maps\nOval_mirror_v2_5.lua"]:1795: in function 'DoMirrorPlayers'
[string "Assets\Maps\nOval_mirror_v2_5.lua"]:1883: in function 'StartPlotSystem'
[string "Assets\Gameplay\Lua\MapGenerator.lua"]:811: in function <[string "Assets\Gameplay\Lua\MapGenerator.lua"]:775>
[C]: ?
CivilopediaScreen: SetSelectedCategory

If think that I have 2 solutions:
1) check number of units, i supose that such CS doesn't have unit
2) reduce number of CS on map to avoid CS DISCARDING

I dont now how to do it.
 
maybe you can check if the CS has a starting plot... I think that checking for units will fail in the map script.
 
maybe you can check if the CS has a starting plot... I think that checking for units will fail in the map script.

What do you mean exactly? How do you want to do it?

sth like that?

function isValidPlayer(pPlayer)
return pPlayer:GetStartingPlot() ~= nil;
end

EDIT:
WOW IT WORKS THX U FOR INSPIRATION! :) THANK YOU! it was so simple :)
 
Back
Top Bottom