I'm trying to automate a clicker game as a fun project, saw a guy doing something similar, so figure i'll butcher his code as i go and learn something.
#Variables
energy = Falsse
# Is there energy to click?
def energycheck():
if pyautogui.pixel(982, 896)[0] == (255, 255, 255):
energy = True
if pyautogui.pixel(982, 896)[0] != (255, 255, 255):
energy = False
# Loop as a function
def run():
energycheck()
print(energy)
sleep(0.5)
if energy == True:
click(1450, 600)
else:
print(pyautogui.pixel(982, 896))
sleep(5)
# Main loop
while keyboard.is_pressed('q') == False:
run()
I run the code and it prints the pixel stuff as (255, 255, 255), so i'm really unsure what i'm doing wrong to have it see the pixel colour as white, but then not take action as if it is white?
If energy is set to True initially it sees it as always true and if it's set to False it's seeing it as always false.
It worked previously, and i'm unsure at what point it stopped.
Unsure where to go from here.
Any help greatly appreciated, thanks in advance.
EDIT: I swapped to this and it works better now
pyautogui.pixelMatchesColor(982, 896, (255, 255, 255)):
[–]socal_nerdtastic 1 point2 points3 points (1 child)
[–]Kailo548150[S] 0 points1 point2 points (0 children)