How would I manage this.

Tyman2007

Ya Rly >.
Reaction score
74
Loops inside of vjass triggers with waits?
What I mean is with abilities such as slide, knockback, etc, they are usually just in one trigger.
For vjass, can I just use a TriggerSleepAction inside of a loop?

How do people do this stuff?

I'm a bit tired so sorry if i'm not so clear.

like a periodic even inside a trigger after the event has already happened.
 

uberfoop

~=Admiral Stukov=~
Reaction score
177
Never use TSA wait loops, they're innacurate and TSA can't go fast enough for short durations.

The most simple and versatile way that doesn't suck is arguably with use of the TimerUtils library.

Just get a new timer, load any data you need to send into the repeating function into a struct, attach struct to timer, and use a TimerStart to get going. When you're done, return the timer. Example:
JASS:

function Callback takes nothing returns nothing
local structtype structname = GetTimerData(GetExpiredTimer())
//do stuff with stuff
if SomeStopLoopConditionsOrSomething then
//clean stuff up, destroy struct, whatever
call ReleaseTimer(GetExpiredTimer())
endif
endfunction

function Actions takes nothing returns nothing
local timer t = NewTimer()
local structtype structname = structtype.create()
//load stuff into struct
call SetTimerData(t,structname)
call TimerStart(t,period,true,function Callback)
endfunction

Since TU recycles timers, there's no need to null them.

Now, TU is fantastic for random long period things. However, for many applications involving short period stuff like unit dynamic unit sliding and whatnot, struct stacks, linked lists, and systems like T32, all of those using an individual timer for all instances instead of a timer per instance, are generally the norm due to efficiency.
 

Jesus4Lyf

Good Idea™
Reaction score
397
Yeah. TimerUtils is an alternative to KT2.

I just said KT2 because it is only 2 functions to remember, KT_Add and KT_GetData (and does all the recycling and stuff in a hidden manner, and is also more efficient for the purposes in discussion - also doesn't assume timer knowledge). ;)

By all means, if you want the best for slides and knockbacks and whatnot, use T32. :thup:
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top