Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
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 10

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 NeuroGenix
      Post rewritten after rewritting and updating the code multiple times.
      So I decided to give writing my own GE API a go and this is what I've come up with so far, using Exchange#offer(name, price, quantity, buy) will do the following:
      If the GE is closed, it will open it and continue making the offer. If the price is set to -1 then it will use the buttons to increase or decrease the price, depending on whether it is a buy or sell offer, until it is at a price that will buy/sell instantly. Otherwise it will use the custom input button to set the price. It will set the quantity using the 1/10/100/1000 buttons. I plan on updating this to randomise between using them and the custom input method shortly. Edit* I hadn't even remembered implementing this until I saw it do it whilst testing the method, and it was beautiful, but if it goes over the buy quantity accidently, in the example I saw it was clicking +100 and clicked it again too fast so instead of stopping before its target of 875 it got to 900, it will then use the custom amount interface to input 875, beautiful. It will prioritise buy offers over sell offers so that if there isn't an empty slot available, or any items to collect, then it will cancel a sell offer, collect it and continue now it has a free slot. If there isn't a free slot available and we are trying to sell something it will return true, this is so that in my scripts it will remove the item from a toSell HashMap and put it back into the bank to sell later because it has bought the items it needs to continue botting. If it is instead trying to buy something and there are no empty slots or sell offers to cancel then it will wait for something to buy and continue once it can collect something and therefore has an empty slot. Update* It will now search for the item 1-3 words at a time checking the first 9 results each time and will choose the item as soon as it is visible as a human would. I might update this so that it randomises more, sometimes entering the whole first word of an items name straight away, because I sometimes do that, most of the time though I enter as few characters as I need to, I think, thoughts? Let me know what you think, the code is probably disgusting to look at for some of you but for others just starting out like me it could be a valuable learning tool, for how not to code All feedback and constructive criticism appreciated.
      Exchange Class
      GEInterfaces Class
      GEConditions Class
      InfoHelper Class
      Thank you to everyone that has read this far, it is appreciated
      Rewritten, if you have read again, even more appreciation!
    • 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 Frosty XVII
      Hello everyone,
           I used to bot a lot with Tribot. I've been gone for what feels like well over a year. I just had some questions for my fellow botters and scripters.
       
      What is the botting scene like right now? Last time I left people were just botting throw-aways and still making cash.
      Any new updates to osrs? How has OSRS changed in the past year? I plan on looking over the update logs, but anything cool happen?
      In terms of Tribot, have the devs introduced any cool new technologies? Like a more efficient LG or anything?
       
      Frosty
    • 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 goxdom
      How can I determine if the character is stunned? Any methods out there for this? I'm currently checking something like "currentHP < previousHP" after a certain action but it is not ideal for every occasion.
    • 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)
  • Our picks

    • This release will:

      Fix LG for both OSBuddy and RuneLite


      Fix issue where the resizable client isn't able to be made smaller (Thanks @JoeDezzy1)


      Fix detection of the logout game tab when resizable mode and side panels are enabled (Thanks @JoeDezzy1)


      Add initial support for Sentry to allow us to identify and easily debug exceptions happening with all TRiBot users


      Add methods to determine if the bank is actually loaded, and not just the overarching interface (Thanks @wastedbro)



      Upcoming updates:

      Improved CLI support


      Full Sentry support


      Much more
        • Like
      • 46 replies
    • This release will:

      Fix NPE in Camera API (Thanks @wastedbro)


      Update deposit box interface ids (Thanks @Encoded)


      Add various bank methods (Thanks @wastedbro)


      Banking#getWithdrawXQuantity


      Banking#getDefaultWithdrawQuantity


      Banking#arePlaceholdersOn




      Fix resizeable minimap bug (Thanks @wastedbro)


      Remove Java 8 requirement


      Please note: TRiBot is not yet fully compatible with Java 10+




      Fix the break handler issues by ensuring the break handler thread never gets paused


      Fix broken settings hooks



      Upcoming updates:

      Improved CLI support


      Much more



      Note: If you are using LG, please restart both the RS client and TRiBot
        • Like
      • 68 replies
    • This release will:

      Add support for using custom F key bindings to switch between game tabs (Thanks @erickho123)


      Fix tab opening for "Skills" and "Kourend Tasks" (Thanks @erickho123)



      Note: If you are using LG, please restart both the RS client and TRiBot
        • Like
      • 34 replies
    • This release will:

      Fix an issue where breaks would stop firing


      Fix Combat#getWildernessLevel, use dynamic search for text and cache ID for later calls


      Fix an NPE in the Combat API


      Fix Mouse#leaveGame bug where the mouse wouldn't actually leave the game screen
        • Like
      • 21 replies
    • This release will:

      Add LG support for Runelite


      Fix NPCChat issues


      Fix a bug where the camera angle setter would just hold down a key for 5 seconds (the timeout)


      Slightly adjust the rotation via keys to be more accurate


      Add the ability for asynchronous camera movement via keys


      Make Camera rotation via mouse more fluid, with more antiban, and work much better in resizable mode


      Add a "Camera#setCamera" method, allowing the rotation and angle to be set in parallel


      Increase the likelihood of using the mouse for camera movements


      Add support for adjusting the camera to positionable entities (Positionable#adjustCameraTo)



      Upcoming updates:

      Improved CLI support


      Much more



      Note: If you are using LG, please restart both the RS client and TRiBot
        • Thanks
        • Like
      • 59 replies
  • Recently Browsing   0 members

    No registered users viewing this page.

×