Page 1 of 1

Timers

Posted: Sun Jun 27, 2004 2:27 pm
by noober
Finally I found the way to use timers, thanks for the help.
Here is the working code.

Code: Select all

Sub Main
  
   /declare ThornsTimer timer Outer 0
   /Varset ThornsTimer 5s

   /declare SkinTimer timer outer 0
   /Varset SkinTimer 10s

   /declare SvDisTimer timer outer 0
   /Varset SvDisTimer 15s

   /echo Start Time = ${Time}
   :WaitForIt
        /doevents
        /delay 1s        
        /echo ${Time} 
|-----------------------------------------
| Put code here
|-----------------------------------------
        /goto :WaitForIt 
        } 
/return
/end

|Sub Event_Timer
|       /echo Casting Thorns
|       /Varset ThornsTimer 3m
|/return

Sub Event_Timer(tmrName)
   /if (${tmrName.Equal["ThornsTimer"]}) { 
      /Echo Casting Thorns 
      /Varset ThornsTimer 5s
   } 
   /if (${tmrName.Equal["SkinTimer"]}) { 
      /Echo Casting Skin 
      /Varset SkinTimer 10s
   } 
   /if (${tmrName.Equal["SvDisTimer"]}) { 
      /Echo Casting Resist Disease 
      /Varset SvDisTimer 15s
   } 
/return

Posted: Sun Jun 27, 2004 2:31 pm
by Falco72
You need to declare the timer inside your main not outside. An there are some others errors.

Code: Select all

Sub Main
   /declare MyTimer timer outer 0
   /varset MyTimer 3m | setting timer for 3 min trigger
   :loop
   /doevents
   /delay 10
   /goto :loop
/endmacro

Sub Event_Timer
   /cast 1  | Cast Gem #1 
/return

Posted: Sun Jun 27, 2004 2:33 pm
by ieatacid
Also, remove the comment after /varset MyTimer 3m. It's not setting the duration correctly with that there.

Posted: Sun Jun 27, 2004 2:35 pm
by noober
the sub should be:

Sub Event_Timer

or

Sub Event_Mytimer?

Posted: Sun Jun 27, 2004 2:50 pm
by Falco72
Event for ALL timers is

Code: Select all

Sub Event_Timer

Posted: Sun Jun 27, 2004 2:52 pm
by noober
How would you be able to tell appart 2 different timers if there is only one Sub that responds to all timers?

Posted: Sun Jun 27, 2004 2:57 pm
by Falco72

Code: Select all

Sub Event_Timer(tmrName)
   /if (${tmrName.Equal["MyTimer"]}) {
      /cast 1
   }
/return

Posted: Sun Jun 27, 2004 3:19 pm
by noober
Thank you for your help.