Where you write
The My scripts tab, inside the game
Open the assistant with the Assistant button on the top bar and go to the My scripts tab. New opens a blank script, Paste from outside makes one from the text you copied, Check points at the line of an error, in words, and Run starts it. The Commands button swaps the editor for this same list, in the game's language. The rest of the assistant, from routines to macros, is in The assistant.

How it works
One command a line. # starts a comment. Texts go in quotes.
The pace is the server's: every command that sends something waits for its own turn, so no script needs pauses to stay within the rules.
Blocks
Conditions and loops
| Command | What it does |
|---|---|
if condition ... elseif condition ... else ... endif | Runs the lines inside only when the condition holds; elseif and else give other ways. |
while condition ... endwhile | Repeats the lines inside while the condition holds. |
for 10 ... endfor | Repeats the lines inside that many times. |
break, continue, stop | Break leaves the loop, continue goes back to its start, stop ends the script. |
call "another script" | Runs another of your scripts in My scripts, then comes back to the next line (up to 8 one inside the other). |
Waits
The only places a script stops
| Command | What it does |
|---|---|
pause 1000 | Waits, in milliseconds. |
waitfortarget [ms] | Until the server asks for a target. |
waitforgump [id] [ms] | Until a window of the server's opens. |
waitforjournal "text" [ms] | Until the text shows in the journal. |
waitforcliloc number [ms] | Until the server's message of that number comes. |
waituntil condition [ms] | Until the condition holds. |
With no time they wait 5000 ms (waituntil waits with no limit). After one, timedout says whether the time ran out.
Actions
What the character does
| Command | What it does |
|---|---|
say "text", emote, whisper, yell | Says the text in a normal voice, as an emote, whispering or yelling. |
sysmsg "text" | A message only you see. |
toast "text" | A notice on the screen, only for you (for what must not be missed). |
cast "Magic Arrow" | By the English name or by the name the game shows. |
useskill "Hiding" | Uses a skill, by its English name. |
useobject thing | Uses it, as a double click does. |
usetype graphic [hue] [where] | Uses the first item of that graphic in the backpack, or in the place given. |
target thing | Answers the target the server asked for with the thing. |
targettype graphic [hue] [where] | Answers the target with the first item of that graphic in the backpack, or in the place given. |
targettile x y [z] [graphic] | Answers the target with a place on the ground, by its coordinates. |
targetrelative dx dy | Answers the target with the place dx, dy steps from you. |
canceltarget | Cancels the target the server asked for. |
attack thing | Attacks the creature. |
warmode on, off or toggle | Goes into war mode, out of it, or switches. |
moveitem thing destination [amount] | Takes the item to the destination (backpack, bank, a container or ground); with no amount, the whole pile. |
movetype graphic source destination [amount] [hue] | Takes items of that graphic from the source to the destination; source ground picks from the ground up to 2 steps away, any looks in the backpack, then on the ground. |
equip thing | Wears or wields it; what was in its place goes into the backpack (record it by dragging onto the paperdoll). |
equiptype graphic [hue] [where] | Equips one of that graphic from the backpack; nothing if one is already worn. |
walk direction, run direction | North, northeast, east, southeast, south, southwest, west, northwest. |
walkto x y [z] [distance] | Walks to the place, finding the way by itself. |
walkto thing [distance] | Walks to beside something in sight. |
replygump button [id] | Presses the button of that number in the open server window (or in the one with that id). |
contextmenu thing entry | Picks an entry of the thing's context menu, by its number. |
clearjournal | Forgets what the journal has shown, so injournal sees only what comes after. |
setalias "name" [thing] | With no thing, asks you to target it. |
unsetalias "name" | Deletes a name kept with setalias. |
settimer "name" [ms] | Sets the timer of that name to zero, or to the time given. |
ignore thing, clearignore | Findtype and findmobile skip what was ignored. |
Gathering
Rock, trees, water and sand
| Command | What it does |
|---|---|
findtile "resource" [range] | Finds the nearest place with that resource (rock, trees...) that has not run out; it becomes tile. |
walkto tile [distance] | Walks to where it can be worked from. |
targettile tile | Answers the server's target with it. |
ignoretile [seconds] | The place ran out; findtile moves on to the next and comes back to it only after its rest. |
tiledistance | How many steps away it is. |
option "question" "answer" | In a routine, what was chosen on its card. |
setoption "question" "answer" | The routine changes one of its own card's answers. |
Routes
A way recorded once
A way you walk once and the assistant walks again, there and back. Kept with the character; of several with one name, the one that starts nearest counts.
| Command | What it does |
|---|---|
recordroute "name" | From here on it keeps where you walk. |
endroute [thing] | Ends and keeps the route, with the thing that stands at its end (a chest). A moongate, a teleporter or too long a way: not kept. |
walkroute "name" [back] | Walks the route to its end, or back to its start. It goes around whoever stands on the way, opens doors and waits at a shut passage before giving up. |
forgetroute "name" [range] | Forgets the route. |
findroute "name" [range] | The route exists (starting within that many tiles). |
onroute "name" [distance] | The character stands on the route or beside it (half way or at its end), within that many tiles (8); of two, the one used last. |
routedistance "name" [start] | How far its end is (or its start); 999 when there is none. |
Things
How a script points at something
self, backpack, last (the last target), lastobject, found (what findtype or findmobile found), righthand, lefthand, bank (your bank box, once opened), routeend (what was kept at the end of the route used last), a name of yours (setalias) or a serial (0x40001234). As a source, a destination and as where, ground is the ground (as a source, up to 2 steps from you). As a source, any is the backpack and then the ground. As a hue, any is any.
Reads
For if, while and waituntil
| Command | What it does |
|---|---|
hits, maxhits, diffhits, mana, maxmana, diffmana, stam, maxstam, diffstam | Life, mana and stamina: the value, the most, and how much is missing to the most. |
hitspercent, manapercent, stampercent, weightpercent | From 0 to 100. |
weight, maxweight, diffweight, str, dex, int, gold, followers | Weight, the most weight and what is left of it, strength, dexterity, intelligence, gold in the backpack and followers. |
dead, hidden, poisoned, paralyzed, mounted, war, walking, holding | True when the character is dead, hidden, poisoned, paralyzed, mounted, at war, walking or holding an item on the cursor. |
x, y, z, distance thing, distanceto x y | Where the character is, and how many steps away a thing or a place is. |
skill "Mining" | The skill's value, as in 85.3. |
findtype graphic [hue] [where] [range] | Finds an item of that graphic in the backpack, a container or on the ground (ground, up to 2 steps away or within the range given), which becomes found. |
counttype graphic [hue] [where] | How many of that graphic are in the backpack, or in the place given, counting the bags inside. |
findmobile body [range] | The nearest creature of that body (0xCF is a sheep with wool), which becomes found. |
graphic thing | An item's graphic or a creature's body; 0 when it is not in sight. |
findalias "name", amount thing | Findalias says whether the kept name points at something in sight; amount, how many units the pile holds. |
lastuse | How many ms ago you yourself used something (double click), which becomes lastobject. |
container thing | It is a chest or another container on the ground. |
targeting (or targetexists), gumpexists [id], injournal "text", incliloc number, timer "name" | The server asks for a target, a server window is open, the text or the message came up in the journal, and a timer's ms. |
They join with and, or, not and parentheses, and compare with == != < <= > >=.
Macros
Steps recorded while playing
A macro is an ordinary script of steps only, with #macro on its first line. The Macros tab shows those steps, records what you do and edits them; "Repeat" puts the steps between while 1 and endwhile. A script with conditions or loops does not become steps: edit it here.
Examples
To copy and paste with Paste from outside
while not dead
if mana >= 20
cast "Magic Arrow"
waitfortarget 3000
target self
else
useskill "Meditation"
waituntil mana >= maxmana 60000
endif
endwhile# Picks up the coins on the ground up to 2 steps away
while findtype 0x0EED any ground
moveitem found backpack
ignore found
endwhile
clearignorefindtype with ground looks on the ground, up to 2 steps away, and what it found becomes found. ignore found sets aside a coin that could not be picked up, and the loop goes on to the next.
# Uses bandages when life drops below 70%
while not dead
if hitspercent < 70 and counttype 0x0E21 > 0
usetype 0x0E21
waitfortarget 3000
target self
pause 8000
endif
pause 500
endwhileCommon questions
- Why does findtype say "unknown command"?
- Because
findtypeis a reading, not a command: it goes inside aniforwhile, as inif findtype 0x0F51. What it found is then calledfound, and a command can use it, as inmoveitem found backpack. - How do I pick an item up from the ground?
- With
findtype graphic any groundin aniforwhileand, inside it,moveitem found backpack. The coins example does this for everything up to 2 steps away. - Can I write a script outside the game?
- Yes. Write it in a text editor, copy it and use Paste from outside in the My scripts tab: the assistant makes the script from that text, and Check shows the line of any error.
- Can a script do what a hand cannot?
- No. Every command that sends something to the server waits for its turn, at the server's pace, and there is no way to send an arbitrary packet. When you paste someone else's script, the assistant reminds you to read it before you run it: it does what it says.