Snippet Timed Timer

Prometheus

Everything is mutable; nothing is sacred
Reaction score
590
This mini-system basically puts a life span on a repeating timer.*
Quite useful in my opinion.
Only downside is it requires HSAS.
Requires
HSAS
New Gen

How To Call
JASS:
call Timed_Timer(timer MyTimer, real LifeOfMyTimer)


Code
JASS:
library Timed requires HSAS
    //! runtextmacro HSAS_Static("Time","24570","")
    
    private struct Time
        timer T
        timer D
    endstruct
    
    private function DestTime takes nothing returns nothing
        local timer t = GetExpiredTimer()
        local Time T = GetAttachedStructTime(t)
        call DestroyTimer(t)
        call PauseTimer(T.D)
        call DestroyTimer(T.D)
    endfunction

    public function Timer takes timer t, real r returns nothing
        local Time T = Time.create()
        set T.T = CreateTimer()
        set T.D = t
        call TimerStart(T.T, r, false, function DestTime)
        call AttachStructTime(T.T, T)
    endfunction
endlibrary


Implementation Instructions
Code:
1. If you don't know wtf you're doing, download and open the test map.
2. Copy the two triggers there. You can copy them individually or copy the trigger folder.
3. Place into your map.
4. Now, any time you are using a timer you call my function (how to call it is stated above) and it gives that timer a life span.

Credits
PurgeandFire - Teaching Me How To Use Structs
Rising_Dusk - Minor Coding
emjlr3 - Ideas, Minor Coding
Uberplayer - He must of done something :rolleyes:

*Test map is a half-assed spell that uses this function.
 

Attachments

  • Blur.w3x
    26.4 KB · Views: 218
Reaction score
333
Counting the ticks. Usually there will need to be some sort of cleanup in the timer function, anyway.
 

Prometheus

Everything is mutable; nothing is sacred
Reaction score
590
Meh, I didn't want to use that and this works just fine.
 

Larcenist

REP: Respect, Envy, Prosperity?
Reaction score
211
Why is this using structs? Two timers could easily be globalized which would remove the requirement of HSAS. A lot of people seem to (for some unfathomable reason) be using ABC, so simply removing the struct would remove the need of HSAS which would remove another system-implementation which would result in easier implementation of this system.
 

Prometheus

Everything is mutable; nothing is sacred
Reaction score
590
It was originally like that but there was no way to make it 100% bug free. It could overlap and bug up easy.
 

chobibo

Level 1 Crypt Lord
Reaction score
48
Yo dude, I can't understand how to use this, can you explain more about this snippet? Thanks.
 

Prometheus

Everything is mutable; nothing is sacred
Reaction score
590
I'll add implementation instructions into the main post.
 

Sim

Forum Administrator
Staff member
Reaction score
534
:eek:

Better off counting the ticks, seriously. :p
 

Prometheus

Everything is mutable; nothing is sacred
Reaction score
590
Would you like to link me it?
I have no idea where all these systems are, Purge showed me HSAS.
 

Hatebreeder

So many apples
Reaction score
381
Hmmm... This System would be kewl, if it would be compatible with TT. Because you don't create + destroy a timer, and everything runs on one timer... Which is actually pretty kewl :3
 

chobibo

Level 1 Crypt Lord
Reaction score
48
Ok now I get what it does! :)
Hmmm... This System would be kewl, if it would be compatible with TT. Because you don't create + destroy a timer, and everything runs on one timer... Which is actually pretty kewl :3
Good suggestion!
 

Prometheus

Everything is mutable; nothing is sacred
Reaction score
590
Where is TT....


Edit:
Found, looking and will probably modify to fit this.
 
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