Jump to content
Sign in to follow this  
Deluxes

Script Debugging Tutorial

Recommended Posts

This tutorial will teach you how to use an IDEs debugging to utilize break points to debug your TRiBot scripts. This tutorial will only show how to do it with Intellij, but that same thing should apply to other IDEs.

Setting up Intellij to run TRiBot

1. We must set up the project dependencies. You can get here by using Ctrl+Alt+Shift+S or going to File -> Project Structure

ncUwxBM.png

 

Once you are here, click on Modules and select the dependencies tab.

UeHQqBY.png

 

Debugging Tribot requires you add the following files to your dependencies.

To add a dependency, click on the green + next to Scope and click JARs or directories.

tools.jar You can find this in your jdk directory.  Example: C:\Program Files (x86)\Java\jdk1.8.0_101\lib

substance.jar You can find this in your %AppData% Tribot location. Example: C:\Users\Your User\AppData\Romaing\.tribot\dependancies

trident.jar You can find this in your %AppData% Tribot location. Example: C:\Users\Your User\AppData\Romaing\.tribot\dependancies

bin You can find this in your %AppData% Tribot location. Example: C:\Users\Your User\AppData\Romaing\.tribot\bin

 

2. We must setup a new Run/Debug Configuration. You can get here by going to Run -> Edit configurations

KhFejKD.png

 

Once you are here, create a new Application configuration by clicking on the green + and clicking Application.

iFaOhvh.png

 

The new configuration will be created and we must edit the settings now. I named my configuration Tribot.

Main class: org.tribot.TRiBot

VM options: -Xmx386m -Xss2m -Dsun.java2d.noddraw=true -XX:CompileThreshold=1500 -Xincgc -XX:+UseConcMarkSweepGC -XX:+UseParNewGC -Xbootclasspath/p:"C:\Users\Spencer\AppData\Roaming\.tribot\dependancies\xboot860.jar" -classpath "C:\Program Files (x86)\Java\jdk1.8.0_101\lib\tools.jar";"C:\Users\Spencer\AppData\Roaming\.tribot\bin";"C:\Users\Spencer\AppData\Roaming\.tribot\dependancies\substance.jar";"C:\Users\Spencer\AppData\Roaming\.tribot\dependancies\trident.jar";"C:\Users\Spencer\AppData\Roaming\.tribot\dependancies\TRiBot.jar";

Make sure to switch out the directories to what they are on your computer.

Program arguments: TRIBOTSESSIONID MEM384 OLDSCHOOL

Replace TRIBOTSESSIONID with your session id. You can find this in %AppData%\.tribot\settings\startup.ini

PLEASE NOTE: if your session id does not start with SID, add it to it.

Example: ccaa-das9fg87ad9fg7a98df7ga98df7g2aead32kjhhj13k

You should place: SIDccaa-das9fg87ad9fg7a98df7ga98df7g2aead32kjhhj13k

Hit apply and you are ready to go.

 

Using breakpoints to debug your script.

Breakpoints are extremely useful for debugging your program. They allow you to stop the program during runtime and see what is happening.

Lets use this simple script as an example.

4LovBOr.png

I'm having an issue. Even though I'm near the Oak Trees my script is not clicking the Cut option. We can debug this by adding a break point and stepping through the script.

To add a breakpoint, you click on the empty area next to the line numbers which will place a red circle. This red circle is a break point. While debugging, any time your script hits said circle, the script will stop and you will be able to interact with it.

VR2HGd2.png

 

Now that I have a break point setup, its time to debug it. We can launch the TRiBot client by going to the Run menu and clicking Run -> Debug 'Tribot'. If this option is not available, you can click Run -> Debug... and select the correct configuration. Once your client has loaded, you can run the script you are debugging.

When a breakpoint is triggered, your script will pause and options will be available within the IDE.

Ffdqdp9.png

A blue line represents the current line you are debugging. You will notice that your client has frozen while you are interacting with a break point. To prevent this, right click on your break point and change Suspend All to Suspend Thread.

3veDyEy.png

Now when you encounter a break point, your client will no longer freeze but you can debug the script. Now about the real problem. Why isn't my script clicking Cut on the oak tree?!?!

Well we have a few options here. We can use some nice features down at the bottom in the debugger.

wRnYLrY.png

QAY9Iug.png will rerun the program. This will close your current client and open a new one.

00D6OC6.png will continue the program until it encounters the next break point.

mOWguAt.png will stop the program, ending your tribot client.

fSxMiMi.png will "step over". This will run the line of code and go to the next one. It will not go into any method calls.

