Noob help with lua ai - Page 2

Noob help with lua ai

Here is where ideas can be collected for the skirmish AI in development

Moderators: hoijui, Moderators

User avatar
Petah
Posts: 426
Joined: 13 Jan 2008, 19:40

Re: Noob help with lua ai

Post 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.
User avatar
knorke
Posts: 7971
Joined: 22 Feb 2006, 01:02

Re: Noob help with lua ai

Post 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
Post Reply

Return to “AI”