Code: Select all
-- Intercept mouse press
function widget:MousePress(x, y, button)
-- allow user to take over unit when issuing an order so unit goals don't interfere with user actions
if button == 3 then -- right mouse
Spring.Echo("Right mouse")
for _, unitID in ipairs(Spring.GetSelectedUnits()) do
if GetUnitGoal(unitID) then
Spring.Echo("Taking over unit "..unitID)
-- cancel goal
RemoveUnitGoal(unitID)
end
SetUnitFlag(unitID, "busy")
end
end
end
UPDATE: Solved using