The tools
Thirty-five calls do the member's work. Each is already inside your script.
farm_map
How to write it: farm_map('map name'), or with named settings: farm_map('map name', priority=..., flee=..., escape_map=..., recheck_min=..., city=..., hours=...).
What it does: farms a map. For one of the twenty-three tuned maps (the Farming Slave maps) it runs that map's own table: the same doors, patrol and shops the bot itself farms it with. For any other map with wall data (the bot's own map knowledge; 374 maps have it) it builds a generic patrol on the spot. It travels there, turns on healing, repair, pet care, death recovery and chest opening, farms, and walks to a city for a shopping trip whenever supplies run low. If your character dies, the bot brings it back, shops, and walks it back to the map by itself.
priority is a list of monsters to hunt first, like priority=['great ape']. Nothing to do with bosses: wherever the hunt stands, a monster whose name is on the list is preferred over anything else in sight, on any map. Your list rides your own hunt-first setting for the length of the run and gives it back afterwards. A map may keep a default of its own -- big eucalyptus carries the great ape -- and the dialog's box carries that default; what you leave in the box is the list, and an emptied box means no priority at all. A boss you flee is never on this list.
flee is a list of bosses to run from, like flee=['Monkey King Wukong']. A boss on the list is always fled, never fought: the moment the bot sees him, the run leaves for the escape map and farms there until a broadcast names him dead, then it comes back and farms your map again. This works on every map, with any pair of maps, in any script. escape_map says where to go — any map the bot can travel to. Without it, the map's own escape is used when it has one (big eucalyptus hides in Great Eucalyptus House, turkey mountain in turkey cave, blood red castle in Blood Wasteland); with neither, the bot says so once, out loud, and keeps farming the map you chose. recheck_min is how many minutes to wait on the escape map before going back to look — 0 never goes to look at all: only the death broadcast (or the hours deadline) brings the run home; 0 is the default, and any number above 0 is a timed look you ask for.
No dying message is needed: the game's own broadcast that carries the boss's name is what the bot listens for.
city names the city to shop in; without it the map's own hub city is used. On one of the twenty-three tuned maps, naming a city makes the bot use the generic patrol instead of that map's table; leave city out to keep the table. hours stops the farm after that long and the call returns, so your script can continue with something else; it takes decimals (hours=3.5), and it works together with a flee — the deadline ends the run on whichever of the two maps it is farming. It works on every farm, tuned map or not.
The old boss= and exile= settings still work, quietly: boss=X means flee=[X], and exile=True means "use the map's own escape map" — and the old positional order (map, boss, city, exile, hours) still means what it always did. The names above say it better.
About 105 maps can be reached on foot; if yours cannot, travel refuses out loud and says so, instead of walking your character into a wall forever.
Examples:
# Hunt the great apes, run from the boss, stop after six hours:
farm_map('big eucalyptus',
priority=['great ape'],
flee=['Monkey King Wukong'],
escape_map='Great Eucalyptus House',
hours=6)
# Any other map: your boss, your escape, your clock:
farm_map('wolf prairie',
flee=['Man-wolf Caesar'],
escape_map='Takama Desert',
recheck_min=30,
hours=4)
Stop conditions: kills, level, bag_full, public_left, until
How to write it: farm_map('wolf prairie', kills=500, bag_full=True).
What it does: kills, level, bag_full, public_left and until are stop conditions for farm_map. The first one that is met ends the farm and makes the call return, so your script can do something else next.
kills=500 stops after 500 kills, counted from the start of this call.level=80 stops when your character reaches level 80. The game does not tell the bot when you level up, so the bot learns your level from the character panel: at the start, on every shopping trip and, when no monster is near, once every few minutes at the pause between two legs of the patrol. It never opens the panel in the middle of a fight, because an open menu stops the fight. A level-up is therefore noticed within a few minutes, not at the moment it happens, and while monsters stay close it can take longer. If the level cannot be read, the farm simply goes on.bag_full=True returns when the bag is full and the bot cannot make room in it. Without it, the bot ends the run by itself: it sells, rides home and stops your script. With it, the call returns and your script decides what comes next.public_left='0h20m' stops when the public-area drop time left is that or less ('1h', '30m' and 0.5 are understood too). It uses the bot's own count, and only while the character panel was read lately. The public-time floor in your profile still applies on top: if it is higher, the bot ends the run by itself first.until=my_check is a function of yours that takes nothing and answers True or False. The bot calls it about once a second while it farms; keep it quick and press no keys in it. If it raises an error, the answer counts as False.
Worth knowing: a value the bot cannot understand (kills='lots') is said aloud and nothing is started. When you give any of these, or hours, farm_map returns a result: a dictionary with reason ('hours', 'kills', 'level', 'bag_full', 'public_time', 'until', or 'ended' when the farm returned for another reason, which the log names), kills, minutes, level (None when unknown) and detail. With none of them, farm_map returns what it always returned.
Example:
r = farm_map('wolf prairie', kills=500, bag_full=True)
speak('Stopped: ' + r['reason'])
restock_from()
restock_from
How to write it: restock_from(), or restock_from(city='Tulip City', fill=True).
What it does: one shopping trip, now. Walks to the city, buys the potions your profile uses, and stays in the city: call go_to('map name') afterwards to return. With no city named, it shops in the city you stand in, or the nearest known one on your map. fill=True fills every potion to its maximum instead of the minimum a farm needs; that is what you want before a long night.
Worth knowing: the city must be a city the bot knows, by its real name, in English. The eight it knows are Tulip City, holy blood city, Giant Rock City, White Sand City, Moon City, Violet City, dark night City and Sunset City. Spelling is forgiving about capitals ("tulip city" works as well as "Tulip City") and a part of a city's name is enough ("tulip" finds Tulip City). The name of a city's hub map also takes you to that city, so go_to('Tuneful Wetland') ends in the city, not on the map in general. The name must still be one of the eight. A name the bot does not know is said aloud and nothing is bought; the call returns and your script goes on. When in doubt, ask cities_like (below) what exists before you shop in it.
Coming back: come_back=True walks you back, after the shopping, to the map and the exact tile you stood on when you called; the answer is True only when the shopping and the walk back both worked. It refuses, out loud, and goes nowhere when a fight is on, when a death recovery is running, when you are inside a timed dungeon (leaving it would lose it), or when no road leads back. If a boss you flee from is still up on your map, you are brought to the map you flee to, not onto him. scan=True reads the bag first and binds the potion keys, as the first fill of a run does.
Example:
farm_map('wolf prairie', hours=3)
restock_from('Giant Rock City', fill=True, come_back=True)
farm_map('wolf prairie', hours=3)
bag_count
How to write it: bag_count('item name'), or bag_count('hp') for a supply slot.
What it does: tells you how many of an item are in the bag, right now, out loud, and returns the number to your script. It reads the bag from the game's memory, so it costs no walking and no keys, and it is safe to ask in the middle of a fight. An item the bag holds answers "I have 12 Silk Thread."; an item it does not hold answers "I have 0 ..."; a bag that cannot be read this moment answers "I cannot read the bag right now." and returns -1. A zero and a cannot-read are never mixed up, so your script can shop on a zero without fear.
Worth knowing: the name must match the item's name; capitals do not matter ("silk thread" finds Silk Thread). Piles split across bag slots are added together, bound (restricted), locked and free piles alike. The six supply slots answer by their slot name too: hp, mp, pet_hp and pet_mp say your four potions by their configured names, rice_roll and repair say the pet food and the repair tool. The bot also watches these supplies by itself: when one of them falls from some to none, it says so once, refreshes its own counts, and books the shopping it needs -- no script code required.
To hear nothing, write bag_count('hp', say=False): the bag is read the same way, the number comes back, and no sentence is said.
Example:
left = bag_count('hp')
if left == 0:
restock_from()
bag_items
How to write it: bag_items().
What it does: returns everything in the bag as a dictionary, each item's name and how many of it you carry: {'Large Red Potion': 300, 'Silk Thread': 7}. Piles of the same name are added together, restricted (bound), locked and free ones alike, the way bag_count adds them. It reads the game's memory: no walking, no keys, nothing spoken, and it is safe in the middle of a fight.
Worth knowing: when the bag cannot be read this moment it returns None, never an empty dictionary, so None means "I could not tell", not "the bag is empty". The names are the ones your game shows.
Example:
bag = bag_items()
if bag is not None and bag.get('Silk Thread', 0) >= 50:
speak('Enough silk thread.')
bag_load
How to write it: bag_load(), or bag_load(fresh=True).
What it does: tells you how full the bag is, as three numbers: what you carry, the most the bag holds, and the percent full, for example (3000, 4000, 75). It says nothing and presses no key: it is the load the bot last noted, from the game's own load line and from the character panel the bot reads on its trips and while a farm runs. It returns None when the bot has not seen the load in this run, or last saw it more than half an hour ago; None means "I do not know", never an empty bag.
Worth knowing: bag_load(fresh=True) opens the character panel and reads the load now, which takes about a second and one key press. It does that only when the character is quiet: with a fight on, a monster within six tiles, or a death recovery running, it presses nothing and answers from the last note, as bag_load() does. A panel that gives no load does the same.
Example:
load = bag_load()
if load is not None and load[2] >= 90:
sell_shards()
supplies_low
How to write it: supplies_low().
What it does: lists the supplies that are short right now, by slot name: hp, mp, pet_hp, pet_mp, rice_roll and repair (your four potions, the pet's food and the repair tool). A supply is short exactly when the bot's own restock would shop for it: shopping for it is on in Settings, the count is under its minimum (at the minimum is not under), and a pet's supplies count only when you have a pet. It reads the bag from the game's memory: no keys, nothing spoken, safe in a fight.
Worth knowing: an empty list [] means nothing is short. None means the bag could not be read this moment; do not treat it as "nothing is short".
Example:
short = supplies_low()
if short:
restock_from()
last_sale
How to write it: last_sale().
What it does: tells what the latest shard sale of this run did, as a dictionary: kinds (how many kinds of shard it sold), units (how many shards), income (the arnebia the broker paid for that sale) and sales (how many sales it took), plus run_income and run_sales, everything the broker has paid this run so far. It answers None when no sale has finished yet in this run. A sale that sold nothing is reported with zeros. Ask it right after sell_shards(); it only reads the bot's own books.
Worth knowing: sell_shards() keeps a gap so a loop cannot hammer the broker: a second call within sixty seconds of a sale that sold waits out the rest of the minute (it says so aloud), or answers False at once when the game's memory shows no shards in the bag. sell_shards(say_bag=True) also says how full the bag is after a sale.
Example:
sell_shards()
sale = last_sale()
speak('Earned ' + str(sale['income']) if sale else 'No sale yet')
combat_events
How to write it: combat_events(), or combat_events(20), or combat_events(50, 'dealt').
What it does: returns the last fights' events, oldest first, as a list your script can read: every damage number you dealt, every drop in your own health, every dodge, and one "fight" and one "kill" line per fight. The bot keeps the last 500. Each event says its kind, its amount, how it was learned (path: the game's speech, the game's memory, or the experimental combat tap) and when. It costs nothing and presses nothing. It returns an empty list when nothing has happened yet; it never fails.
Worth knowing: the kinds are dealt, taken, heal, dodge (you dodged), miss (the target dodged you), own_cast, fight and kill. The numbers the bot learns from speech are only as complete as the game's speech: with the in-game helper 2.15.0 or newer the bot also reads the game's casts, which is exact but not yet tested on a live game.
Example:
for e in combat_events(10, 'kill'):
print(e['species'], e['amount'])
nearby_players
How to write it: nearby_players(), or nearby_players(names=True).
What it does: returns the other players near your character, nearest first, as a list. Each one is a small record with class (warrior, orc, assassin, hunter, mage, elf, priest or sorcerer), colour ("red", "black" or "yellow" for a flagged name, an empty text for an ordinary one), distance in tiles, has_gang and has_team. It reads the game's memory, so it costs no walking and no keys, and it says nothing out loud.
Worth knowing: it lists players within 40 tiles, and your own team mates are not in it. The colour is None when the game helper is older than 2.15.1 and cannot send it. A player's name is never in the record, even when you pass names=True: names are never handed to a script. An empty list means nobody is near, or the picture of the world could not be read this moment.
Example:
for p in nearby_players():
if p['colour'] == 'red' and p['distance'] < 20:
speak('A red-named ' + p['class'] + ' is close.')
nearby_monsters
How to write it: nearby_monsters(), or nearby_monsters(30), or nearby_monsters(40, name='Monkey King Wukong').
What it does: returns the monsters near your character, nearest first, as a list. Each one is a small record with name (the monster's English name, the way the game's memory holds it), distance in tiles, hp_percent (a whole percent of its full health) and is_boss. The number is the radius in tiles (40 if you leave it out); name= keeps only that monster, and takes one name or a list of names, in any case. It reads the game's memory, so it costs no walking and no keys, and it says nothing out loud.
Worth knowing: bosses are listed too, so you can see one before it sees you. is_boss is True only for a boss the bot is watching for right now (the names you gave farm_map(flee=...)); every other monster, an unwatched boss included, says False. hp_percent is None when the in-game helper is older than 2.13.0 and cannot send the full health. The snapshot carries no monster level, so there is none in the record. Players, pets, NPCs, traps, summoned totems and the dead are not in the list. An empty list means no monster is near, or the picture of the world could not be read this moment.
Example:
if nearby_monsters(30, name='Monkey King Wukong'):
go_to('Great Eucalyptus House')
for m in nearby_monsters(10):
speak(m['name'] + ' at ' + str(m['distance']) + ' tiles')
read_menu
How to write it: read_menu().
What it does: returns the menu that is open in the game right now as a small record, or None when no menu is open. The record has title, rows (the lines of the menu as the game says them, in order), cursor (the number of the row the cursor is on, counting from 0), depth (how many menus are open on top of each other; the record describes the top one) and id, kind and flags, the menu's own numbers, which are the same in every language. It reads the game's memory: no key, no sound.
Worth knowing: id, kind and flags are None when the game helper is older than 2.15.0. None can also mean the helper is too old to read menus at all; world_context()['helper_version'] says which helper you have. The rows are in the language of your game. raw_title and raw_rows are the same lines in English whatever language your game speaks (what the game keeps in memory before it translates), so one script reads the same words on every client; they are None when the game helper is older than 2.15.2.
Example:
menu = read_menu()
if menu is not None:
speak(menu['title'] + ', ' + str(len(menu['rows'])) + ' rows')
choose_row
How to write it: choose_row('Sell'), or choose_row(2).
What it does: chooses one row of the open menu. Give the row's text (the whole text, or a part of it that only one row has; capitals do not matter) or its number (0 is the first row of the rows list that read_menu() gives). It returns True when the row was chosen. It returns False when it was not, and then nothing was pressed and the reason is in the log. It takes the road the bot's own shops and NPCs take: it reads the menu from memory, moves the cursor to the row by counted taps, proves with two agreeing reads that the cursor is on it, and only then chooses it, by the game's own Enter handler when the game helper can (no key at all) and by the Enter key when it cannot.
Worth knowing: some rows are never chosen, and nothing in a script can switch that off: rows that delete, create, quit, register, change the language or the server, switch the account, say Exit, or open a text box or a web address. (A row such as "Create a team" is therefore not for choose_row; use menu_search.) If two rows read the same, asking by text is refused; ask by number, and the call still refuses when the cursor cannot be proved on the right one. True means the row was chosen, not that the server liked it: look at read_menu() or world_context() afterwards. On a game in another language, use the menu's own words, the English words of raw_rows, or the number. It needs a game helper that can read menus; without one it returns False.
Example:
if read_menu() is not None:
if choose_row('Sell'):
speak('Sell chosen.')
world_context
How to write it: world_context().
What it does: one call that returns what the game's memory knows right now, as a record: in_world, map_id, map_name, x and y (the tile), hp and maxhp, mounted (the speed fusion beast is on), pet_out, target_id and target_name, monsters_15 and monsters_40 (monsters within 15 and 40 tiles), players_15 and players_40 (other players within 15 and 40 tiles), flagged_player_distance, menu_open, helper_version, public_time_left_sec, level and exp_needed. It uses the readings the bot already takes: no key, no walking, nothing said out loud.
Worth knowing: a value that cannot be known right now is None, and the call never fails, so check for None before you compare. target_id and target_name are None when nothing is targeted. Your own team mates are not counted as players. flagged_player_distance is the distance in tiles to the nearest red- or black-named player within 40 tiles; it is None when there is none, or when the game helper is older than 2.15.1 and cannot send name colours. public_time_left_sec is the bot's own estimate of the public area's drop time left, and is None until the character panel has been read in this run. level and exp_needed (the character's level and the experience still needed for the next one) come from that same panel read, in any game language, and are None until it has been read.
Example:
ctx = world_context()
if ctx['in_world'] and ctx['monsters_15'] == 0:
speak('Nothing near.')
press_verified
How to write it: press_verified('j'), or press_verified('lctrl+j').
What it does: presses a game key the way keypress does, and tells you whether the game took it. It returns True only when the game's own key handler took the key and memory agrees: if a menu is open, the game's queue of waiting keys is empty; if none is open, the game's list of held keys does not still show the key. It returns False otherwise.
Worth knowing: True means the game received the key, not what the key did; movement, menus and the map can be checked afterwards with world_context() and read_menu(). False also covers a key name the bot does not know, a press the bot held back (for example while you hold a real Ctrl or Alt, or while a menu nobody opened is up), a game helper that is missing or too old to confirm, and a key the game does not bind (typed text goes to a text box instead). keypress itself is unchanged.
Example:
if read_menu() is not None:
closed = press_verified('esc')
if closed and read_menu() is None:
speak('The menu is closed.')
else:
speak('The menu is still open.')
battle_reports
How to write it: battle_reports(), or battle_reports(3), or battle_reports(1, players=True).
What it does: returns the newest battle reports the game holds, newest first, as a list of records. Each has kind, names (the team names the report carries), created, index, side1 and side2 (with crystal_towers, defense_towers, kills and monster_kills; side2 is missing in a team report). With players=True each report also has players1 and players2: per player id, name, monster_kills, damage, healing and more (30 rows a side at most). It reads the game's memory: no key, no sound.
Worth knowing: an empty list means the game holds no report; None means the reports could not be read (no game, or a game helper older than 2.14.1). The game writes a report when an arena or a battlefield ends; no report has been read on a live game yet, and the meaning of the fields follows the game's code, so treat the figures as unconfirmed. At the end of every dungeon the bot itself writes one line to the log, "dungeon result: ...", with the summary of a report the game wrote for it, or the words that the game wrote none; it changes nothing in the run.
Example:
reports = battle_reports(1)
if reports:
print(reports[0]['kind'], reports[0]['side1']['monster_kills'])
map_advice
How to write it: map_advice(), or map_advice(64).
What it does: returns the Farming Slave maps for a level, best first, ranked by the game's own rules from its help files, as a list of records with map, levels (the monster levels of the map), xp (the experience multiplier; 1.0 is the standard) and drops (the loot chance in percent on a public map). Without a level it uses the one the bot already knows from the game's info line, and returns an empty list when it knows none.
Worth knowing: the rules are the help files'. A monster above your level gives up to 120 percent of the standard experience (from 5 levels above), and every level below takes 4 percent off, down to nothing at 25 below. The loot chance on a public map is 100 percent down to 9 levels below you, 50 percent for 10 to 19 below, 25 percent for 20 to 29 below and none for 30 or more. The help files state the monster levels of only some of the maps, so only those are ranked (the others are left out, no number is guessed), and a map whose weakest monster is more than 5 levels above you is not listed. The ranking is the experience multiplier times the loot chance. This is advice only: nothing changes the map a run farms. When a Farming Slave run starts on a map that is not among the best three for the character's level, the bot writes one line to the log, "map advice for level N: ...".
Example:
best = map_advice(64)
if best:
speak('Best map: ' + best[0]['map'])
kills
How to write it: kills().
What it does: returns how many kills this run has made, as a whole number. It is the bot's own count of confirmed kills, the number the status key speaks; a monster that merely disappeared is not counted. It is 0 before the first kill and outside a run. It costs nothing and presses nothing.
Example:
if kills() >= 500:
speak('Five hundred kills so far.')
farm_stats
How to write it: farm_stats().
What it does: returns the run's numbers as a dictionary: kills; kills_per_hour (over the time you really farmed: trips, pauses, shopping, deaths and disconnects are not counted); recent_kills_per_hour (the last ten minutes); minutes_farming; deaths; restocks (shopping trips); repairs; chests opened; gold picked up; and sale_income, the arnebia the shard sales paid. It reads what the bot already keeps for the status key, so nothing is pressed or spoken, and every run starts again from zero.
Worth knowing: it returns None when no run is being counted, never a dictionary of zeros.
Example:
stats = farm_stats()
if stats is not None and stats['minutes_farming'] > 30:
if stats['kills_per_hour'] < 60:
speak('This ground pays badly.')
farm_summary
How to write it: farm_summary().
What it does: returns, as text, what the status key (Ctrl+F8) would say about the run right now: where it is, the kills, the rate, the deaths and the trips, in your language. It is an empty text outside a run. It does not speak by itself: wrap it in speak to hear it, or give it to status_detail so the status key says it.
Example:
speak(farm_summary())
status_detail(lambda: farm_summary())
public_time_left
How to write it: public_time_left().
What it does: returns the bot's own count of the public-area drop time you have left, in whole seconds, or None until the bot has read the character panel in this run. The count goes down only while you are on the farm map: the game pauses the clock in town, and a ride through other maps or an outage is not counted. It knows the daily refill at 00:00 UTC. It reads a number the bot already keeps, so nothing is pressed or spoken.
Worth knowing: to end a run with time to spare, set the floor with two lines near the top of your script, for this run only: cfg_set('farm_public_stop_when_left', '0h20m') and cfg_set('farm_public_stop_at_zero', 'true'). While farm_map or farm_patrol runs, the bot then rides to your city and ends the run when the time left falls to 20 minutes (write the time as 20m, 0h20m or 1h30). Without them it ends the run at zero, as long as public_farm_stop is on, which it is unless you switched it off.
Example:
left = public_time_left()
if left is not None and left < 1200:
ride_home()
tuned_maps
How to write it: tuned_maps().
What it does: returns the list of maps the bot has a measured, tuned farm for (the ones Farming Slave lists), named the way the game names them and in Farming Slave's order. farm_map runs these through the bot's own tuned chains; any other map is farmed by the general patrol. It reads a table inside the bot: no game, no keys. You get a copy, so changing the list changes nothing.
Example:
speak(str(len(tuned_maps())) + ' maps are tuned.')
tuned_zones
How to write it: tuned_zones().
What it does: returns the tuned maps grouped by zone, as a list of pairs: the zone's name, then the list of its maps. The zone names the hub the maps restock from (the game's own grouping), and the order is the one Farming Slave shows.
Example:
for zone, names in tuned_zones():
speak(zone + ' has ' + str(len(names)) + ' maps.')
tuned_zone_of
How to write it: tuned_zone_of('Wolf Prairie'), or with the map's number.
What it does: answers the zone of a tuned map as text. Capitals and spaces at the edges do not matter. It answers None when the map is not one of the tuned ones: a map the game has but the bot has no tuned farm for is None too, so None means "no tuned farm", not "no such map".
Example:
zone = tuned_zone_of('Wolf Prairie')
if zone:
speak('Wolf Prairie restocks in ' + zone + '.')
go_to
How to write it: go_to('place name').
What it does: walks, rides and loads maps until your character stands on the map or in the city you named.
Worth knowing: this is the same traveler the farms use, so it knows the roads. Use it for the stops of your own route: a city before a task, a meeting map at a set hour.
Example:
go_to('Moon City')
send_chat
How to write it: send_chat('one line of text'), or send_chat('one line of text', channel='team'). The channel is one of 'global' (the default), 'map', 'nearby', 'gang' or 'team'.
What it does: sends exactly one line to that chat channel. It answers True when the line went out and False when it did not.
Worth knowing: one line per call, and plain text, at most 300 bytes (the game's own limit; accented and Arabic letters take two bytes each). With the current in-game helper the line is sent directly, without typing, so it does not need your keyboard or the chat box. The bot adds no pause of its own: the only wait is the game's - it refuses a line that comes less than 3 seconds after the previous one on global (2 seconds on the other channels), so the bot waits that short moment and then sends. That means a script that loops on send_chat puts a line on the channel every three seconds, and the game and the server are the only limit: put your own pause in the loop. Nothing is posted while your character is dead or the game is not in the world. The channels other than global need the current helper; with an older one the line is not sent and the bot says so. A gang or team line only reaches a gang or team you belong to. Stop lands as soon as the call returns. Say something worth reading; the map can hear you.
Example:
send_chat('Selling time shards in Tulip City.')
send_chat('Ready when you are.', channel='team')
buy_items
How to write it: buy_items({'Large Red Potion': 50}). Inside the curly braces: an item name in quotes, a colon, then how many. Separate several items with commas.
What it does: buys the named items from the shop your character can reach. Names are partial: the game's own words for the item, and the bot finds it on the list.
Worth knowing: this is the sharp tool. restock_from decides for you and buys what your profile needs; buy_items is when you know better. Use the game's English item names; "Large Red Potion", not "red pots". The four potion names of your profile go to the pharmacy; any other name goes to the grocer. buy_items returns the set of names it actually bought, so check it: bought = buy_items({...}) then if 'Large Red Potion' not in bought: speak('The potions were not bought.').
Example:
buy_items({'Large Red Potion': 50, 'Large Blue Potion': 30})
repair_now
How to write it: repair_now().
What it does: repairs your gear now, in one step, with the repair tool in your bag. It needs the repair tool and its key set up in Settings ("Repair tool number key" and the repair switch); without them it says "Repair is not set up, so I cannot repair now" and returns False. So "repair before you log off" works only for a profile that already repairs.
Worth knowing: during a farm the engine repairs on its own schedule. This call is for scripts of your own: repair before you log off, and the next farm starts with full gear.
Example:
repair_now()
current_city
How to write it: current_city().
What it does: returns the name of the city you are standing in, or the nearest one the bot knows.
Worth knowing: useful before a decision: "am I already in Tulip City, or do I need to travel first?" It returns a name you can hand straight to restock_from or go_to.
Example:
speak('I am near ' + current_city())
maps_like
How to write it: maps_like('turkey').
What it does: returns every map name containing your piece of text, each with its map number, like rosha continent (map 4661). It does not speak by itself, so wrap it in speak to hear the answer.
Worth knowing: this exists because map names repeat. Of the 374 maps with wall data, 57 names exist on more than one map. When a name is ambiguous, the answer spells out its map numbers, and farm_map accepts a number in place of a name - the sure way to farm the exact map you meant. (A number that shares its name with other maps cannot be combined with flee or escape_map, which work by name: the bot says so aloud and farms nothing.) If you farm "turkey mountain" and it is not the one you meant, you would never know from the farming itself. Ask first; the list is short.
Example:
for name in maps_like('eucalyptus'):
speak(name)
cities_like
How to write it: cities_like('tulip').
What it does: returns every city name containing your piece of text, the shop cities first. Like maps_like, it does not speak by itself.
Worth knowing: the same honesty for cities. City names are real names in the game's English, and restock_from walks to real shops in them; a near-miss name buys nothing. Find the exact name once, keep it in your script forever.
Example:
for name in cities_like('city'):
speak(name)
map_id
How to write it: map_id('Tuneful Wetland').
What it does: gives the number of the map with that name, as a whole number your script can use (farm_map, go_to_npc, on_map and wait_for_map take it). Capitals do not matter. It reads the bot's map files: no key is pressed and the game does not have to be open.
Worth knowing: a name that exists on several maps (57 names do) is never answered with a guess. The bot says every number aloud and the call gives back None; use map_ids to get the whole list. A name no map has is spoken with the nearest names, and also gives None. A number is answered by itself when a map has it.
Example:
number = map_id('Tuneful Wetland')
speak('That map is number ' + str(number))
map_ids
How to write it: map_ids('ancient sealed land').
What it does: gives the list of every map number that carries the name, smallest first: [1760, 1761]. A name on one map gives a list of one, and a name no map has gives an empty list. It is silent: your script decides what to do with several.
Worth knowing: the name must be the whole name, in English; a piece of a name finds nothing (use maps_like for that).
Example:
for number in map_ids('ancient sealed land'):
speak('Map ' + str(number))
map_name
How to write it: map_name(1081).
What it does: gives the English name of the map with that number, or None when no map has it. It takes a number, not a name. The game's own number for Underwater World (2016) gives that map's name too.
Example:
name = map_name(1081)
speak('Map 1081 is ' + str(name))
map_info
How to write it: map_info(1081) or map_info('Tuneful Wetland').
What it does: describes a map from the bot's map files, as a dictionary. id and name; size, its width and height in tiles; doors, a list with one entry per door: to_id and to_name (where it leads), the door's rectangle x1, y1, x2, y2, its middle x, y, and direction, the key to press for a door on the map's edge (left, right, up or down; empty for a door in the middle of the map, which you walk into); npcs, the shop and service NPCs known on the map, each with name, x and y; rides, the cable-car rides, each with the destination, the NPC and its tile; and for the maps the bot farms by itself: tuned (True), zone (the hub map that serves it) and hub_city (the city whose shops it uses). It only reads files: no key is pressed and nothing walks.
Worth knowing: a name shared by several maps gives None and the bot says all the numbers, as map_id does; give the number instead. The NPC list is what is known, not a promise that every NPC is listed.
Example:
info = map_info(1081)
speak(str(len(info['doors'])) + ' doors')
speak('Size ' + str(info['size']))
spawn_zones
How to write it: spawn_zones('big eucalyptus'), or spawn_zones(5283), or just spawn_zones() for the map you stand on.
What it does: lists the rectangles where the map's monsters respawn, as a list of dictionaries with type, x1, y1, x2 and y2 (tiles). The type is the kind of respawn the game declares: normal, small, elite, big_elite, super, boss or event. A map that declares none gives an empty list. It only reads the map files: no key is pressed and nothing walks.
Worth knowing: a name shared by several maps is spoken with all its numbers and gives an empty list; give the number. farm_map already roams the respawn ground by itself; this is for a script that walks it on its own.
Example:
zones = spawn_zones('big eucalyptus')
first = zones[0]
goposition(first['x1'], first['y1'])
How to find a map's number
How to write it: speak(str(current_map_id())) on the map itself, or maps_like('part of the name') from anywhere.
What it does: every map has a name and a number, and the calls that take map_id= want the number. There are four ways to get it.
- Stand on the map and ask.
speak(str(world_context()['map_id'])) says the number of the map your character is on right now; current_map_id() gives the same number, and world_context()['map_name'] its name. They say None when the game's memory cannot be read yet. - Ask by name.
maps_like('part of the name') returns every map name that contains your text, each with its number, like rosha continent (map 4661). A name that exists on more than one map comes back with all its numbers, like central barracks (maps 1, 1772). - Read the list.
README-MAPS.md, in the same guides folder as this guide, names all 374 maps with their numbers: an alphabetical index (name, then number or numbers), a numeric index (number, then name), and for every map its size, its doors to other maps, the shops and service NPCs known on it, and the rides it offers. It is in English for every language: the map and NPC names are the game's English names whatever language your game speaks. - Pass the number.
go_to_npc, enter_through_npc, on_map and wait_for_map take map_id=, and farm_map takes a number in place of a name.
Worth knowing: pass map_id= whenever the name exists twice. Fifty-seven names do: "central plains" is map 1041 and also map 4705, and a name alone cannot say which you meant. go_to also takes a number, but it turns it into the map's name first, so for a name that exists twice give the number to go_to_npc, on_map or wait_for_map.
The tiles in README-MAPS.md are where an NPC was seen standing; give go_to_npc the tile as x, y after the map's name, as the example does.
Example, a whole script that travels between two maps and visits an NPC on each (save it in my_scripts):
TITLE = 'Two maps, two NPCs'
NOTE = 'The grocer in Central Plains, then the pharmacist in Tuneful Wetland.'
def run():
open_game_window()
# Stop 1. "central plains" names two maps, so map_id=1041 says which.
if not go_to_npc('Grocer John', 'central plains', 164, 221,
map_id=1041):
return
speak('At the grocer, on map ' + str(current_map_id()))
# Stop 2, on another map: go_to_npc travels there by itself.
if not go_to_npc('Pharmacist Evan', 'Tuneful Wetland', 356, 141,
map_id=1081):
return
if on_map('Tuneful Wetland', 1081):
speak('At the pharmacist.')
run()
Once you are at an NPC, talk_to_npc talks to it and chooses a menu row by the row's own words; to go through an NPC to another map, use enter_through_npc. Both are explained below.
NPCs, maps and XP dungeons
Sixteen more calls, for what a map's own patrol cannot do: reach an NPC, talk to it, go through it to another map, farm a map until the game moves you out, read a timed dungeon's own clock, and ride home. The XP Dungeon script is made of these, plus the start-up calls described in "Starting a script properly" (see also "The XP Dungeon script"); with them you can write a dungeon script of your own.
go_to_npc
How to write it: go_to_npc('npc name', 'map name'), or with the map's number too: go_to_npc('Spider cave', 'Water Curtained Cave', map_id=1502).
What it does: gets your character to an NPC from anywhere. It travels to the NPC's map unless you are already on it, then looks the NPC up by name among the people the game shows near your character and walks to it. It returns True when your character is at the NPC and False, said aloud, when the map cannot be reached or the name is not found. While it travels, the status key (Ctrl+F8) says where it is going, the map your character is on and how many maps are left.
Worth knowing: the lookup sees about 79 tiles around your character, so on a big map the NPC must be within that sight when the road ends. If you know the tile the game reads out for the NPC, add it as x, y: go_to_npc('White Bone Cave', 'ancient Sealed Land', 61, 110, map_id=1761); a tile you give is walked to as written, so it must be right. The walk to the tile gets 75 seconds; if it stops a few steps short, talk_to_npc still finds the NPC from there. map_id is the sure way to name a map whose name exists twice (maps_like shows which).
Example:
if go_to_npc('Spider cave', 'Water Curtained Cave', map_id=1502):
speak('I am at the cave keeper.')
talk_to_npc
How to write it: talk_to_npc('npc name', 'menu option'), or with several wordings of the option: talk_to_npc('Spider cave', ['Enter the dungeon', 'Enter dungeon']). A conversation of several steps is one call: talk_to_npc('Pharmacist Evan', 'Buy', then=['Large Red Potion'], quantity=50).
What it does: finds the NPC near your character, presses Enter to talk, and chooses the option from its menu. With then, it goes on down a path of menu rows: each name in the list is a row of the menu that the row before it opened, chosen in order. With quantity, it types that number into the number box that the last row opens. It returns True when every step was done, and False, said aloud with the step named, when one was not.
Worth knowing: three tries for the first row (tries=3 changes that); a try that finds no such option closes the menus with Escape before the next one. The rows after it are chosen once each, from the menu the game's memory shows. A list of wordings is tried in order, and capitals do not matter. It never picks a row that deletes, creates, quits, registers, changes the language, the server or the account, is Exit, or opens a text box or a web address: that is the same refusal list as choose_row, applied to EVERY step, and nothing is pressed on such a row. The quantity is a whole number from 1 to 2000 and is typed only when the game says its number box is open (a box the bot cannot read gets nothing). The rows are read as the game's English text whatever language your game speaks; if a name does not match on a translated game, tell us. It is refused, said aloud, while a fight is on or a death recovery owns the character.
Example:
go_to_npc('Pharmacist Evan', 'Tuneful Wetland', map_id=1081)
talk_to_npc('Pharmacist Evan', 'Buy', then=['Large Red Potion'], quantity=50)
bag_count('Large Red Potion')
enter_through_npc
How to write it: enter_through_npc('npc name', 'menu option', 'map name'), or with all its settings: enter_through_npc('Spider cave', ['Enter the dungeon', 'Enter dungeon'], 'Spider Cave', map_id=1503, tries=3, wait=30).
What it does: goes to another map through an NPC who sends you there. It talks to the NPC, chooses the option, and waits until your character stands on the new map. It returns True when you arrived (or were already there), and False, said aloud, after the last try.
Worth knowing: each try waits wait seconds for the new map; when it does not come, the menus are closed and the NPC is asked again. This is how the XP dungeons are entered.
Example:
enter_through_npc('Spider cave', ['Enter the dungeon', 'Enter dungeon'],
'Spider Cave', map_id=1503)
on_map
How to write it: on_map('map name'), or with the map's number: on_map('Spider Cave', 1503).
What it does: returns True when your character stands on that map. It does not speak.
Worth knowing: with a number, the game's own map number decides; without one, the name does, and a part of the name is enough.
Example:
if not on_map('Spider Cave', 1503):
speak('Not in the cave yet.')
wait_for_map
How to write it: wait_for_map('map name', timeout=30), or with the map's number: wait_for_map('Spider Cave', 1503, timeout=30).
What it does: waits until your character stands on the map, at most timeout seconds, and returns True when it got there.
Worth knowing: Stop and Pause still work during the wait.
Example:
if wait_for_map('Spider Cave', 1503, timeout=30):
speak('I am in.')
farm_until_map_changes
How to write it: farm_until_map_changes('map name'), or with all its settings: farm_until_map_changes('Spider Cave', 1503, bounds=(0, 180, 0, 180), until=my_check).
What it does: farms the map your character stands on until the game moves it to another map (a timed dungeon closing, a teleport), then stops fighting and returns. It fights the way every farm does: the radar on enemies, combat on pacifist with counterattack, the hunt, the attack and the one-enemy-at-a-time mode, your pet's care, chests, the respawn after a death and the farm's other helpers; then it sweeps the map in rows.
Worth knowing: bounds is the box swept: lowest x, highest x, lowest y, highest y; without it the map's own walls decide. until is a function of yours that takes nothing and answers True or False: when it answers True, the farm stops too. It does not shop and does not ride home: your script decides what comes next. When it returns, the hunt, the attack and the one-enemy-at-a-time mode are back the way they were before it started, so a farm your script runs next fights as it would have.
To hunt some monsters first while it runs, add priority='great ape' (a name or a list of names): your own hunt-first list is kept and put back, as with hunt_first.
Example:
farm_until_map_changes('Spider Cave', 1503, bounds=(0, 180, 0, 180))
speak('The cave put me out.')
The same stop conditions as farm_map work here too: kills=, level=, bag_full= and public_left= (see "Stop conditions" under farm_map). The call returns a dictionary: reason is 'map_changed' when the game moved you, 'until' when your function said True, the condition's name when one of the others was met, or 'ended'; with kills, minutes and level.
farm_dungeon
How to write it: farm_dungeon('dungeon name', map_id=1503), or with all its settings: farm_dungeon('Spider Cave', map_id=1503, bounds=(0, 180, 0, 180), minutes=15).
What it does: farm_until_map_changes for a timed XP dungeon your character is already inside. While it farms, the status key (Ctrl+F8) says you are inside the dungeon, its kills, its kills an hour and its time left: the bot presses Q a few seconds in to read the dungeon's own time, counts it down, and reads it again every five minutes. When the dungeon puts you out, it says the dungeon is finished and returns; until the ride home, the status key says the dungeon's total kills.
Worth knowing: minutes is how long the dungeon lasts, for the time left before the first Q line is heard; the four XP dungeons last 15. It does not ride home: ride_home() does. Like farm_until_map_changes, it leaves the fighting switches as it found them.
To hunt some monsters first while it runs, add priority='great ape' (a name or a list of names): your own hunt-first list is kept and put back, as with hunt_first.
The stop conditions of farm_map work here as well: kills=, level=, bag_full=, public_left= and until=. The first one met ends the farm inside the dungeon, before its own time is up. The call returns a dictionary with reason ('map_changed', 'until', the condition's name, or 'ended'), kills, minutes and level:
r = farm_dungeon('Spider Cave', map_id=1503, kills=300)
Example:
try:
farm_dungeon('Spider Cave', map_id=1503)
finally:
ride_home()
hunt_first
How to write it: with hunt_first('great ape'): and then the farm call, indented under it. It takes one name, several names, or lists of names.
What it does: puts the monsters you name at the front of the hunt for the block it wraps, whatever farm call runs inside it (farm_until_map_changes, farm_dungeon, farm_patrol, farm_map). Your own hunt-first list from Settings is kept: the names are added to it, and when the block ends, even when it ends in an error, your list is back exactly as it was. Blocks can nest.
Worth knowing: it must be written with with; written alone, hunt_first('great ape') does nothing (the log says so). A boss the bot is watching for, like the names you gave farm_map(flee=...), is never put on the list: a boss is fled, never hunted first. farm_until_map_changes and farm_dungeon also take priority='great ape' (a name or a list) for the same effect during that one call.
Example:
with hunt_first('great ape', 'king beetle'):
farm_until_map_changes('Spider Cave', 1503)
dungeon_info
How to write it: dungeon_info().
What it does: presses Q and returns the dungeon's own line (its time remaining and today's entries) as text, or an empty text when the game said no such line within a second and a half. It does not speak by itself, so wrap it in speak to hear it.
Example:
speak(dungeon_info())
ride_home
How to write it: ride_home(), or ride_home(city='Tulip City', sell_shards=True, quit_game=True).
What it does: ends the run the way every farm ends it: fighting off, the pet put away, the fusion beast mounted, and a ride to your return city (the "Leave me in" answer of the Run window). Nothing after it runs: it is your script's last call.
The three options change the end of THIS run only; your Settings are not touched, and anything you leave out stays as Settings has it.
city: where to end, for example 'Tulip City'. A city the bot does not know is refused out loud, and that call does not end the run.sell_shards: True sells the shards your profile lists before the run stops, False sells nothing, whatever Settings say. The list of shards is always your profile's.quit_game: True closes the game after the ride, False leaves it open.
Worth knowing: it does nothing, silently, when a Stop is in progress. It waits for a death recovery that is running to finish first, and refuses out loud if that takes more than ten minutes. The Hearthstone is never used: on a map with no road at all to your city (ancient Sealed Land, where White Bone Cave puts you out, is one), the ride tries its planners once and, if none has a road, stops there and says the character could not get home. Put ride_home in a finally, as in the examples: that is how the ride home always comes after the farm.
Example:
try:
farm_map('wolf prairie', hours=4)
finally:
ride_home()
To end in another city and close the game:
try:
farm_map('wolf prairie', hours=4)
finally:
ride_home(city='Tulip City', quit_game=True)
enable_death_recovery
How to write it: enable_death_recovery(), or enable_death_recovery(back_to='wolf prairie', restock_in='Giant Rock City').
What it does: arms the bot's death recovery for the whole run: if your character dies, the bot brings it back to life in the city, the way a farm does, and your script carries on from there. Call it at the top of your script, beside enable_regen(), so the road to the NPC is covered too. It returns True when it is armed.
With restock_in the bot also shops in that city once the character is alive, and with back_to it then walks back to that map (a name or a map number). Give one, both or neither. The shop comes first, then the walk.
Worth knowing: it refuses, says why and arms nothing when a death recovery is already running, when the city or the map is not one the bot knows, and when back_to is a timed XP dungeon (the dungeon would already be lost). If a boss you flee from with farm_map is up on the back_to map after a death, the character stays in the city instead of walking onto him. The Hearthstone is never used. farm_until_map_changes and farm_dungeon keep the recovery you armed, and farm_map sets its own walk back to its farm and puts yours back when its farm ends. A recovery left from an earlier run in the same bot window never sends this run back to that run's farm.
Example:
enable_regen()
enable_death_recovery()
farm_until_map_changes('wolf prairie')
With a shop and a way back:
enable_death_recovery(back_to='wolf prairie',
restock_in='Giant Rock City')
character_level
How to write it: character_level().
What it does: returns your character's level as a whole number, or None when it could not be read. The game's memory does not carry the level, so the bot opens the character panel for about a second, reads its first row and closes it again. It never fails: a level nobody could read is None, and the bot decides nothing from it.
Worth knowing: because it opens a panel, ask it in town or before a farm starts, never in the middle of a fight. world_context() also carries a level that costs nothing, but it is the level of the last panel the bot read, so it can be old after a level-up.
Example:
level = character_level()
if level is not None and level >= 60:
speak('Level ' + str(level) + ', Scorpion Cave is open to me.')
dungeon_level_gate
How to write it: dungeon_level_gate('Scorpion Cave', 60, 79). The last number is optional.
What it does: checks your level against a dungeon's level range before you walk to it. It answers True when you may go on, and False, after saying aloud why, when your level is below the minimum or above the maximum. The XP Dungeon script calls it first, so a level-78 character is never walked four minutes to a door that will not open. The ranges of the four XP dungeons are: Spider Cave 40 to 59, Scorpion Cave 60 to 79, Bottomless Pit 80 to 89 and White Bone Cave 90 to 100.
Worth knowing: a range of 0 or nothing is never checked, and neither is a level that could not be read; the answer is then True, so the run goes on as it did before the gate existed. It reads the level the way character_level() does, so call it before the farm, not during a fight.
Example:
if dungeon_level_gate('Scorpion Cave', 60, 79):
speak('The level fits, setting off.')
else:
speak('Staying home.')
dungeon_status
How to write it: dungeon_status().
What it does: describes the XP dungeon that farm_dungeon is farming right now, as a dictionary. Outside a dungeon it is {'active': False}. Inside one it has active (True), name, map_id, inside_sec (seconds spent inside), time_left_sec and time_left_min (the dungeon's time left: the game's own Q line once one was heard, else counted down from the dungeon's length), q_response (the last Q line heard, an empty text until one is), and kills and rate (kills an hour) made inside the dungeon only, not on the road to it. It costs nothing and presses nothing, so it fits the function you hand to status_detail.
Example:
info = dungeon_status()
if info['active']:
speak(info['name'] + ': ' + str(info['time_left_min']) + ' minutes left.')
xp_dungeons
How to write it: xp_dungeons().
What it does: gives you the four timed XP dungeons as a dictionary (a copy: changing it changes nothing in the bot). Each dungeon's name leads to its row: map_id (the dungeon's own map number), entry_map and entry_map_id (the map where its NPC stands), npc and npc_tile (the NPC's name and the tile it stands on), min_level and max_level (the game's own level range, both ends count) and bounds (the box hunted inside). The Run window of the XP Dungeon script offers exactly these names.
Example:
level = character_level() or 0
for name, d in xp_dungeons().items():
if d['min_level'] <= level <= d['max_level']:
speak('Your level fits ' + name + '.')
run_xp_dungeon
How to write it: run_xp_dungeon('Spider Cave').
What it does: runs one timed XP dungeon from start to finish. It checks your level against the dungeon's range FIRST (a character outside it is told so and nothing walks), switches healing and death recovery on, applies your profile's repair setting, travels to the dungeon's map and walks to its NPC from wherever you stand, talks to the NPC and goes in, hunts until the game puts you out, and rides home. The ride home always happens, also when the road failed; standing inside the dungeon already skips the road. It returns {'ok': True or False, 'kills': N, 'minutes': M, 'reason': text}.
Worth knowing: the name is one of xp_dungeons() (capitals do not matter): Spider Cave, Scorpion Cave, Bottomless Pit or White Bone Cave. ok is True when the dungeon was hunted, and reason says how the run ended (ended, or the stop condition that fired) or why it never started (level, unknown_dungeon, refused, no_road, not_entered). It does not open the game or check your access: put open_game_window() and require_access() first (see "Starting a script properly"). It is refused, said aloud, while a death recovery or a boss escape owns the character. It uses no Hearthstone.
Example:
open_game_window()
require_access()
if (character_level() or 0) >= 60:
run_xp_dungeon('Scorpion Cave')
A script that talks to NPCs on two maps
A script is calls one after another, and go_to_npc and run_xp_dungeon travel by themselves, so a script that does business with an NPC on one map and then goes on to another map is three lines:
go_to_npc('Pharmacist Evan', 'Tuneful Wetland', map_id=1081)
talk_to_npc('Pharmacist Evan', 'Buy', then=['Large Red Potion'], quantity=50)
run_xp_dungeon('Spider Cave')
The first line travels to the first map from wherever you are and walks to the NPC. The second talks to him, follows the menu to the potion and types the number. The third travels to the second map, talks to the dungeon's NPC, goes in, hunts and rides home. For two NPCs without a dungeon, use go_to_npc again with the second map's name and talk_to_npc for the second NPC.
Your own XP dungeon script
A whole script for one dungeon, made of the calls above plus open_game_window() (see "Starting a script properly") and enable_regen(), which turns on healing by your profile's settings. Save it in my_scripts, put your dungeon's names and numbers in it, and run it from the list.
TITLE = 'My Spider Cave'
NOTE = 'Spider Cave, then home.'
def run():
open_game_window()
enable_regen()
enable_death_recovery()
# Not inside yet: reach the NPC from anywhere, and go in.
if not on_map('Spider Cave', 1503):
if not go_to_npc('Spider cave', 'Water Curtained Cave',
map_id=1502):
return
if not enter_through_npc('Spider cave',
['Enter the dungeon', 'Enter dungeon'],
'Spider Cave', map_id=1503):
return
# Inside: hunt until the dungeon puts you out, then ride home.
try:
farm_dungeon('Spider Cave', map_id=1503, bounds=(0, 180, 0, 180))
finally:
ride_home()
run()
The XP Dungeon script does the same for four dungeons with one call, run_xp_dungeon (see "The XP Dungeon script" below), and you can write the short version yourself: run_xp_dungeon('Spider Cave').
Making gems: arnebia, buying shards and the gang hall
Six commands that used to live inside the Make Gems script. They go through the same gate as the town trips: they wait for the world to be readable, refuse to run during a fight or while a death recovery owns your character, and say every refusal and failure out loud. None of them uses the hearthstone, and none of them sells anything.
The ones that spend arnebia keep five guards. They never spend below the floor you give (keep_arnebia). They buy at most 2000 shards a trip and never fewer than four. They say the price and the total out loud before they buy. They wait when you bought less than a minute ago, so a loop in your script cannot empty your purse. And they take a gem TYPE (Topaz, Moonstone, Blond Jade and so on), never a shard's name.
These commands have nothing to do with the automatic shard sale at the end of a run. That sale is its own setting ("Sell my shards when the run ends") and it happens after your last line, whatever you called. If you want to sell in the middle of your script, call sell_shards() yourself.
They read the NPC menus by their English text, which the in-game helper supplies in every game language; if a menu cannot be read on your game language, the reason is said aloud and nothing is bought.
A gem night in three lines:
make_gems('Jade', 6, count=3)
break_gems()
sell_shards()
arnebia
How to write it: arnebia(). It takes no arguments.
What it does: tells you how much arnebia your character holds, as a whole number, read from the game's memory.
Worth knowing: it returns None when the game's memory does not show the amount (unknown is never zero). It presses no key and says nothing, so it is safe in the middle of a fight.
Example:
money = arnebia()
if money is not None:
speak('I hold ' + str(money) + ' arnebia')
buy_shards
How to write it: buy_shards('Topaz', 400, keep_arnebia=100000). The gem type and the number of shards come first; keep_arnebia is optional and defaults to 0.
What it does: buys shards of one gem type from the Shard Broker and never lets your arnebia fall under the floor you give. Stand beside the broker first: go_to_city() and then go_to_service('broker').
Worth knowing: the number is from 4 to 2000 (more is cut to 2000, the quantity box's own limit). Before it buys it says the price from the broker's list and the total. It cuts the number so your purse keeps the floor, and so the shards fit in the bag. It waits until a minute has passed since your last purchase, and it refuses during a fight or a death recovery. It returns a dict with ok, bought, spent, unit_price and reason; bought is what the bag really gained, and ok is False (with the reason said aloud) when nothing was bought.
Example:
go_to_city()
go_to_service('broker')
r = buy_shards('Topaz', 400, keep_arnebia=100000)
in_gang_hall
How to write it: in_gang_hall(). It takes no arguments.
What it does: tells you whether your character stands inside a gang hall.
Worth knowing: it returns True or False, reads the game's map number, presses no key and says nothing.
Example:
if in_gang_hall():
leave_gang_hall()
go_to_city()
enter_gang_hall
How to write it: enter_gang_hall('my gang'), or enter_gang_hall(15) for the gang with that number.
What it does: walks to the Gang Entrance and goes inside the gang hall. Stand in the city that holds the entrance first (go_to_city()).
Worth knowing: it never guesses a gang. An empty answer, or anything but 'my gang' or a gang's number, is refused and said aloud, and no door is opened. It returns a dict with ok and reason; ok is True once you are inside (also when you already were), and False, with the reason said aloud, when the game says you have no gang, the entrance is not in sight or the number is not in the list. It refuses during a fight, a death recovery, inside a dungeon and during a boss escape.
Example:
go_to_city()
enter_gang_hall('my gang')
go_to_service('crafter')
leave_gang_hall
How to write it: leave_gang_hall(). It takes no arguments.
What it does: walks out of the gang hall through its one door, back to the city map.
Worth knowing: it returns True when you are outside a gang hall (also when you never were inside one) and False, said aloud, when the walk out failed or the command was refused.
Example:
leave_gang_hall()
go_to_service('broker')
buy_shards('Topaz', 400)
make_gems
How to write it: make_gems('Topaz', 6, count=3). The gem type and the level come first. The options are count=1, keep_arnebia=0, shards_per_trip=2000 and gang=''.
What it does: buys shards at the broker and makes gems at the crafter until count NEW gems of that type and level exist. The gems of that level that are already in your bag are not counted and are never used up: with one level 6 gem in the bag, count=1 makes another. When the bag cannot make more, it rides to the broker, buys more and comes back.
The arguments: the gem is a type such as 'Topaz'; a word that fits only one type is accepted ('Jade' is Blond Jade). The level is 2 to 9, the count 1 to 1000 and shards_per_trip 4 to 2000. gang='' uses the city's Gem Craftsman; gang='my gang' or a gang's number (gang=15) uses the crafter inside that gang hall. A wrong number or gang answer is refused and said aloud, never corrected for you.
Worth knowing: every buy is cut so your purse keeps keep_arnebia, is announced with its price first, and waits for the one-purchase-a-minute floor. It stops when the target exists, when your arnebia cannot buy four shards, when the bag has no room for four, when the crafter refuses three orders in a row, or when it was refused (a fight, a death recovery). Above level 6 it warns once that the bot does not use protection runes. It returns a dict with ok, reached, have, made, fee_spent, shards_bought, arnebia_spent and reason: reached is True when the target was made, have is the bag's count of that level (None when it cannot be read), made is how many new gems of that level, and reason says why it stopped short. An optional progress={} dict is kept filled in (fee_spent, shards_bought, arnebia_spent and bag, a function that reads the bag when you call it) for a status line.
Example:
r = make_gems('Topaz', 6, count=3, keep_arnebia=50000)
speak('Made ' + str(r['made']) + ' gems')
break_gems()
The toolbox reference
Everything here is already inside your script. Each entry says what it is and gives one working line. The calls above are not repeated.
Talking and listening
speak(text) makes NVDA say one line. Your progress reports, your summaries. speak('Halfway there.')
status_message(text) sets your script's identity sentence: what the farm-switch key (Ctrl+F6) says together with the character's name. Call it once at the top of the script. status_message('Running my night loop')
status_detail(text) registers what Ctrl+F8 answers — your script's own info, spoken exactly, with nothing added. A string stands still; a callable is read at the press, so the answer always says where your run stands: status_detail(lambda: f'Broken {n} gems, selling the shards') Without a detail, Ctrl+F8 answers with the farm's numbers as before. Ctrl+F6 stays the engine's key: it names the running script and the character, using the identity sentence you registered above.
steps_done = 0
status_message('Running my night loop')
status_detail(lambda: f'{steps_done} steps done so far')
The shipped Farming Slave, Make Gems, Shard Seller and XP Dungeon register both, the first for the name and the second for Ctrl+F8. With two farms running, Ctrl+F6 names the script of the farm you just selected, not the one of the window you pressed it in. Their sentences come from the bot's own translation table, which a script of your own cannot add to: write yours as plain text.
last_spoken() returns the most recent line the bot said or matched, as text. Handy in a reaction to add context. if 'boss' in last_spoken(): ...
recent_speech(5) returns a list of the lines from the last five seconds, oldest first. For looking back at what just happened. for line in recent_speech(5): speak(line)
wait_for(pattern, timeout=30) blocks until the game says a matching line, then hands you the match; when the timeout runs out it hands you None instead. The pattern is a regular expression: plain words match themselves, and parentheses lift a piece out - match.group(1) is what the first parentheses caught. timeout=0 means no upper bound. One neutral example, waiting for a boss broadcast:
m = wait_for(r'broadcast ;.*Monkey King Wukong', timeout=600)
if m:
speak('The king is announced.')
else:
speak('Ten minutes, no broadcast.')
on_speech(pattern) is the @ line that pins a function to a pattern: from then on the function fires by itself whenever a matching line is spoken, while your script farms, waits, or sleeps. The ears stay on only while the script runs, and a loop keeps the script alive for them. Note the shape of the ending: try and finally, never except - finally runs your cleanup and lets Stop through, and clear_handlers() takes the ears off cleanly. One neutral example:
@on_speech(r'broadcast ;.*Monkey King Wukong')
def heard_wukong(match):
speak('Wukong broadcast. ' + match.group(0))
try:
while True:
check_abort()
sleep(1)
finally:
clear_handlers()
Pressing keys and menus
keypress('ctrl+1') presses one key combination, exactly as if you had. Named keys with plus signs. keypress('f5')
type_string('hello') types text into whatever is focused, one character at a time. type_string('hello')
menu_search('Bags') finds an entry in a menu that is ALREADY OPEN: it presses the navigation key (S by default, the nav_key setting) until the game says text containing yours, then presses Enter, and returns True or False. With no menu open the S key walks your character, so open the menu first. The usual pattern is an NPC: find_object('Pharmacist Evan', mode='npc'), keypress('enter'), then menu_search('Buy').
find_object('Pharmacist Evan', mode='npc') looks for the named NPC or object near your character, focuses it, and returns True or False. Partial names work. Pass mode='npc' for a person (the radar is otherwise left on enemies after a fight), and stand where the NPC is in sight. The depth setting is not used.
Moving
goposition(x, y) walks your character to a map coordinate. The coordinates are the ones the game reads out. goposition(120, 84)
current_position() returns where you are, as (x, y), or (0, 0) before the first reading. x, y = current_position()
current_map() returns the name of the map you are on, as the game spells it, with capitals, or an empty text before the first reading. if not on_map('wolf prairie'): go_to('wolf prairie')
Fighting
enable_single_target_attack() and disable_single_target_attack() turn the one-enemy-at-a-time attack mode on and off. On when you want one enemy; off when the farm engine should choose. enable_single_target_attack()
attack(keys) swings your attack skills once; keys is a list of the keys you set up in your profile, or leave it out to use them all. attack(['1', '2'])
ignore_mob(*names) tells the engine to leave named monsters alone - loot guards, event mobs, whatever you do not want. Both the fighter and the mob hunt skip them. ignore_mob('Guard of the Gate', 'Young Turkey')
get_current_target() returns a small record, {'name': ..., 'hp': ..., 'yards': ...}, read from the last target line the game spoke, or None when that last line was not a target line. Press a target key first (K, L, O or ;), then call it.
keypress('k')
t = get_current_target()
if t:
speak('Fighting ' + t['name'])
Staying alive
get_hp() returns your health points right now, as a number; 0 means the bot has not read it yet. speak(str(get_hp()) + ' health left')
get_mp() returns your mana points right now. if get_mp() < 100: speak('Mana is low')
get_potion_counts() returns the potion counts the bot is tracking, by name: hp, mp, pet_hp, pet_mp. A count of -1 means not scanned yet. c = get_potion_counts()
Pets and mounts
activate_pet('Frog') summons the named pet, by the name in your profile. activate_pet('Frog')
set_fusion_beast(True) rides your fusion beast; False dismounts. Long roads are faster on it. set_fusion_beast(True)
A character on the beast (fused) cannot attack. set_fusion_beast(True) rides, and your script must set_fusion_beast(False) before it fights.
Town things: shopping, storage, repair
buy_items({...}) and repair_now() are described with the thirty-five tools above.
take_from_storage('Large Toolbox', 5) takes items from the storehouse NPC: name, then how many; zero means all of them. take_from_storage('Large Red Potion', 100)
deposit_to_storage('Large Red Potion', 0) deposits bag items into the storehouse: name, then how many; zero means all. deposit_to_storage('Junk Shard', 0)
sell_shards() sells the shards you chose in Settings: the same sale the bot makes at the end of a farm. It finds the Shard Broker, walks to him and sells, then answers True when something was sold and False when not, so if sell_shards(): works. It needs "Sell unwanted shards when the bag is full" switched on and at least one shard chosen with "Choose which shards to sell"; when it declines for that reason it says so aloud. sell_shards()
Settings
cfg_get(key, fallback) reads one setting from your character's profile; fallback is what you get when the setting was never saved. Use it to make your script configurable without editing it. start_hour = cfg_get('my_start_hour', '21')
cfg_int(key, fallback) reads a setting as a whole number, and cfg_bool(key, fallback) reads it as yes or no: hours = cfg_int('my_hours', 6).
cfg_set(key, value) changes a setting for this run only; the value is gone the next time you press Run. cfg_set('my_flag', 'yes')
cfg_save(key, value) changes it now and also writes it into your character's profile, so it is still there next time. It answers True when the profile was written and False when it could not be (no profile, a name with a space, a computer-wide setting). A setting of your own, like my_start_hour, needs no editing by hand: the first cfg_save adds it to the profile. cfg_save('my_start_hour', '22')
Running and stopping
sleep(60) waits while staying responsive: Stop and Pause pass through it. The only sleep your loops should ever call. sleep(n) and check_abort() raise SystemExit on Stop and never return an answer. sleep(5)
check_abort() checks Stop and Pause right now, without waiting. It does not return an answer: it raises the stop, so never test it with if. Every loop should call it or sleep. check_abort()
run_script('name.py') runs another script inside this one, waits for it to finish, and comes back. It looks for the name first in the bot's own scripts folder, then in my_scripts, so you can split a night across several of your files and chain them by name. If a bot script and one of yours carry the same name, the bot's own wins. Do not chain Farming Slave and expect to come back; farm_map(..., hours=...) is the call that returns. run_script('my_night_loop.py')
clear_handlers() takes off every ear this script pinned on, and only those: the bot's own listeners stay. The last line of every finally that follows an @on_speech. remove_handler(pattern) takes off just the ear you pinned with that pattern. clear_handlers()
Also available
Each name here is available in your script; see the source docstring for what it takes.
- Window and access:
open_game_window, find_game_window, focus_game, is_game_running, require_access, recheck_access (see the source docstring). Do not call: start_game. - Reading settings:
cfg_int, cfg_bool, cfg_float, cfg_list, cfg_load (see the source docstring). - Attack and combat switches:
enable_attack, disable_attack, enable_melee, disable_melee, set_attack_type, enable_nav_attack, disable_nav_attack, set_speed_attack, clear_ignored_mobs, enable_mob_hunt, disable_mob_hunt (see the source docstring). - Care switches:
enable_pet_regen, enable_pet_food, enable_repair, disable_repair, enable_auto_chest, disable_auto_chest, enable_auto_resurrect, disable_auto_resurrect, enable_hazard_escape, enable_obstacles, enable_clearbag, enable_auto_reply, and their disable_ partners (see the source docstring). - Travel and maps:
travel_to, ensure_on_map, can_walk_to, reachable_from, current_map_id, walk_off_map, goposition_map, farm_patrol, declare_wall_alias (see the source docstring). - Timers:
set_interval, del_interval, clear_intervals (see the source docstring). - Items and characters:
press_item_key, scan_potions, get_char_name, get_char_info, keydown, keyup, timewait (see the source docstring). - Mounts and parking:
enable_mount, disable_mount, park_character (see the source docstring). quit_game closes the game: use it only as the last line. - Do not call (the engine runs these itself):
start, stop, start_health_monitor, stop_health_monitor, start_hotkey_listener, stop_hotkey_listener, start_go, stop_go, start_random_going, stop_random_going, inject_speech, make_socket.
Rules that keep you safe
The stop contract. Ctrl+F10 stops your script (in the main window) by raising SystemExit inside it, and Ctrl+F9 pauses it through the same door. The same stop request, raised by the window's Stop button, reaches a second farm the same way. Your side of the contract: call sleep() or check_abort() in every loop, and never catch SystemExit or a wide except Exception around the whole script. A script that breaks the contract stops eventually, but it will ignore you first, and the engine will say so.
One game per script. The bot locks your run to one game before your first line. Do not try to drive a second game from the same script; that is what a second bot and a second profile are for. Two bots on the same game are refused, by design.
Do not fight the engine's own threads. The engine already runs listeners, health watchers and travelers. Do not start your own threads against the game, and do not call the low-level query layer directly. Everything on the toolbox list is safe to call from your script's own single flow; that is what the list is for.
Reserved names. mortal.py and respawn.py are the engine's own internal scripts. A file of yours with either name would be hidden and never run, so the bot refuses to create one. Any other name is yours.
Updates keep your work. A bot update replaces the engine and the shipped scripts, never the my_scripts folder. Keep your scripts there and nowhere else, and they survive every update.
After an update, close the bot completely and open it again. That means the main window and every farm window. Until you do, a farm you start from the Run window can still be running the old engine. A script that uses a function the old engine does not have stops within seconds with "name ... is not defined" or "No module named ...". Nothing is wrong with your script; restart the bot.
If your script crashes, the bot says "Something unexpected happened and the bot stopped" and nothing more. The traceback is in the session log: Help, Past sessions (Ctrl+L) opens it, and the bot window's Client output shows it as it happens. In a farm started from the Run window as a second farm, the bot may say nothing at all (see the update note above); read the log.
The Make Gems and Shard Seller scripts use bot-internal helpers that are not on the toolbox list. Copying them into my_scripts works only while those internals stay as they are; do not import private bot modules in a script of your own.
Name your run. Call status_message(text) once at the top of your script, and use status_detail(text) for what the status key (Ctrl+F8) says about your run. Both are described in "Talking and listening" in the toolbox reference.
What the bot does when your script ends by itself. When a script finishes (not when you press Stop), the bot may still make one trip for you. If your profile has "Sell my shards when the run ends" switched on (the setting run_sell_shards_end), it first breaks the gems you chose in Settings, when the Run window said so (farming_slave_break_gems), and then walks to the Shard Broker and sells the shards you chose, the same sale as sell_shards(). This happens after your last line, in any script that does not leave the shard question out of its RUN_QUESTIONS. If your script already sold, the end sale finds nothing left to sell; calling sell_shards() yourself is harmless.
Settings the Run window writes. The Run and Schedule windows save their answers into your character's profile, and the bot acts on them whatever script runs, so a script of yours inherits them: run_sell_shards_end (sell the shards when the run ends), farming_slave_break_gems (break gems before that sale), farm_public_stop_when_left and farm_public_stop_at_zero (the public-area time to leave unused), return_city (the "Leave me in" city that ride_home() and the end of a run ride to), quit_game_after_script_ends (close the game when the run ends) and skip_startup_restock (skip the restock at the start of a farm). Read any of them with cfg_get. A script of yours that ends with ride_home() and names RUN_QUESTIONS should include afterwards: a question the window does not ask keeps the answer saved earlier from another script's window, so without it the game could be closed, or kept open, at the end of your run without the choice ever being shown to you.
Setting the public-area floor from a script. Two lines set the floor for this run only: cfg_set('farm_public_stop_when_left', '0h20m') and cfg_set('farm_public_stop_at_zero', 'true'). While farm_map or farm_patrol runs, the bot then ends the run, riding to your city, when the public-area drop time left falls to the floor. Write the time as 20m, 0h20m or 1h30; public_farm_stop must be on, which it is unless you switched it off.
park_character() works once per run. It dismounts the fusion beast and puts the pet away. The bot calls it itself at every run end, and the first call wins: a second call, yours or the bot's, is skipped silently (the log says so). Call it at most once, and not in the middle of a script if you want it at the end too.