Manual › Script template
Build a bot in its own repository
Compiles against @rs2b0t/api and loads into the client by
URL. Forking rs2b0t is not required.
Build it #
- Copy this directory somewhere and rename it.
- Repoint the
@rs2b0t/apidependency inpackage.json. It is afile:link topackages/rs2b0t-api/and resolves only inside this repo. - Edit
src/ExampleBot.ts. - Run
bun install. - Run
bun run buildto producedist/bot.js. Usebun run watchto rebuild on change.
Load it #
- Serve
dist/bot.jsover HTTP. - Open the client's script panel.
- Choose Load URL and give it the address of
dist/bot.js.
Default-export a defineBot({...}) call from the bundle. The registry loads that export
and nothing else.
Read the example #
src/ExampleBot.ts is BoneBurier: it picks up bones near its start tile and buries
them. It shows how to extend LoopingBot, wait for the world with
Execution.delayUntil(() => Game.ingame(), 0), query with
GroundItems.query().name('Bones').within(10).nearest(), confirm an action landed by
watching game state instead of assuming a click worked, and subscribe to skill.xp and
inventory.changed in onStart.
The shim wraps the ABI the client installs at globalThis.__rs2b0t. It throws when
loaded outside the bot client, and when the client's ABI version disagrees with the
shim's.
See also #
- Write a bot, the same example annotated
- Scripting API, the complete surface
- Running locally, getting a client up to load this into
- Manual index