So I'm taking the way of the JASS for the first time and I decided to challenge myself with some functions I plan to implement in my map. The purpouse is to declare a set of regions (rects) as "Entrances" and another set as "Exits". So when an unit enters one Entrance, it gets moved to its respective Exit.
So you have to assume Entrance[array] and Exit[array] are already established (no problem with that). I get good results without the loops (as I was testing with one single "Entrance" and "Exit"), but I thought loops would speed up the whole proccess (main reason I'm learning JASS). So with these loops, I get no starting units (dunno if related) and nothing works.
Any help is apprecciated.
JASS:
function Test takes nothing returns nothing
local unit u
local rect r
local rect rexit
local location l
local integer i = 0
set u = GetTriggerUnit()
loop
set i = i + 1
if RectContainsUnit(udg_Entrance[i], u) then
set rexit = udg_Exit[i]
set l = GetRectCenter(rexit)
call SetUnitPositionLoc(u,l)
endif
endloop
endfunction
function InitTrig_Test2 takes nothing returns nothing
local trigger t = CreateTrigger()
local integer i = 0
loop
set i = i + 1
call TriggerRegisterEnterRectSimple(t, udg_Entrance[i])
call TriggerAddAction(t, function Test)
endloop
endfunction
So you have to assume Entrance[array] and Exit[array] are already established (no problem with that). I get good results without the loops (as I was testing with one single "Entrance" and "Exit"), but I thought loops would speed up the whole proccess (main reason I'm learning JASS). So with these loops, I get no starting units (dunno if related) and nothing works.
Any help is apprecciated.