Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

Pixelsearch in an area



  • Please log in to reply
19 replies to this topic
JadeDragon
  • Members
  • 935 posts
  • Last active: Jun 07 2014 07:40 AM
  • Joined: 18 Jan 2013
✓  Best Answer
;-----------------------------------------
; Subroutine to start the mana check timer
;-----------------------------------------
StartManaTimer:
ManaCheckInterval = 2000 ;<-- check mana every 2 seconds
ManaTimerIsRunning := True
Gosub ManaBarTimer ;<-- start the timer
return

;----------------------------------------
; Subroutine to stop the mana check timer
;----------------------------------------
StopManaTimer:
ManaTimerIsRunning := False
Return

;------------------------------------
; This is the actual mana check timer
;------------------------------------
ManaBarTimer ;<-- begin timer subroutine
If (!ManaTimerIsRunning) ;<-- is timer running?
   Return ;<-- if not then return

PixelGetColor, color, 206, 53, RGB ;<-- check mana bar
Sleep 200
if (color != 0x3388CC) ;<-- if color is not good
{  Send, 2 ;<-- use mana pot on key#2
}  Sleep 500

SetTimer, ManaBarTimer, -%ManaCheckInterval% ;<--reset the timer
return

Never assume evil intent when simple ignorance will suffice. Ignorance is an eventually curable condition with the right education. Evil intent, however, is another matter entirely. Scripts are much like children. Simple to conceive. Difficult, expensive, and time-consuming to raise. Often do the opposite of what you expect them to. Require frequent  "correction". And once they leave home you can't control them anymore. But you love them anyway.


hollow
  • Members
  • 125 posts
  • Last active: Dec 21 2014 09:12 AM
  • Joined: 19 May 2011

It's working nicely..I just add the shortcut just above 

!a::
WinWaitActive, game id 1
StartManaTimer:

However I don't understand here:

If (!ManaTimerIsRunning) ;<-- is timer running?
   Return ;<-- if not then return

Why can we put Return here..and what is the minus sign (-%)ManaCheckInterval% before this ?



JadeDragon
  • Members
  • 935 posts
  • Last active: Jun 07 2014 07:40 AM
  • Joined: 18 Jan 2013

if you turn the timer off before it triggers by turning off the toggle flag then when the timer runs the next time it will not reset the timer or run the entire subroutine.

 

The timer is a oneshot. It runs one time doing all its stuff and then resets itself for the next run. I do this as a matter of course when it's possible the timer period can be shorter than the the length of time it takes to run the routine. This way the timer never conflicts with itself or retriggers before it completes.it's task. It's a bit different than a free running timer. This Kind of timer can be run with a retrigger rate less than the time it takes to do it's job. An example would be a timer routine that takes 10 seconds to run but has a timer interval of only 1 second. The routine would start running, take 10 seconds to complete, retrigger itself and one second later it would run again. A free-running timer with a 1 second interval but a 10 second run time would fail under this scenario because it would retrigger itself again before it could finish  it's task. A one-shot timer avoids this problem.


Never assume evil intent when simple ignorance will suffice. Ignorance is an eventually curable condition with the right education. Evil intent, however, is another matter entirely. Scripts are much like children. Simple to conceive. Difficult, expensive, and time-consuming to raise. Often do the opposite of what you expect them to. Require frequent  "correction". And once they leave home you can't control them anymore. But you love them anyway.


Rijul Ahuja
  • Members
  • 763 posts
  • Last active: Nov 25 2013 10:16 AM
  • Joined: 14 Mar 2012

 

Run only once [v1.0.46.16+]: Specify a negative Period to indicate that the timer should run only once. For example, specifying -100 would run the timer 100 ms from now then disable the timer as though SetTimer, Label, Off had been used.

SetTimer


Abandon the forum. The community has decided in a democratic vote to leave this website because of inactive and perverse administration.

Very few of the contributing members remain here.


hollow
  • Members
  • 125 posts
  • Last active: Dec 21 2014 09:12 AM
  • Joined: 19 May 2011

Thank you JadeDragon. It took me times to read your comment..It comes to me gradually..I'll try more.