Page 2 of 2

Re: Noob help with lua ai

Posted: 06 Sep 2013, 04:14
by Petah
knorke wrote:There is callin:UnitIdle() --> http://springrts.com/wiki/LuaCallinReturn#Unit-Specific:
Guess that is supposed to find idle units.
Though when I tried to use it I was not sure what it considers "idle."
The calling is not really applicable, because I need the AI to also detect idle units when re-initializing, loading a save game, taking over from a player who has quit etc.

Idle in the sense that I'm using it is a unit that has no commands issued to it at present. So yea, I'll go GetUnitCommands road. Can I do:

Code: Select all

if Spring.GetUnitCommands(unitID) > 0 then...
in Lua? Or must I do something along the lines of:

Code: Select all

local count
for k,v in Spring.GetUnitCommands(unitID) do
    count++
end
spring\rts\ExternalAI\LuaAIImplHandler.cpp says:...
It would be nice if the lobby/engine actually used the mod version number instead of the string "<not-versioned>" everywhere then.

Re: Noob help with lua ai

Posted: 06 Sep 2013, 11:34
by knorke
count++
The # in my post was no typo ;)
It is to get number of things in array:
http://lua-users.org/wiki/TablesTutorial