• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[Solved] [Lua]Making unit go in circles

Status
Not open for further replies.
Level 8
Joined
Jun 16, 2008
Messages
333
I am trying to make units spin around their respected region in array variable form.
It is not working, can it be I just suck at coding?


Lua:
function spinTimerFunc()
    local spinTimer = CreateTimer()
    TimerStart(spinTimer, 0.03, true, spinUnit)
end

function spinUnit()
    for i=1,2 do
        SetUnitPositionLoc(udg_spininUnit[i], PolarProjectionBJ(GetRectCenter(udg_spininReg[i]), DistanceBetweenPoints(GetRectCenter(udg_spininReg[i]), GetUnitLoc(udg_spininUnit[i]), (AngleBetweenPoints(GetRectCenter(udg_spininReg[i]), GetUnitLoc(udg_spininUnit[i])) + 5))))
    end
end
 
Level 8
Joined
Jun 16, 2008
Messages
333
  • Set VariableSet spininUnit[2] = Wisp 0303 <gen>
  • Set VariableSet spininReg[1] = Region 857 <gen>
Unit is not moving at all...
that is all the code except the global variables which are set to unit and variable.

got it

Lua:
SetUnitPositionLoc(udg_spininUnit[i], PolarProjectionBJ(GetRectCenter(udg_spininReg[i]), DistanceBetweenPoints(GetRectCenter(udg_spininReg[i]), GetUnitLoc(udg_spininUnit[i])), (AngleBetweenPoints(GetRectCenter(udg_spininReg[i]), GetUnitLoc(udg_spininUnit[i])) + 5)))
 
Last edited:

Wrda

Spell Reviewer
Level 28
Joined
Nov 18, 2012
Messages
2,010
SpininUnit[1] is nil SpininReg[2] is nil.
I'm not sure what happens, but you should have put debug messages if it runs or not inside the loop.
Moreover, maybe it doesn't work because of the character limit in 1 line (around 244??), so reduce it to variables such as for x and y and see what happens.
 
Status
Not open for further replies.
Top