I've been trying to tailor this code to work for my desktop so I can auto-farm some enemies in this game I play. Right now the code is stuck at a point where it scans the UI at a certain pixel for a certain shade of blue. if it's the correct shade, the code progresses. if not, it completely stops. I'm not sure what to do but if someone could take a look I'd greatly appreciate it. Here are some screenshots and the code:
Also, the code is broken into two pieces: the first script which allows for interaction with the game, and the second being programming automatic movement, clicking etcetera. the second piece is simple enough where it doesn't need to be put here, nor is it necessary.
First Piece (main problem is in the POSITION and COLOR part of def is_mana_low:
def is_mana_low(self):
self.set_active()
# Matches a pixel in the lower third of the mana globe
POSITION = (79, 565)
COLOR = (66, 13, 83)
THRESHOLD = 10
return not self.pixel_matches_color(POSITION, COLOR, threshold=THRESHOLD)
def use_potion_if_needed(self):
mana_low = self.is_mana_low()
health_low = self.is_health_low()
if mana_low:
print('Mana is low, using potion')
if health_low:
print('Health is low, using potion')
if mana_low or health_low:
self.click(160, 590, delay=.2)
My Discord is APieceofString#5151 if you wanted to hit me up for more information or a better explanation. I really appreciate this :)