Periodic Function

KaerfNomekop

Swim, fishies. Swim through the veil of steel.
Reaction score
613
Ok, here's a question. A theoretical function Repeater, calls itself after a 0.05 second Wait. Would this function act in the same way as a periodic trigger, or would it create an endless loop that crashes the game?
 

Ayanami

칼리
Reaction score
288
You mean like:
JASS:
function Repeat takes nothing returns nothing
    call Repeat()
endfunction

function OnInit takes nothing returns nothing
    call Repeat()
endfunction


The above would cause an infinite loop and crash the game probably.
 

luorax

Invasion in Duskwood
Reaction score
67
It'd be an infinite loop; unless you assign a check to it, so that it has an end. Just stick to a timer, propably the best approach:

JASS:
function Repeat takes nothing returns nothing
endfunction
function onInittakes nothing returns nothing
    call TimerStart(NewTimer(),.5,true,function Repeat)
endfunction
 

Dirac

22710180
Reaction score
147
It would eventually crash because none of the functions actually ends, creating an endless thread.
Do as luorax says and use timers, waits are just horrible
 
General chit-chat
Help Users

      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