The issuing looks like so:
Code: Select all
Spring.SetUnitMoveGoal(unitID, cmdParams[1],cmdParams[2],cmdParams[3],64,nil,true)
This is the original ZK code + my modification for the command callins:
Code: Select all
function gadget:UnitCmdDone(unitID, unitDefID, unitTeam, cmdID, cmdTag)
if (cmdID == CMD_RAW_MOVE) then
Spring.Echo("Unit cmd done")
Spring.ClearUnitGoal(unitID)
spGiveOrderToUnit(unitID, CMD.STOP, {}, {})
else
return false
end
end
function gadget:CommandFallback(unitID, unitDefID, teamID, cmdID, cmdParams, cmdOptions) -- Only calls for custom commands
if (cmdID ~= CMD_RAW_MOVE) then
return false
end
local x, y, z = spGetUnitPosition(unitID)
local distSqr = GetDistSqr({x, y, z}, cmdParams)
if (distSqr > (64)) then
return true, false -- command was used but don't remove it(unit have not reach destination yet)
else
--spGiveOrderToUnit(unitID, CMD.STOP, {}, {})
Spring.Echo("Removing cmd..")
return true, true -- command was used, remove it (unit reached destination)
end
end
Ideas for how to stop the unit after SetUnitMoveGoal finishes?