Skip to content

Common Library Functions

Jimb Esser edited this page Mar 10, 2015 · 1 revision

These are found in the common scripts.

Global Variables

tick_delay

The amount of time to wait between iterations in a polling loop (in ms). Default: 10

click_delay

The amount of time to wait between clicks when making many clicks at once (in ms). Default: 50

allow_pause

Whether to allow the user to pause the macro or not. Affects checkBreak(), statusScreen(), sleepWithStatus(). Set to false if your code requires delicate timing. Default: true

quit_message

Standard message to print to the user if they explicitly abort the macro.

General Functions

void askForWindow(String t)

Pause and tell the user to press shift over the target window. Should be run only once and near the beginning of the macro.

Vec2 makePoint(x, y)

Make a Vec2 (or Point) data structure from a pair of coordinates.

Box makeBox(x, y, width, height)

Make a box data structure which represents a portion of the screen.

Vec2[] findAllImages(String imgName, int tol)

Return a list of all occurrences of an image on the screen

Mouse

void safeBegin()

Performs various checks to make sure that we don't interfere with the user. This takes a small amount of additional time and should be used before performing mouse actions using the standard API.

void safeClick(x, y, rightClick)

Clicks without moving the mouse after checking to make sure we don't interfere with the user.

bool safeDrag(sourceX, sourceY, destX, destY, timeout)

Drags from source to destination after checking to make sure we don't interfere with the user. Waits until drag completes by examining the destination pixel for change. Timeout (in ms) is the maximum amount of time it will wait. Returns true on success, false on timeout.

void clickAllPoints(points, offsetX, offsetY, rightClick)

Click every point in a list in sequence adding (offsetX, offsetY) to each click position. (offsetX, offsetY) defaults to (5, 5).

int clickAllImages(image, offsetX, offsetY, rightClick, tol)

Click all matching images, but add (offsetX, offsetY) to each click position (offset defaults to 5, 5). Returns the number of clicks performed.

bool drawWater()

Attempts to draw water by first looking for a rain barrel, second trying to find an aqueduct, and third attempting to find the fill water icon. Returns true on success, false if no water source was found.

Vec2 getMousePos()

Returns the current location of the mouse.

Clone this wiki locally