Retrieve an Array Integer

Trollvottel

never aging title
Reaction score
262
? Expired timers dont have array-values. Could you describe your problem a bit more understandable?
 

eskimojoe_66

Member
Reaction score
2
yeah sorry :D
anyway, i am using JASS (I cannot use vJASS) to create a spell that creates a projectile and move it towards an angle. For this, i use a timer which repeats and triggers another function every 0.01 seconds. I use udg array variables (1 - 12, 1 for each player), and i was wondering how i could retrieve the correct PlayerId as it is a different function. Is there any way in which i can give the timer a global array value and retrieve that value in that function so that I can also retrieve various globals? I was hoping that there was a way to do this..
 

uberfoop

~=Admiral Stukov=~
Reaction score
177
Initialize your timers at map init with this:
JASS:

function TimerInit takes nothing returns nothing
local integer i=1
set <some global timer array>[0]=CreateTimer()
set <some global integer>=H2I(<some global timer array>[0])-1
loop
exitwhen i>(number of timers to be put into array)
set &lt;some global timer array&gt;<i>=CreateTimer()
set i=i+1
endloop
endfunction
</i>


I decided to use a variable offset just incase you initialize a LOT of handles at init in your map for some reason. Anyway, get the value of a timer via this:

JASS:

function T2I takes timer t returns integer
return H2I(t) - &lt;the global integer variable used in above function&gt;
endfunction


//======================================

Alternatively, you can use Rising Dusk's timer system for epic full MUI action:
JASS:

globals
timer array ax
integer Vx
integer nx
endglobals

function DH2I takes handle h returns integer
return h
return 0
endfunction

function TimerInitialization takes nothing returns nothing
local integer i=1
set udg_ax[0]=CreateTimer()
set udg_Vx=DH2I(udg_ax[0])-1
loop
exitwhen i&gt;512
set udg_ax<i>=CreateTimer()
set i=i+1
endloop
set udg_nx=513
endfunction

function GetTimer takes nothing returns timer
if udg_nx==0 then
call BJDebugMsg(&quot;ERROR: The timer stack has run out of timers&quot;)
return null
endif
set udg_nx=udg_nx-1
return udg_ax[udg_nx]
endfunction

function FreeTimer takes timer t returns nothing
if t!=null then
call PauseTimer(t)
set udg_ax[udg_nx]=t
set udg_nx=udg_nx+1
endif
endfunction

function T2I takes timer t returns integer
return DH2I(t)-udg_Vx
endfunction
</i>
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top