[InWork] Timed Timer

Status
Not open for further replies.

Prometheus

Everything is mutable; nothing is sacred
Reaction score
589
I know the title sounds retarded, but this is basically putting a time limit on a looping timer. There's a little nagging voice in the back of my head that says "This is missing something" or "This could be done better." Comments?
<3
JASS:
library Timed
    globals
        private timer array T
        private timer array D
        private gamecache GC
    endglobals

    private function DestTime takes nothing returns nothing
        call DestroyTimer(D[GetStoredInteger(GC, R2S(TimerGetTimeout(GetExpiredTimer())), &quot;Timed_Timer&quot;)])
    endfunction

    public function Timer takes timer t, real r, integer i returns nothing
        call FlushGameCache(InitGameCache(&quot;Timed.x&quot;))
        call InitGameCache(&quot;Timed.x&quot;)
        set T<i> = CreateTimer()
        set D<i> = t
        call TimerStart(T<i>, r, false, function DestTime)
        call StoreInteger(GC, R2S(TimerGetTimeout(T<i>)), &quot;Timed_Timer&quot;, i)
    endfunction
endlibrary
</i></i></i></i>


I know there's CSSafety/CSData or structs and structs are better but I don't know how to use structs. CSSafety/CSData would require more coding then needed then if there was structs. Suggestions?
 
Reaction score
456
Library name should be snippet/system name.

I have no idea what you're going to do with array variable R.
 

Prometheus

Everything is mutable; nothing is sacred
Reaction score
589
Oh, yea, forgot to remove that.
:D
But called TimedTimer_Timer just sounds stupid.
 

Prometheus

Everything is mutable; nothing is sacred
Reaction score
589
Hell, I already refined this with Purge's help, now it uses CSAS and structs.
Check it out in the submission section.
 
Reaction score
456
> Since when is OK to destroy timers?
Since always, but they should paused before destroying. Or even better if you use the one simple library Vexorian wrote. Can't remember the name. But it has the functions NewTimer() and ReleaseTimer().

This is, by the way, the current version.
 

Prometheus

Everything is mutable; nothing is sacred
Reaction score
589
Thread locked after System (Snippit) being owned by Cohadar.
:(
 
Status
Not open for further replies.
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