Auto Farm
On this page
Reads and switches Auto Farm, the Rotation Builder's farmer. Auto Farm picks the best spot on the current map, goes there and attacks whatever is in reach, and follows the character to the next map. Its switch is saved with your settings, so Auto Farm left on starts again after you log in, reconnect or restart the game.
Your own keys still reach the game while Auto Farm farms, and so do scripts' key presses: core.input.press_key(), hold_key(), release_key(), use_item(), use_skill() and call_wndproc() work as usual. Calls that move the character, such as core.input.teleport(), move_x() or core.nav.path_to(), are refused with Rotation Builder owns the input while Auto Farm is active. To move the character without switching Auto Farm off, use core.farm.hold().
Functions
core.farm.is_enabled() -> boolean
Available on GMS and CW
Returns true while Auto Farm is switched on, including while it waits to get into the game or for a map where monsters spawn.
core.farm.is_active() -> boolean
Available on GMS and CW
Returns true while Auto Farm is moving the character and attacking on the current map. Returns false while it waits, while it changes maps or starts over, and while it is switched off.
core.farm.status() -> table
Available on GMS and CW
Returns what Auto Farm is doing right now:
| Field | Type | Description |
|---|---|---|
enabled | boolean | Auto Farm is switched on |
active | boolean | Same as is_active() |
borrowed | boolean | Auto Quest has borrowed Auto Farm for a hunt, which also runs it with the switch off |
state | string | What it is doing; see the table below |
held_by | string or nil | While state is busy or paused, what is using the character; see the list below |
map_id | number | The map it is farming or waiting on; 0 when it is off |
kills | number | Monsters killed since it last started on this map |
run_seconds | number | Seconds since it last started on this map |
spawns | number | Monster spawn points it found on this map; 0 until it starts |
main_skill | number or nil | Skill ID of its main attack; nil until it starts. On Classic 0 is the Basic attack |
spot | table or nil | The spot it chose, while it has one; see below |
time | table | Seconds since it last started on this map, spent on travel, attack, waiting and looting. Always there, all 0 before it has any to report |
spot has these fields:
| Field | Type | Description |
|---|---|---|
x, y | number | Where it stands to attack, in map coordinates |
facing | number | -1 facing left, 1 facing right |
hits | number | How many monsters it expects to hit from there |
travel_seconds | number | How long it expected the trip there to take when it chose the spot |
attack_box | table | What its main attack covers from there: left, top, right and bottom in map coordinates |
| State | Meaning |
|---|---|
off | Auto Farm is switched off |
not_in_game | Waiting for the character to be in the game |
busy | Waiting to start while a loop, another feature or a script uses the character; held_by says which |
no_monsters | Waiting for a map where monsters spawn |
no_attack_key | Waiting: put an attack skill on a hotkey |
all_attacks_skipped | Classic only. Waiting: every attack, the Basic attack included, is switched off under Skills on the Farm page |
no_undead_monsters | Classic only. Waiting: Heal is the only attack left on, and no undead monsters spawn on this map. Switch the Basic attack or Holy Arrow back on, or go to a map with undead monsters |
no_jump_key | Waiting: put Jump on a hotkey |
no_area_platform | Waiting: the map's farm area has no platform the character can reach |
no_area_monsters | Waiting: no monsters spawn inside the map's farm area |
idle | Farming, with nothing to hit from any spot it can reach |
travelling | Heading for the spot it chose |
attacking | Attacking from its spot |
attack_refused | The game is not taking the attack (MP, a cooldown or a status); it tries again every second |
changing_map | The map changed; it starts again once the next map has loaded |
dead | The character died; it starts again once the character is back up |
restarting | Starting over; it carries on in a moment |
paused | Another feature or a script is using the character; held_by says which. It starts again once that is done |
held_by is one of loop, rusher, evasion, lie_detector, auto_sell, restock, auto_chat, navigation, movement, held_key or script, and on Classic also transformation or party.
core.farm.start()
Available on GMS and CW
Switches Auto Farm on, the same as turning on the Auto farm switch on the Farm page. It starts once the character is in the game on a map where monsters spawn, and stays on, also after logging in again, until it is switched off.
core.farm.stop()
Available on GMS and CW
Switches Auto Farm off, the same as turning that switch off. The switch is saved, so Auto Farm stays off at the next login too. To use the character for a while and have Auto Farm carry on afterwards, use hold() instead.
core.farm.hold(seconds: number) -> boolean
Available on GMS and CW
Borrows the character from Auto Farm for up to seconds, above 0 and at most 600, and leaves its switch alone. Anything else raises an error. Auto Farm lets go of the character on its next update, with state paused (or busy if it hadn't started) and held_by script.
Returns true when your script can move the character: Auto Farm has let go, no loop is playing, and no other feature (the map rusher, Evasion, the lie detector, an auto-sell or restock trip, Auto Chat) has the character. Returns false until then. The hold stands either way, so call it again on a later tick until it returns true.
Calling it again replaces the time your script has left, so a script that keeps calling it with a few seconds holds the character for as long as it needs, and frees it soon after it stops. Each script has its own hold, and Auto Farm waits for all of them. A hold ends when your script calls release(), when its time runs out, and when your script unloads. Auto Farm then starts again on whichever map the character is on, once any trip or movement your script started has finished. kills, run_seconds and time carry on if the map is the same.
Kami and Auto Attack stay off during a hold, as they do whenever Auto Farm is switched on. A long hold during an Auto Quest hunt counts against Auto Farm, and Auto Quest may leave the map for that hunt.
core.farm.release()
Available on GMS and CW
Ends your script's hold, so Auto Farm can start again. Does nothing when your script has no hold.
Skipped skills
Reads and changes the skills Auto Farm never uses, the ones switched off under Skills on the Farm page. A change is saved with your settings and shows on the Farm page, and a running farm starts over without those skills.
core.farm.get_skipped_skills() -> table
Available on GMS and CW
Returns the skipped skills' IDs as a list, lowest first. On Classic 0 stands for the Basic attack.
core.farm.skip_skill(skill_id: number) -> boolean
Available on GMS and CW
Makes Auto Farm skip the skill. Returns true when that changed anything and false when it was already skipped. The ID must be a whole number above 0, or on Classic 0 for the Basic attack. It doesn't have to be a skill the character has. A bad ID raises an error, and so does calling it before your settings have loaded.
core.farm.unskip_skill(skill_id: number) -> boolean
Available on GMS and CW
Lets Auto Farm use the skill again. Returns true when that changed anything and false when it wasn't skipped. Raises an error in the same cases as skip_skill().
Farm area
Reads and changes the area drawn on a map in the Farm page's Farm area panel, and the grid for maps without one. On a map with a drawn area that is switched on, Auto Farm keeps to it; elsewhere it keeps to the grid picked for every map without one. A change is saved with your settings and shows on the Farm page, and a farm running on that map starts over with the new area.
Edges are map coordinates, the same as player:get_position() and map:get_bounds(): x grows to the right and y grows downward, so top is less than bottom. A map can hold up to 16 boxes, all switched on or off together.
map_id is optional in every call; leave it out, or pass nil, for the map the character is on. Calls that change an area raise an error when map_id is left out while the character is not on a map, or before your settings have loaded. Every call, reads included, raises an error for a map_id that is not a whole number above 0, so pass nil rather than core.farm.status().map_id while that is 0.
core.farm.get_area(map_id?: number) -> table | nil
Available on CW
Returns the map's drawn area, or nil when it has none (also when map_id is left out while the character is not on a map, or before your settings have loaded). An area that is switched off is still returned.
| Field | Type | Description |
|---|---|---|
enabled | boolean | The area is switched on, so Auto Farm keeps to it |
left, top, right, bottom | number | The edges of its first box |
boxes | table | Every box on the map, each with left, top, right and bottom |
core.farm.set_area(left: number, top: number, right: number, bottom: number, map_id?: number)
Available on CW
Draws the map's area as this one box, replacing any boxes drawn there before. A map without an area gets it switched on; a map that had one keeps it switched on or off, as redrawing it on the Farm page does. Edges are rounded to whole pixels and must lie between -1000000 and 1000000, with right greater than left and bottom greater than top; anything else raises an error and changes nothing.
core.farm.set_area_boxes(boxes: table, map_id?: number)
Available on CW
Draws the map's area as these boxes, replacing any drawn there before, and treats on or off the way set_area() does. boxes is a list of 1 to 16 tables with left, top, right and bottom, so the boxes from get_area() can go straight back in. Each box follows the rules of set_area(). Anything else raises an error and changes nothing.
core.farm.set_area_enabled(on: boolean, map_id?: number) -> boolean
Available on CW
Switches the map's area on or off, the same as its Keep to the drawn area switch, and keeps its boxes. Returns false when the map has no area.
core.farm.is_area_enabled(map_id?: number) -> boolean
Available on CW
Returns true when the map has a drawn area and it is switched on.
core.farm.clear_area(map_id?: number) -> boolean
Available on CW
Deletes the map's area, so Auto Farm keeps to the grid there again. Returns false when the map had none.
core.farm.get_grid() -> table | nil
Available on CW
Returns the grid for every map without a drawn area, or nil before your settings have loaded. size is how many rows and columns it has, and cells lists the picked cells, lowest first. A cell's number is row * size + column, with rows and columns counted from 0 at the top left.
core.farm.set_grid(size: number, cells: table)
Available on CW
Sets that grid. size is a whole number from 2 to 12, and cells is a list of cell numbers from 0 to size * size - 1; repeats are dropped. Picking no cells or every cell means the whole map. Anything else raises an error and changes nothing. Raises an error before your settings have loaded.
Options
More of the Farm page's options can be read and changed with core.get_setting() and core.set_setting(). These are on Classic only. A change is saved with your settings, and a running farm starts over to take it.
| Setting | Value | Option |
|---|---|---|
rotation_studio.farm.closest_mob | boolean | Closest Mob First |
rotation_studio.farm.hold_ground | boolean | Hold Ground |
rotation_studio.farm.front_lock | boolean | Front Lock |
rotation_studio.farm.wave_wait | boolean | Wait At Spawn Points |
rotation_studio.farm.loot_priority | 0 Kill Priority, 1 Balanced, 2 Loot Priority | Kills or Loot |
rotation_studio.kite.enabled | boolean | Kite Assist |
rotation_studio.kite.red_zone | 0 to 300 pixels, 0 for Auto | Red Zone |
rotation_studio.kite.back_off | boolean | Back Off |
rotation_studio.kite.step_out_mode | 0 Off, 1 Ranged only, 2 Everyone | Step Out When Surrounded |
rotation_studio.kite.step_out_mobs | 0 to 10, 0 for Auto | Step Out Mobs |
rotation_studio.kite.jump_attacks | 0 Off, 1 Class moves only, 2 Sometimes, 3 Often, 4 Always | Jump Attacks |
rotation_studio.kite.jump_moves | boolean | Melee Jump Moves |
rotation_studio.kite.reaction | 0 Relaxed, 1 Normal, 2 Fast | Reaction Speed |
Example
local was_active = false
function on_tick(stage)
local active = core.farm.is_active()
if active ~= was_active then
was_active = active
core.log(active and "Auto Farm is farming" or ("Auto Farm: " .. core.farm.status().state))
end
endKeep Auto Farm to a box around where the character stands, then go back to the whole map:
local player = core.object_manager.get_local_player()
if player then
local pos = player:get_position()
core.farm.set_area(pos.x - 400, pos.y - 250, pos.x + 400, pos.y + 50)
core.farm.set_area_enabled(true)
local area = core.farm.get_area()
core.log(`farm area ${area.left},${area.top} to ${area.right},${area.bottom}`)
end
-- later
core.farm.clear_area()Walk somewhere with Auto Farm switched on, then let it carry on. If the script stops, Auto Farm takes over again within five seconds:
local target = { x = 1200, y = -85 }
local walking = false
function on_tick(stage)
if not target or not core.farm.hold(5) then
return
end
if not walking then
walking = core.nav.path_to(target.x, target.y)
elseif not core.nav.is_active() then
target = nil
core.farm.release()
end
endHear about the moments that need attention, and how the farm has been going:
function on_farm_state(state, previous)
if state == "dead" or state == "no_attack_key" then
local s = core.farm.status()
core.log_warning(`Auto Farm went from ${previous} to ${state} after ${s.kills} kills, ${s.time.waiting} s of it waiting`)
end
end