Jump to content

An Introduction to Script Development for TRiBot

Recommended Posts


This tutorial uses Windows 10 and IntelliJ IDEA.


  • Java knowledge equivalent to someone who has passed a college level introductory Java course with complete understanding of the course.
  • Java Development Kit installed.
  • VIP or VIP-Extended on TRiBot (required to run local scripts).


  • Experience with a Java IDE.
  • Experience programming outside of a classroom setting.

Learning Resources

TRiBot Java Documentation



  • Preface
  • Getting Started
    • IntelliJ IDEA Setup
    • Creating Your First Script
    • Uploading to the TRiBot Script Repository
  • Script Design
    • Task
    • Decision Tree
    • Variables and Constants
  • Development Tools
  • Essential Classes and Methods

Getting Started

IntelliJ Idea Setup

Download and install IntelliJ IDEA community edition from JetBrains.com.

If you have never ran the TRiBot client before, do so now and let it load Old School RuneScape all the way up to the login screen. After doing so, I would recommend restarting the TRiBot client, although this is not required.

Create and Setup the IntelliJ Project

On the IntelliJ welcome screen, select Create New Project
If you already have a project open, then select File -> New -> Project…
Select the Java verison or if none are available, press New... and locate the directory in which Java is installed.

Project SDK

Click Next skipping the project template option and you then should come to a window that allows you to set the project name and location.
Set those to whatever you want and then click Finish

Adding TRiBot.jar to Project Libraries

Select File -> Project Structure and in the window that opens select Libraries
Click the green + and select Java.

Add Java Library

You will now need to locate TRiBot’s dependencies folder.
On a standard windows installation, this folder will be located at C:\Users\REPLACE_WITH_YOUR_WINDOWS_USER\AppData\Roaming\.tribot\dependancies Yes, dependancies is mispelled.

TRiBot.jar Dependency

Once you have navigated to the dependancies folder inside IntelliJ, select TRiBot.jar and press OK

Note: AppData is a hidden folder and will not display in IntelliJ’s file explorer. You will need to type in the path at the top of the window for it to show. Do not press enter after typing the path, the file explorer will automatically refresh as you type.

On the next window you should only have one module. Make sure the module is selected and press OK

Configuring Output Path

If you have closed the Project Structure window, reopen it by selecting File -> Project Structure
Navigate to the Modules tab and make sure your only module is selected.
Select the Paths tab and then select the radio button Use module compile output path
Change both the Output path and Test output path to C:\Users\REPLACE_WITH_YOUR_WINDOWS_USER\AppData\Roaming\.tribot\bin\
Click Apply and then OK

Creating Your First Script

All of your classes will need to be in the package scripts
In your src folder, create the package scripts

scripts package

Inside the scripts package, create a new Java Class named HelloWorld


Extend Script and implement the method run
Note: Make sure you import org.tribot.script.Script and not sun.font.Script

Add a ScriptManifest which will provide the TRiBot client information about your script so it can be properly categorized in the script selector.
@ScriptManifest(authors = "Encoded", name = "Hello World", category = "Script Tutorial")

Add println("Hello World"); inside the run method and the basic script skeleton is complete.
println prints to the Client Debug at the bottom of the TRiBot client. This method is inhereted from Script, but an equivalent method can be found in the General class.

Build your project (Build -> Build Project) and then press Start Script in the TRiBot client.
If your script does not show up in the script selector, then you have done something incorrect or you do not have VIP.


package scripts;

import org.tribot.script.Script;
import org.tribot.script.ScriptManifest;

@ScriptManifest(authors = "Encoded", name = "Hello World", category = "Script Tutorial")
public class HelloWorld extends Script {

