- Joined
- Aug 9, 2015
- Messages
- 34
Hi,
I have been struggling with the following code:
In the current state the timer runs only once each time a unit is moved. Only a part of the script is shown, I believe the cause is related with me coding the timer wrong.
May I ask for help?
I have been struggling with the following code:
Lua:
...
local shipsmoving = CreateGroup()
...
function naval_movement_start()
TimerStart(CreateTimer(), 0.1, true, ForGroupBJ(shipsmoving, function()
local u = GetEnumUnit()
naval_movement_accelerate(u)
naval_movement(u)
end))
end
function naval_movement_order()
local u = GetTriggerUnit()
GroupAddUnitSimple(u, shipsmoving)
naval_movement_start()
end
function naval_movement(u)
local cv = GetUnitUserData(u)
SetUnitPositionLoc(u, PolarProjectionBJ(GetUnitLoc(u), RVM.actualspeed[cv], GetUnitFacing(u)))
print("dog1")
end
function naval_movement_accelerate(u)
local cv = GetUnitUserData(u)
if RVM.actualspeed[cv] ~= RVM.maxspeed[cv] then
RVM.actualspeed[cv] = RVM.actualspeed[cv] + RVM.acceleration[cv]
end
end
OnMapInit(function ()
local trig = CreateTrigger()
TriggerRegisterAnyUnitEventBJ(trig, EVENT_PLAYER_UNIT_ISSUED_POINT_ORDER)
TriggerAddAction(trig, naval_movement_order)
end)
...
In the current state the timer runs only once each time a unit is moved. Only a part of the script is shown, I believe the cause is related with me coding the timer wrong.
May I ask for help?