Skip to main content

Setters

There are several types of "setters" we will be talking about. There are those that set variables, so vectors or switches, and there are those that set values such as the default delays and cursor position.

Setting cursor position

@cursor is a simple function that takes the (x,y) coordinates and places the cursor at those coordinates. Here's a little example where a line is drawn by holding down the mouse:

@cursor [100,100] # Default position before drawing #

|[MB_LEFT] # Hold mouse #

@cursor [200,200] # Draw #

# This draws from (100,100) to (200,200) #

Setting default delays

As discussed before there are two types of delays, which are hold, and wait. They both have their own builtin functions to set them in particular. These get used as the default delays, so they are used unless otherwise specified. For example:

@hold [5]
@wait [5]

a # Presses, holds for 5ms, releases, waits for 5ms #

Instead of this, you can also opt to go in the route of defining both in one go. You can use the @delay builtin function for this. For example:

@delay [5,5] # First one is hold, second is wait #

a # Presses, holds for 5ms, releases, waits for 5ms #

Setting variable values

There are different builtin functions for vectors and switches. As we have made clear before, modes cannot be changed and are meant to be constant, so nothing builtin can change them.

For vectors

You can use either the @setIndex or @set builtin functions to update the value of a vector. The first one changes a particular component of a vector, whereas the second one treats it as a number and only considers the first component.

These functions take the name of the vector you want to set and a value which can be a literal number or a mathematical expression (refer to the expr-eval package for more details on how it is interpreted).

The @setIndex function also takes an index of course. Here is an example of setting both with and without expressions:

<VECTORS>
$my_num = 5
$my_vector = 0,1,2,3,4,5

<MACRO>
@set [$my_num, $my_num + 5] # Sets $my_num to 10 #
@setIndex [$my_vector, 0, 5] # Sets the first component (index 0) to be 5 #

@set can also be used to create new vectors.

For switches

There's only one builtin function for setting switches, and that is @setBool, which can be used to define new switches as well. The literal booleans are TRUE and FALSE, and you can also use boolean expressions (again refer to the expr-eval package).

Here's an example of making new switches and using boolean expressions:

<SWITCHES>
$do_1
$do_2

<MACRO>
@setBool [$my_switch, FALSE] # Creates a new switch and sets it to FALSE #
# Creates a new switch and sets it to the boolean result of an expression #
@setBool [$my_other_switch, $do_1 and $do_2]