Applying one unit's command(s) to other units?

Applying one unit's command(s) to other units?

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

Moderator: Moderators

Post Reply
yanom
Posts: 323
Joined: 10 Jul 2009, 23:34

Applying one unit's command(s) to other units?

Post by yanom »

I'm currently writing an improved CarrierDrones gadget called SwarmDrones that allows for, among other things, multiple swarm types per host. I want to set it up so that orders given to the "host" unit (move here, attack this, fight, guard, etc.) are also given to all his (unselectable) drone minions. This means that, essentially, the drone's command queue should be a copy of the host's. How do I set a unit's command queue like that?
yanom
Posts: 323
Joined: 10 Jul 2009, 23:34

Re: Applying one unit's command(s) to other units?

Post by yanom »

so I'm assuming i should iterate through the host's command queue...

Code: Select all

for i,v in Spring.GetCommandQueue(hostUnitID) do
then use...

Code: Select all

Spring.GiveOrderToUnitArray(arrayOfDroneUnitIDs,v)
end
?
User avatar
Beherith
Posts: 5145
Joined: 26 Oct 2007, 16:21

Re: Applying one unit's command(s) to other units?

Post by Beherith »

yep
yanom
Posts: 323
Joined: 10 Jul 2009, 23:34

Re: Applying one unit's command(s) to other units?

Post by yanom »

Ok, cool!

But in order to prevent duplicate orders from stacking up in the drones' order queue, I'll need to wipe their order queue before copying all the orders from the host into the queue. How do I wipe a unit's order queue?
gajop
Moderator
Posts: 3051
Joined: 05 Aug 2009, 20:42

Re: Applying one unit's command(s) to other units?

Post by gajop »

yanom wrote:How do I wipe a unit's order queue?
Overwriting the command queue by giving a new order (which is done by just giving the order if shift isn't used), or by sending a stop order
Post Reply

Return to “Lua Scripts”