74USdOm.png will "step into". This will run run the line of code, stepping into any method calls that are made.

The reason debugging is extremely useful is you can see in real time what each line of code is doing. In this program, we can "step over" all of our lines, and see the line 17 will gathers all Oak trees in our area. If there is more than 0 Oak trees in the array, it will attempt to click the Cut option on the first one. By repeatedly clicking step over, we can see what happens.

Now why can't it cut the tree??

Lets "step over" so we are on the trees[0].click line.

x68rbLQ.png

If we right click we can see an option that is Evaluate Expression. Click it, or press Alt-F8.

rUfFIB1.png

 

This will bring up a new window that looks like this.

cSsgbl5.png

 

This allows us to run code that doesn't even exist in the script!!!

Lets try running

trees[0]

and pressing Evaluate.

YXcLiEW.png

We will see some stuff that doesn't really make sense, but at least we know that there is a tree that we can click on.

By typing a

.

on that line, intellisense will prompt us with valid things we can type. Lets look into the objects definition. We can do this by typing

trees[0].getDefinition()

Well, that brings up some more values that don't really make sense for us. By looking at the Tribot API or even typing another . to see what are valid things we can type we can see that 

trees[0].getDefinition().getActions()

is valid. Lets try that.

wfZGmfN.png

Hmm, it tells us that Chop down and hidden are valid options for interacting with this tree. I think I found my issue. Cut is not valid and Chop down is.

lcJ417h.png

By evaluating this, the result is true, and in the TRiBot client, the bot successfully clicked on the tree!!

 

This is just a small introduction on what you can do with debugging. For more information on what you can do while debugging, consider consulting google.com.

  • Like 8

Share this post


Link to post
Share on other sites

This is what I ended up for using for Debian 8.

 

-Xmx1048m
-Xss2m
-Dsun.java2d.noddraw=true
-XX:CompileThreshold=1500
-Xincgc
-XX:+UseConcMarkSweepGC
-XX:+UseParNewGC
-Xbootclasspath/p:"/home/<user>/.tribot/dependancies/xboot860.jar"
-classpath
"/usr/lib/jvm/java-8-oracle/lib/tools.jar:/home/<user>/.tribot/bin:/home/<user>/.tribot/dependancies/substance.jar:/home/<user>/.tribot/dependancies/trident.jar:/tmp/tribot_6231ebe5d6.jar

Share this post


Link to post
Share on other sites
Quote

VM options: -Xmx386m -Xss2m -Dsun.java2d.noddraw=true -XX:CompileThreshold=1500 -Xincgc -XX:+UseConcMarkSweepGC -XX:+UseParNewGC -Xbootclasspath/p:"C:\Users\Spencer\AppData\Roaming\.tribot\dependancies\xboot860.jar" -classpath "C:\Program Files (x86)\Java\jdk1.8.0_101\lib\tools.jar";"C:\Users\Spencer\AppData\Roaming\.tribot\bin";"C:\Users\Spencer\AppData\Roaming\.tribot\dependancies\substance.jar";"C:\Users\Spencer\AppData\Roaming\.tribot\dependancies\trident.jar";"C:\Users\Spencer\AppData\Roaming\.tribot\dependancies\TRiBot.jar";

