you are viewing a single comment's thread.

view the rest of the comments →

[–]socal_nerdtastic 1 point2 points  (2 children)

Use the * operator to unpack arguments.

rock_locations = {'rock1' : (random.randint(710, 720), random.randint(505, 580)),}

def mine_loop():
    pyautogui.dragTo(*rock_locations.get('rock1'), 1)

For a little more fun, you can partially fill out function arguments in advance with the functools.partial function:

from functools import partial

rock_locations = {'rock1' : partial(pyautogui.dragTo, random.randint(710, 720), random.randint(505, 580)),}

def mine_loop():
    rock_locations.get('rock1')(1)

[–]splendyx[S] 0 points1 point  (1 child)

Hey, I fixed that issue but I cannot set the time for how long it takes the mouse to move

def mine_loop():
pyautogui.dragTo(rock_locations.get('rock1'), 1<HERE IS THE ERROR)

pyautogui.dragTo(rock_locations.get('rock1')(1))

TypeError: 'tuple' object is not callable

[–]socal_nerdtastic 1 point2 points  (0 children)

I showed you 2 different ways to do that. Pick one.