0

I am new to python. I am making a bot to play Realm Grinder. Right now I am using PyAutoGui to control the mouse to click on certain options. I want my looping code to stop every hour and execute a different line of code. Then I need it to return to the main code and branch off again in half an hour.

I know I can't use sleep to do it and I have considered using a variable, but I don't know how to set up numeric variables yet. The python documentation I have found is very confusing.

Right now I have:

def realmGrinder():\
     (code here)
while True:
     (code here)

realmGrinder
Fish767
  • 1
  • 7

1 Answers1

2
  1. Use asyncio.sleep(3600) to handle your delay. You'll want multithreading and the asyncio modules.
  2. Have your loop check the current time at convenient intervals, executing the other code when an hour has passed. You'll want datetime for this; if you don't mind slipping a little over an hour on each interval, then simply time.time() will do the job.
Prune
  • 76,765
  • 14
  • 60
  • 81