Only one catch, though- they don't inherit the move orders of their parent properly. I keep trying various approaches, and Spring keeps telling me that I'm supplying a bad unitID, or a bad commandID. I've tried echo, to determine what's wrong, and I don't see anything wrong- so it must be something else I'm doing wrong.
Here's the code I'm using:
Code: Select all
function BuildClone(u, ud, team)
local x, y, z
x, y, z = Spring.GetUnitPosition(u)
local MyCommandQueue
MyCommandQueue = Spring.GetUnitCommands(u)
MyCommandQueue = table.remove (MyCommandQueue, 1)
Spring.Echo(MyCommandQueue)
local one
AllowUnsafeChanges("USE AT YOUR OWN PERIL")
one = Spring.CreateUnit("LightMech_Spawn", x - 16,y,z, 0, team)
Spring.Echo(one)
Spring.GiveOrderToUnit(one,MyCommandQueue)
AllowUnsafeChanges("thanks")
end