How to use TimerUtils?

staind25

TH.net Regular
Reaction score
7
This system was recommended to me and it's great, but I don't know JASS, so I'm struggling to get it working.

I have it implemented and everything, but I'm not sure what I need to do from here. In the comments, the author says I can use:

//* set t=NewTimer() : Get a timer (alternative to CreateTimer)
//* ReleaseTimer(t) : Relese a timer (alt to DestroyTimer)

I want to use both of these. Here's what I put in my trigger:

Trigger:
  • Then - Actions
    • Custom script: call ReleaseTimer(t)
    • Custom script: set t=NewTimer()


What am I missing? I added the 'call' to ReleaseTimer because I got a syntax error there. Now I'm getting an "undeclared variable t" error. I would've figured t would've been declared somewhere in the code for the system. What do I need to do to fix this?

Please don't skip any steps in your explanation...like I say, I don't know JASS, so I don't really know what to "assume" and what not to assume.

Thanks!
 

hgkjfhfdsj

Active Member
Reaction score
55
undeclared variable t
you need to declare a (local) variable before you can use it
[ljass]local timer t[/ljass]
locals can only be declared at the top of the function. they can be initialized.. however part of ur trigger says its creation is conditional...
anyways, mind posting your whole code? some gui actions that follow (such as pick every unit) call functions and you have to declare them in that rather than what appears to be the top of the gui actions tab.
 

staind25

TH.net Regular
Reaction score
7
Ahh, thanks for the responses. I'm actually not certain I'll end up using TimerUtils, but just in case, yes, I'll post the whole trigger for you. Just keep in mind that it probably won't make sense, because this trigger also deals with 2 other triggers (And due to if/then/else statements, it's kind of long).

Trigger:
  • Stonehearth C
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Channel
      • (Unit-type of (Target unit of ability being cast)) Equal to Stonehearth Graveyard (C)
      • ((Casting unit) belongs to an enemy of (Owner of (Target unit of ability being cast))) Equal to True
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ContestedFlagFaction[5] Equal to Alliance
        • Then - Actions
          • -------- Horde defended flag --------
          • Unit - Replace (Target unit of ability being cast) with a Stonehearth Graveyard (H) using The old unit's relative life and mana
          • Unit - Change ownership of (Last replaced unit) to Player 12 (Brown) and Change color
          • Custom script: call ReleaseTimer(t)
          • Custom script: set t=NewTimer()
          • Countdown Timer - Destroy GYTimerWindow[5]
          • Game - Display to (All players) the text: The Horde have defe...
        • Else - Actions
          • Do nothing
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ContestedFlagFaction[5] Equal to Horde
        • Then - Actions
          • -------- Alliance defended flag --------
          • Unit - Replace (Target unit of ability being cast) with a Stonehearth Graveyard (A) using The old unit's relative life and mana
          • Unit - Change ownership of (Last replaced unit) to Player 11 (Dark Green) and Change color
          • Custom script: call ReleaseTimer(t)
          • Custom script: set t=NewTimer()
          • Countdown Timer - Destroy GYTimerWindow[5]
          • Game - Display to (All players) the text: The Alliance have d...
        • Else - Actions
          • Do nothing
 
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