Removing a command from a unit's command que

Removing a command from a unit's command que

Discuss Lua based Spring scripts (LuaUI widgets, mission scripts, gaia scripts, mod-rules scripts, scripted keybindings, etc...)

Moderator: Moderators

Post Reply
EmMeister
Posts: 4
Joined: 18 Mar 2007, 07:08

Removing a command from a unit's command que

Post by EmMeister »

I am currently making my first script which would have bombers (actually units from a list) attack their assigned target once and then remove it from their command que so that they will then continue on an egress path planned presumably to avoid enemy AA.

My question is, is it possible to remove a command from a units command que or do I have to simply recreate the command que less the current command?

EmMeister
Tobi
Spring Developer
Posts: 4598
Joined: 01 Jun 2005, 11:36

Post by Tobi »

I think you need to do the last, recreate the que without the command(s) you want to delete.
trepan
Former Engine Dev
Posts: 1200
Joined: 17 Nov 2005, 00:52

Post by trepan »

But not for long ... ;)

Upcoming commit:

Code: Select all

* Added the CMD_INSERT and CMD_REMOVE commands
  (these can use the command tags, positions, and types)
To get this working, I had to add command "tags", to uniquely
identify every command that gets inserted into a unit's command
queue (or build queue or new unit command queue for factories).

CMD_INSERT
- insert by position (negative numbers to reference the back of the queue)
- insert before or after a tagged command

CMD_REMOVE
- remove all commands with a specific id (ex: remove all peewee builds)
- remove by command tag (multiple tags in a single command)
Last edited by trepan on 18 Mar 2007, 11:58, edited 2 times in total.
trepan
Former Engine Dev
Posts: 1200
Joined: 17 Nov 2005, 00:52

Post by trepan »

I forgot to mention the most of the state commands can now be
queued as well. FireState, MoveState, OnOff, Cloak, Trajectory,
Repeat, and Stockpile can be inserted into a command queue for
later execution (I haven't bothered with the others yet).
User avatar
Licho
Zero-K Developer
Posts: 3803
Joined: 19 May 2006, 19:13

Post by Licho »

Nice, that can be very usefull :)
User avatar
AF
AI Developer
Posts: 20687
Joined: 14 Sep 2004, 11:32

Post by AF »

How would a skirmish AI use these?
trepan
Former Engine Dev
Posts: 1200
Joined: 17 Nov 2005, 00:52

Post by trepan »

Subject to change:

id = CMD_INSERT
options.ALT -> treat param0 as a position instead of a tag
options.CONTROL -> use the build queue for factories
params[0] = position or command tag
params[1] = insertCmd id
params[2] = insertCmd options
params[3 ... N+2] = insertCmd params[0 ... N-1]

id = CMD_REMOVE
options.ALT -> use the parameters as commandIDs
options.CONTROL -> use the build queue for factories
params[0 ... N-1] = tags or commandIDs to remove
Last edited by trepan on 15 Aug 2007, 05:59, edited 1 time in total.
kuqa
Posts: 77
Joined: 16 Mar 2007, 23:27

Post by kuqa »

This means it could be done a such widget that allows altering command queues on-the-fly dragging ala supcom ? SWEET :)
trepan
Former Engine Dev
Posts: 1200
Joined: 17 Nov 2005, 00:52

Post by trepan »

That could already be done, this just makes it easier/cheaper.
http://spring.clan-sy.com/phpbb/viewtop ... =dragndrop
Post Reply

Return to “Lua Scripts”