• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[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 26
Joined
Nov 18, 2012
Messages
1,887
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