Page 1 of 1

Cant issue patrol order

Posted: 26 Jun 2014, 19:54
by code_man
I have this simple gadged and well it the order i give doesnt get issued, tough things work fine if i issue the order by hand.

Code: Select all

function gadget:UnitFinished(unit, unit_def, team)
   if UnitDefs[unit_def].humanName == "Tiberium Refinery" then
       local x, y, z = Spring.GetUnitPosition(unit)
       local unitX = Spring.CreateUnit("harvester", x, y, z + 25, 0, team)
       Spring.GiveOrderToUnit(unitX, CMD.PATROL, {x, y, z}, {})
   end
end

Re: Cant issue patrol order

Posted: 26 Jun 2014, 22:05
by knorke
Should work like that. Possible causes:
-25 elmo distance might be too little so that lazy unit does not bother to patrol so small distance? (select it, press shift to see if it has waypoints) Put higher distance.
-unit is stuck in refinery?
-unit name in the if-condition is spelled different?
(imo it is best to always use the internal unitnames, otherwise it can get mixed up. Like here you have humanName ""Tiberium Refinery" but internal name "harvester")

Re: Cant issue patrol order

Posted: 01 Jul 2014, 14:32
by code_man
I resolved the issue, it was something with the unit being "blocked" by the building.

Now maybe i fucked something up but does spring not allow to place patrol order on the same spot as a units current postion, or something similar?