    public void run() {
        println("Hello World");


Creating Additional Modules

When developing a script that is more than one class file, creating a specific module for that script is highly recommended.
For each additional module, you will need to change the output path like you did above and add the TRiBot.jar library as a module dependency.

Removing RS3 Auto Imports

IntelliJ IDEA will auto import for you. This can lead to unwanted behavior such as importing RS3 classes when you wanted OSRS.
To fix this, go to File -> Settings... -> Editor -> General -> Auto Import
In the Exclude from Import and Completion table, add obforg.tribot.api.rs3, and sun.font.Script

Auto Import

Uploading to the TRiBot Script Repository

To upload to the TRiBot Script Repository, you will need to create a .zip file with your script’s java source files.
The zip file acts as your scripts package.
You will need to keep the same package structure you’re using in IntelliJ. If you have the package scripts.agility you will need to have the agility folder inside in the zip.
As an example using HelloWorld.java from above, create a zip file named HelloWorld.zip and place HelloWorld.javainside.
HelloWorld.zip is now ready to be uploaded to the repository, but please do not upload it in attempt to keep the repository clean of unwanted scripts.

Note: Do not place your compiled class files inside the zip file, only java source files.

Script Design

Two of the most common script design patterns will be covered:

  • Task
  • Decision Tree


The task design pattern consists of a collection of tasks that have a validation and execution method. 
The collection is then iterated over and if a task’s validation method returns true, then the task is executed.
Tasks are typically stored in a Set or a List.
Here is a short tutorial for the Task Framework.

Decision Tree

The decision tree design pattern consists of a manually created decision tree that is traversed using a modified preorder depth-first search until a valid runnable node is found.
Here is a tutorial for the Decision Tree Framework.

Variables and Constants


To manage variables, I use a Vars class. The Vars class will be a singleton. A singleton is not needed, however, when managing a shared resource such as variables, a singleton is preferred. To access a variable, you will call Vars.get().variableName
Note: There might be more proper ways to manage variables, but this has proved to be the most effective for me.

public class Vars {

    private static final Vars instance = new Vars();

    public int variableName;

    public static Vars get() {
        return instance;

    private Vars() {




To store constants, I use a final Constants class. This allows you to static import constants so there is no need to have to reference the class and then the constant.
Note: The Constants class is not a substitution for enums. You should be using enums wherever possible.

public final class Constants {

    public static final int EXAMPLE_CONSTANT = 1;

    private Constants() {



Development Tools

  • TRiBot Debug Options
    • All options listed under the Debug tab in the TRiBot client.
  • Interface Explorer
    • At the top of the TRiBot client, navigate to Tools -> Interface Explorer
  • LAN ScriptTools
    • Contains various tools to aid in script development.
  • Area Creator and VarBit Explorer
    • These tools will either need to be developed yourself or can potentially be found on the TRiBot forums.
  • Java VisualVM
    • Used to monitor CPU and memory usage. Can be found within the JDK installation directory.

Essential Classes and Methods

  • RSArea
    • Should always be used to check if a location is within a area.
  • Clicking
    • Should be used for all clicking that involves an entity to stay consistent.
  • Timing.waitCondition(Condition c, long timeout)
    • Should always be used where applicable.
Edited by Encoded
  • Like 4
  • Thanks 3

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Our picks

    • This release will:

      Fix key event handling issue

      Fix other event handling issue

      Fix RSServer hook

      Update world hopper to have it use OCR, thanks to Todd

      Use proper disposal of old Graphics objects

      Reformat code

      Rearrange code

      Organize code imports

      Apply around 8000 automated code refactorings

      Make preparations for Java 9

      Fix 11 various bugs

      Add more reliable debugging support

      Fix mouseEntered/Exited event dispatching bug

      Fix minimap walking bug where it opens the map

      Fix broken hooks for today's game update
        • Thanks
        • Like
      • 87 replies
    • This update will:

      Fix GE inventory item positioning bug

      Fix broken object hooks
        • Like
      • 27 replies
    • This release will:

      Fix some ClosedChannelException bug

      Fix bug in RSObject#getAllTiles

      Add game tab support for "Kourend Favour"
        • Like
      • 15 replies
    • This release will:

      Fix Settings UI placement bug

      Fix game object location bug

      Fix small layout bug making the client shift up and down

      Fix client crashing bug where loading the client with a small display area will cause the client to crash

      Fix annoying Linux bug relating to painting events and peers

      Fix settings saving bug where settings are saved to disk more often than they should

      Fix RSInterface#isBeingDrawn bug affecting a limited amount of people

      Drop Java 1.7 bytecode version for 1.8

      Important: Since the downloadable RS client uses Java 7, it will no longer be compatible with Looking Glass. To make up for this, we will add support for using other clients such as RuneLite (at a later date).

      This change was necessary to allow us to use Java 8 syntax. It also paves the way for Java 9/10/11 support.
        • Like
      • 40 replies
    • This update will:

      Fix the RSMenuNode bug which also fixes the bug with bank opening

      Fix the incorrect object positions bug

      Fix and re-enable the LG Objects API Accelerator

      Fix the RSObject#getAllTiles bug
        • Like
      • 22 replies
  • Recently Browsing   0 members

    No registered users viewing this page.