Is it possible to load client with specified proxy from VM options?

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
Sign in to follow this  

  • Similar Content

    • By zoxind
      I've written my first, I would say for now basic script for combat training. 
      One of the main reasons why I chose to use Tribot is because of abc2. But while reading the post on the tutorial on how to implement it in your own code (
      ) I didn't really understand the method(the way) on how to implement it in code. 
      Could anyone please send me a personal message with an explanation on how to implement it correctly, or write a reply here.
      It would be very nice, if you would include an actual code example of it, that would help me to understand it better.
      Thank you in advance.
    • By JordiLaFjord
      Hey.
      Just trying to right click make all on the gold bracelet interface. Most recent thing i've trid is getting the RSInterfaceChild braceInterface = Interfaces.get(446,47); then calling it as braceInterface.click("Make-All");
      I've tried a few other things from the forum that I can't thing of atm, so any help would be appreciated.
    • By odisey
      Hi,
      I recently got back to Runescape because I was playing with opencv. At first, I wanted to create my own bot (something simple ) but I was amazed by the amount of work that went into Tribot antiban so I decided that I would write some scripts here.

      I used to bot on the powerbot website before 2013 and got really close to max cape back then. I had like 5 skills left.

      It could be fun to give something back to the community that created my main account that is not banned until this day.

      I have some questions if there is anyone who would make time for me.

      1) Could you please share links with some up to date comprehensive tutorial how to write a bot? I don't really code in java but the syntax is quite similar to other languages. However, it would be cool to read some tutorial for an advanced script (something more complicated than clicking tree and dropping logs) so that I could get a better feeling of a file structure, GUI, antiban and decision tree.

      2) Is Tribot color bot? How detectable is the client? I saw that you have something like looking glass? That looks really cool but on the other hand, I saw some scripts working with item ids. Do you detect items on screen or do you read environment information from computer memory?

      3) Are private scripts less detectable than public scripts?
    • By Forsteen
      Hey,
       
      I'm making my own script and I want to check if there are any players within a certain range of me. I'm hoping this can be done using the Players part of api2007, using something like getAll() with a filter. The problem is, I don't know anything about filters, and I can't find any documentation of it except a post here on tribot explaining the concept, not how to actually use them. Could anyone either explain how to use filters or link me something which I can learn from? That would truly be great.
      EDIT - I just found the page specific to Filters.Players. This seems good enough for me to figure out.
      Thanks!
    • By Trauken
      Hi,
       
      I have some java experience and figured I wanted to have a go at  creating my own script, so I looked at the "Scripting Tutorial" by Trilez, and everything makes sense to me, but as I try to import the org.tribot.script.Script i get an error... I've read through the beginning of the tutorial but I really can't find what I'm doing wrong, is it possible that the tutorial is outdated and that I should import something else?
      Thanks!
    • By Xenare
      I started scripting yesterday and wanted to share a basic snippet from the Movement class I have been working on, hopefully it could be useful to anybody starting out and it gives me a chance to get any criticism and possible improvements.
      //Walk to random location near destination by radius static public boolean generateWalkPathArea(Positionable end, boolean object_adjacent, int radius) { DPathNavigator nav = new DPathNavigator(); //Return walkable tiles in given area RSTile[] walkableTiles = getWalkableTiles(new RSArea(end, radius)); if (walkableTiles.length == 0 || walkableTiles == null) return false; //Generate path to one of the walkable tiles RSTile[] path = nav.findPath(walkableTiles[General.random(0, walkableTiles.length - 1)]); //Checks path exists if(isPathWalkable(path)) { //Send path to the Painter Paint.path = path; //Traverse path until within proximity or timeout if (nav.traverse(path[path.length - 1])) return Timing.waitCondition(new Condition() { @Override public boolean active() { General.sleep(General.random(25, 50)); return proximityOfDestination(path[0]) < 4; } }, General.randomLong(2500, 3000)); } return false; } //Return distance between player and destination static public int proximityOfDestination(Positionable destination) { return Player.getPosition().distanceTo(destination); } //Return walkable tiles in given area static public RSTile[] getWalkableTiles(RSArea area) { ArrayList<RSTile> walkableTiles = new ArrayList<RSTile>(); //If tile is walkable add to ArrayList for (RSTile tile : area.getAllTiles()) { if (PathFinding.isTileWalkable(tile)) walkableTiles.add(tile); } return walkableTiles.toArray(new RSTile[walkableTiles.size()]); } I have noticed some odd behaviour with DPathNavigator and do not wish delegate short distance movement to Dax's WebWalker which would introduce another unnecessaryfail point to any scripts, because of this I imagine I will be writing my own short distance movement class in the future and some improvements on the above code would be awesome.
      Cheers and hope this is useful to someone.
    • By Kongenm8
      Hi guys
      These last couple of days I've been struggling to see what I'm doing wrong in my waitCondition, the problem is that I get an ArrayIndexOutOfBounds exception, however I dont understand why it appears, if i have the following waitCondition? Shouldn't the waitCondition only return true if trees[0].isOnScreen(); becomes true (That a tree appears on the screen)? And if that case, shouldn't it just continue?
      final RSObject[] trees = Objects.findNearest(20,                 Filters.Objects.nameEquals(gui.comboBox.getSelectedItem().toString()));         if (!isCutting()) {             Timing.waitCondition(new Condition() {                 @Override                 public boolean active() {                     return trees[0].isOnScreen();                 }             }, General.random(2500, 4000));         } EDIT: Edited the active method to match what I had when the error occured (I'm currently trying what I had posted at first)
    • By Kongenm8
      Hi
      Is there a way that i can make my .class files automatically appear in the bin folder upon save? Right now, everytime i open tribot, it creates a new "Bin" folder, and a "Bin1" folder, for my eclipse project, so I manually have to copy paste the compiled .class files to the tribot "bin" folder.. 
      Sincerely
  • 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.

×