-
Notifications
You must be signed in to change notification settings - Fork 75
Purpose and Definition of Functions including argument s usage
image_Rec_clicker & Image_Rec_single(image, event, iheight, iwidth, threshold, clicker, ispace=20, cropx=0, cropy=0, playarea=True)
Image_Rec_clicker finds all instances of the image for template matching and clicks on them.
Image_Rec_single only find the first instance of the image for template matching and clicks on it.
image = A string value that is the name of the image file in single quotations (include the file type extension) e.g 'prawn_fish.png'.
event = A string value that is a short description of what the function is doing for a particular purpose e.g 'picking a fishing spot'.
iheight = An integer that is the amount of pixels to pad from the y plane starting at the centre e.g 20
iwidth = An integer that is the amount of pixels to pad from the x plane to the centre e.g 20
Threshold = a float number representing a percentage of how much the image should match within the screenshot. Usually 0.7 is a relative good match while accounting for changes in contrast and noise.
Clicker = string indicator for determine which button from the mouse should be clicked 'left' , 'middle' or 'right'.
Cropx = if the image is cropped how much was cropped from the left X plane of the screenshot in pixel length.
Playarea = Boolean value to determine if by default the play area is the area to take the screenshot for or False if a custom cropped screenshot is used (use Cropx and Cropy)
Cropx = if the image is cropped how much was cropped from the top Y plane of the screenshot in pixel length.
Returns a screenshot cropped to only display the inventory space. Uses screen_Image(620, 480, 820, 750, 'inventshot.png') 620 pixels from the left, 480 pixels from the top, 200 pixels wide and 270 pixels in height. Saves the cropped screenshot as 'inventshot.png' and saves to the main project.
Uses the global break to determine when to trigger the function which occurs between 300 and 2000 seconds, and may occur if it is chosen to be triggered out of the other 4 random functions also referenced.
At the end of the function it sets the global variable global_break to True which triggers the randomizer to reset and start again.
Function to randomly open the inventory tab using the F4 key.
Function to randomly open the combat style tab using the F1 key.
Function to randomly open the combat style tab using the F2 key.
Function to randomly open the combat style tab using the F3 key.
Used to resize the cropped screenshot of the top left corner where text actions are displayed for attacking, mining, woodcutting, fishing, cooking etc. Doubles the size so the Image_to_text function can read the text easier.
Preprocess is what preprocessing method will be applied to the image, 'thresh', 'adaptive' or 'blur'.
Image is the name of the image file to apply image to text recognition to.
checks to see if we should apply preprocessing to the image by default thresholding preprocessing is applied.
writes the grayscale image to disk as a temporary file.
loads the image as a PIL/Pillow image, applies the image to text recognition using tesseract-OCR, and then deletes the temp file.
returns the result
It sets the variable banker to the value 50. It generates a random floating-point number between 0.1 and 0.77 and assigns it to the variable b. It generates two random integers: x using random.randrange(480, 500) and y using random.randrange(626, 647). These random values determine the coordinates on the screen where the mouse cursor will move. It moves the mouse cursor to the coordinates (x, y) using pyautogui.moveTo(x, y, duration=b). The duration parameter specifies the time it takes to move the cursor to the new position. It generates another random floating-point number between 0.01 and 0.1 and assigns it to the variable b. It clicks the mouse at the coordinates (x, y) using pyautogui.click(x, y, duration=b, button='left'). The duration parameter specifies the time it takes for the mouse click to be registered. The button parameter specifies the button used for the click (in this case, the left button). It generates a random floating-point number between 0.1 and 4.5 and assigns it to the variable c. It pauses the execution of the program for c seconds using time.sleep(c). This introduces a delay before further actions can be taken.
Overall, this code snippet automate the process of depositing items or resources into a bank in the RuneScape game. It moves the mouse cursor to a specific location, clicks the mouse, and then introduces a delay before continuing with other actions.