Jump to content
Sign in to follow this  
Kaotix

Restarting function once another function has ran.

Recommended Posts

Kaotix

I'm a noob at coding and the problem I'm having is with getting my script() function to restart every time my reward() function has finished running.

Currently my script() function only resumes after reward() has ran ( not restarting).

This causes my script() function to run incompletely if the time between when the last cycle ran was too short.

To make the script efficient, I need it to stop script() when reward() activates but then restart script() from the beginning afterwards.

Any help would be appreciated. thanks!

Global $runscript = False

AdlibRegister("reward")

While 1
Sleep(500)
If $runscript = True Then
  script()
EndIf
WEnd

Func script()
MouseClick("Left", 224, 461, 1)
MouseClick("Left", 1606, 274, 1)
MouseClick("Left", 1633, 337, 1)
MouseClick("Left", 1492, 649, 1)
MouseClick("Left", 1729, 863, 1)
Sleep(500)
MouseClick("Left", 223, 558, 1)
MouseClick("Left", 1606, 274, 1)
MouseClick("Left", 1633, 337, 1)
MouseClick("Left", 1601, 357, 1)
MouseClick("Left", 1721, 858, 1)
Sleep(500)
MouseClick("Left", 223, 658, 1)
MouseClick("Left", 1606, 274, 1)
MouseClick("Left", 1633, 337, 1)
MouseClick("Left", 1601, 357, 1)
MouseClick("Left", 1721, 858, 1)
Global $runscript = False
EndFunc   ;==>script

Func reward()
If PixelGetColor(1643, 356) = 0 Then
  $runscript = False
  MouseClick("Left", 1770, 800, 1)
  Sleep(500)
  MouseClick("Left", 1770, 800, 1)
  Sleep(500)
  MouseClick("Left", 1770, 800, 1)
  Sleep(1000)
  $runscript = True
EndIf
EndFunc   ;==>reward
Edited by Kaotix

Share this post


Link to post
Share on other sites
Guest
This topic is now closed to further replies.
Sign in to follow this  

×