Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
testing1

Scripting Guide For completely noob with 0 java knowledge

Recommended Posts

This Tut is going be for ppl how want to start scripting for tribot and dont know where to start and how to start i will be guiding u through the process here and i will make 2 basic scripts a WOODCUTTING  and MINNING Scripts 

**I am not making a video and guiding through this post cause of my accent as Arabic is my first language ..

** Please avoid copy and past to learn somthing ...

First the requirement 1- You will need IDEA I am going use Intellij  

                                       2- You will need to setup tribot with it 

                                        3- You dont need basic java programming to watch this and u will understand it for sure 

so lets Dont make it much longer and lets start :D 

First of all we going use Node Framework thanks to @Worthy

 

so lets just say what is Node framework do:

Basically a Node consists of 2 major parts 1- A validation 

                                                                              2- An Execute 

Just Ignore every thing in that photo it just shows you what dose Node look like  Node.thumb.PNG.b4f9d536d72b0cdeacd932e659f32727.PNG

 

So we have 2 things to go with 1- Validation that what we need the bot to check if it is happening it call the Execute method in that node 

so lets say we need the bot to cut the tree if it is not cutting so we write in the Validation method if not cutting codes and in the execute method of that node cutting tree node 

Now we done with our Framework so lets talk about making our first script^_^ 

The WoodCutting Script:

As i said before u need to have IDE and compiled it with tribot so u should get a screen like this.

FirstStart.thumb.PNG.686c7e930c25a23f9313c545fc7f3e2b.PNG

 

If u have screen like this continue reading if not please figure it first and then continue or comment if u have a problem 

 

Now lets make out Script structure we Right click on our scripts and select new then select Package and name it what u wan your script to be we will name it WoodCutting after that we will find a new folder was created so now we need to add our main class << it is like our script soul >> 

we right click on our script package which we named <WoodCutting> and the choose new then choose Java Class and name it as u like but i like to name it as the package name so i am naming it <WoodCutting> Now u should look like this MainClass.thumb.PNG.5a846423a103e934e19b4ae67de32f02.PNG

if that what u have then u can continue else ask for the problem 

Now we going add our script name and the maker and version and so on this is called script manifestations how we can do this u just type this word in the line before Public class is

@ScriptManifest

 then when u do that there is going be an error so u just use a short cut on Intellij and hit Alt+Enter it will gives u a suggestion on how to over come the error 

then hit enter to choose the first suggestion that should make it like this Manifestation.thumb.PNG.1dc1c636fa7577e9c0b6b698811ec089.PNG

if u cant use the shortcut just write the like as in the picture. 

now we need to author and category and script name so all of those are name we use Strings for that String is worlds we use in English so we use it btween those  " "   So at the author we write "GeniuSKilelr" Category "WoodCutting" Name "GeniusCutter" or change that names as u wan ^_^

 

Now we done with naming now we need to Implements our tribot main method >> Script 

So after the public class Woodcutting we a extends Script 

when u write Script u will find tons of scripts make sure to choose org.tribot.script one 

then u will find there is and error again so we use the same shortcut as before alt+enter then it will says that there is a method that isnt implemented so hit enter to implement it that would be the run method so u should be like this RunMethod.thumb.PNG.b663250d0ef75aa093e2890ed724d1ba.PNG

Again if u have it like this continue if not ask for help 

Now we almost done with our main method i said we going work with node framework before so lets implement it on your script 

 

Now we will create a package for our custom API , and a package to carry our Nodes that is more organized way to write a script 

as said before we will right click on the WoodCutting package we made and click new package and call it API .

once again create new package and call it Nodes to carry our nodes as i said before 

we should end up like this 

Structure.PNG.8abe68ab64fa803373bbdd0588c62fd0.PNG

so now lets make our Node Framework 

Right click our API package and click new Java Class and name it Node

it will be like this Node.thumb.PNG.d27fb32e29bde2007a89fad2ccfe0af6.PNG

now we need to make it abstract so add abstract between public and class 

then write that code Between {  } 

public abstract boolean validate();


public abstract void execute();

 

Now we done with our Node class lets implement it in the main class 

write this code just before the run method we implemented before 

 

public static ArrayList<Node> Nodes = new ArrayList<>();

Again if u had any errors use the shortcut and if u faced any thing that u cant handle ask here for help i will answer assap 

now we implemented our Node framework to the main class now we need to implements the Nodes we will make into our run method so we go to the run method and Write this code in 

Collections.addAll(Nodes);

loop(40, 50); // the time it take to loop the nodes 

now we will find an error again so we use the shortcut to implement the missing method which is the loop 

when we use the short cut this method will be implemented 

private void loop(int i, int i1) {
}

at this method we need to make it loop the nodes we have so we add this code 

    for (final Node node : Nodes) {
        if (node.validate()) {
            node.execute();
            sleep(General.random(50, 60));    //time in between executing nodes
        }
    }
}

so at the end u should be like this 

FinalMainClass.thumb.PNG.d6fa21d2d7d6a14274e1647f6fb864d0.PNG

Now Remember all we have done now that is all u going do for almost every script u going write in Node Framework 

Now we done with structure lets go in coding the WoodCutting Script now ^_^ 

 

Now we writing a simple wood cutting script so we will need 2 thing 2 Nodes i mean 

1- Cutting Node 

2- Dropping Node 

 

Easiest thing first so lets do the Drop node 

so we go to our package called Nodes then right click and make 2 Java Class u should know how to do that by now

the first one lets call Drop and the second one lets call Cut 

now lets open the Drop node and make an extend Node as we made extend script in our main class 

so u should be like this Drop.thumb.PNG.10f8433f575a6687e3580da3b3df26ec.PNG

 

as i said before now we have a validation and execute 

*** return false mean that this node will never be executed 

so we need it to drop all items in inv if the inv is full so we change the false to check if the inv is full 

now we write instead of false >>>  Inventory and we will get a suggestion we must choose the one of tribot  

so now we called our Inventory now lets check if it is full so we continue writing so if we add . after Inventory we going find tons of actions we choose the one we are looking for then hit enter the one is is full so now we should be like this InvFull.thumb.PNG.dd6b374a963fb227a0f6fcc16e26727b.PNG

 

that mean that the bot will keep checking till the Inv is full then it will validate this node and execute what is in this node 

we what we need it to do if the inv is full we need it to drop all inv so we write in execute the code of dropping so we write Inventory.drop();

now we need to get the id or the item to drop  we can do that by having the item in inv then click the debug in tribot then cloose Inventory it will shows all the ids on the inventory so we get the ide and write it between () of the drop  2511 is the id for the logs so now it will drop all the logs so u should be like that DropAlmostDone.thumb.PNG.6319d5928a910c533287d78359dedb95.PNG

But there is 3 thing that may happen that lead to the script breakdown while inv is full 

1- if the inv isnt open so the script will break 

2- when it is going to drop it is going to use right click then drop we dont wan this we wan it shift drop 

3--if the logs is null >>> we need to check for like every thing if  it is not null almost for every thing 

we can check for null by two ways by the length or by not = null 

so now we need to fix those three things 

1- we will make the bot to check if the Inv tab is open or not before dropping 

2- we will make it use shift dropping instead of noraml dropping 

3- we will check if the length is more than 0 before dropping 

so for the first one:

we first call the Inventory tab by writing GameTab.Tabs.Inventory that call the inventory tab

so now we know how to call tabs 

so we write

if (!GameTab.TABS.INVENTORY.isOpen()) {
}

 

that mean if Inv is open but we need it to check if it isnt open so we add ! this mark mean not we always add it at the first 

 

if (!GameTab.TABS.INVENTORY.isOpen()) {
}

 

now we checked if the Inv isnot open then we need it to open theInv 

so between { } we add the code to open the Inv we going call tabs first then call Inv like before but instead of choosing isOpen we going choose Open 

so it is like this 

GameTab.TABS.INVENTORY.open();

 

now we need to give the bot some time to open the Inv so we add a sleep for the script we have two type of sleep static and dynamic we going for static for now so we add 

General.sleep(300,700);

now we  fixed the first problem .

now we need it to use shift dropping the second problem 

first we call Inventory as before then we add . to see all options like before we will choose setDroppingMethod 

it will be like this 

Inventory.setDroppingMethod();

so now between ( ) we add the dropping method we wan it to be 

so it should be like this 

Inventory.setDroppingMethod(Inventory.DROPPING_METHOD.SHIFT);

now we done with the 2nd problem now lets go for the 3rd problem 

the null problem i said i am going to use length to check so we before wrote the dropping code like this 

Inventory.drop(2511);

so we add a length check first before adding this code so we check for hm of logs are there in inv so we add this code 

if (Inventory.getCount(2511)>0) {
    Inventory.drop(2511);
    General.sleep(500, 900);
}

that is like what length checker but i didnt wan to go to arrays and other things at your first tut so lets keep is simple for now 

what that code do is it check for the number of logs if >0 it will start dropping them 

now we done with the dropping node so the final dropping node should be like this DropingNodefull.thumb.PNG.ed764946b74716202d4e4ffa2c81ca47.PNG

 

Now lets start the Cutting Node

lets open the Cutting Node and extend Node as we did for dropping node 

we need it to cut as if the inv isnt full so we change the false to 

!Inventory.isFull()

notice that i add ! before Inventory is full  so it is not inv isnt full 

now lets go for execute 

we need to identify the objects we need to cut <trees>  and put them at a box together [ ] this called array just dont give about it 

so to put that in a box we write that code 

RSObject[] TREE = Objects.findNearest(10,"Tree");

now lets talk about that line 

first we make a box and called TREE >>>>> RSObject[] TREE

then we have put some Trees in the box but we specified the objects we putting there to be near us within 10 tiles and the object have the name "Tree"

as i said at the start names is wrote between " " 

now as we have made a big box that have some trees in  we need to make the bot cut it down as our Inv is not full 

so we going to call the first object < Tree> within the box by this code Tree[0] as the box counting start with 0 then we write . to get the options as we said before the choose Click as we wan it to click the Tree 

when we choose click it should be like this Cut.thumb.PNG.d73b59ea4b7e4dfdda4dd4b03448e8e5.PNG

now it will click the tree but at every time u are writing a script make sure to specify the action u wan it to do so we will change the code to be like this 

TREE[0].click("Chop down");

now i specified the action i wan it to do 

now if we start running the script it will work but there will be 2 problems 

1- it will keep clicking the tree without stopping  even if it is cutting it down we dont wan this we wan it to sleep till it stop cutting 

2- as for the Node i said we need to check for null 

so lets fix the 2 problems 

the first problem is going be fixed by adding a sleep as we did in Drop node and i said there is two type of sleep dynamic and static we used static 

now lets use the better one the dynamic one and lets make it only cut if the player is idling and not animating the idling animation is always -1 

 

waitConditionsleep500;
    return false;
, random4500, 5500;

that is the code for dynamic so what that code mean is it will sleep for a random time from 4.5sec - 5.5 sec >>>General.random(4500, 5500)

unless the return give back true so we need change that false with what we need it to be >>> Player animation is -1 as the player is idling 

so our code should be like this 

Timing.waitCondition(() -> {
    General.sleep(500);
    return Player.getAnimation()==-1;
}, General.random(4500, 5500));

first we called our own player then we add . to see the action then we choosed the animation action then we add == that mean equal then we add -1 as it the idling animation 

so what that mean it mean that the player is going idle for 4.5 to 5.5 sec or if the animation is changed to -1 

so our full code shoule be like this 

RSObject[] TREE = Objects.findNearest(10,"Tree");

TREE[0].click("Chop down");

Timing.waitCondition(() -> {
    General.sleep(500);
    return Player.getAnimation()==-1;
}, General.random(4500, 5500));

that should fix the 1st problem 

lets go for the second problem to check null 

last time we check the length by the count cause we didnt make an array <big box > and now we did here so lets check by length 

so we write this 

if (TREE.length>0) {

    TREE[0].click("Chop down");

    Timing.waitCondition(() -> {
        General.sleep(500);
        return Player.getAnimation() == -1;
    }, General.random(4500, 5500));
}

we add if ( TREE.length >0)  that check if the big box contains at least 1 tree 

so we avoid a null exception error 

now what if the tree is away from us by like 5 tiles it will keep clicking it till it reach it and start animation so we dont wan this so we add 2 fail safes 1 at the waiting condition and the other with the length checker 

so it should be like this 

if (TREE.length>0 && Player.getAnimation()==-1) {

    TREE[0].click("Chop down");

    Timing.waitCondition(() -> {
        General.sleep(500);
        return Player.getAnimation() == -1 && !Player.isMoving();
    }, General.random(4500, 5500));
}

now we add a check that it will never click the tree while it is animating and it will click it once and wait if the tree is away from use cause we add that the player is not moving in the waiting condition too 

 

Now we done with our two nodes lets implement them in the run method 

 

so back to our main class to the run method we will find this code 

Collections.addAll(Nodes);

to add a new node in it u just need to add this 

Collections.addAll(Nodes,new Cut(), new Drop());

Source Code

 

At the end i hope i didnt forgot any thing ^_^ if u leaned any thing please leave a comment waiting the Scripters feedback

This is my first guide ever but will be making alot more soon as i have some free time now after university

next guide will be adding bankNode and Walking Node and alot more soon feel free to ask me any thing peace  

Edited by testing1
  • Like 4

Share this post


Link to post
Share on other sites

I've found original guide for it from Worthy and there are while(true) used inside of loop method, and in this case it works fine. Have you even tried to run your code from github? And ints from loop (20, 40), is later used by Worthy in method loop(int min,  int max) ....... sleep(General.random(min, max));. In your code they're just useless.

Share this post


Link to post
Share on other sites
On 1/13/2020 at 7:19 AM, Revenant said:

I've found original guide for it from Worthy and there are while(true) used inside of loop method, and in this case it works fine. Have you even tried to run your code from github? And ints from loop (20, 40), is later used by Worthy in method loop(int min,  int max) ....... sleep(General.random(min, max));. In your code they're just useless.

about the while i forgot to add and i didnt run the code and i dont get what are u  talking about the ints 20,40 if u read the comments there in the pic u will know what the use of that ints 

Edited by testing1

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Our picks

    • [CONTEST ANNOUNCEMENT] 2019 Botter's Choice Awards
      2019 Botter’s Choice Awards

      To celebrate the launch of our TRiBot Official RuneScape Bot Blog,

      we’re doing a giveaway! 

      The TRiBot Official RuneScape Bot Blog: 

      Teaching you how to do more advanced botting, faster.
      Contest Details

      Prize: 3 winners will be selected to win 25 TRiBot credits.

      How to enter:

      Respond to this forum post by November 12th tagging the thread for: 

      Your favorite script

      Provide a brief explanation (1-2 sentences) why you think that script should be put in the top 5. 

      Who can enter?

      Botter’s who are not currently scripters. Sorry scripters, the people are going to vote. Your contest is here.

      The top 5 in each category will be showcased on our TRiBot Official RuneScape Bot Blog in a “People’s Choice” section and promoted across the TRiBot website. 

      -- Credits will be awarded based on thoughtfulness and humor -- 

      Bonus points

      Use a meme in your explanation. Because we all love memes.

      *no purchase necessary. Winners will be announced on Friday, November 15, 2019 at 4:00 p.m. on our News and Announcements forum. 

      -- Vote Below -- 
        • Like
      • 28 replies
    • [READ TO THE END FOR A TEASER]

      I've noticed some new TRiBotters have had some troubles finding out sources of how to do certain things, such as using advanced scripts and often get lost in the forums.

      We are still getting posts asking where to start, what to do, recommended scripts, etc. 

      As many of you know, I am new to the team, and had troubles myself learning how to bot, let alone script. 

      So, what our team decided to do was make it easier to learn how to bot, how to script, and just become an overall better botter and scripter faster. 

      As some of you might have seen, I've posted 3 new blogs, you can check it out by clicking on the following picture or here.


      These first 3 blogs are the first of many blogs that will be TRiBot official. They are encouraged to be challenged, improved upon and act as A Best Practices Guide for Botters.

      What information would you like to see in the blogs?

      👇 [TEASER] 👇

      .

      .

      .

      We are going to be hosting a  CONTEST  this  OCTOBER.

      Its scary to think how soon you'll find out.👻

      Stay tuned.


      - RileyZ
      • 8 replies
    • Today marks a big day for TRiBot! To make it easier for users to use TRiBot, we've created installers available for every platform! These installers are all bundled with the latest version of OpenJDK 1.8 (Java 😎, which is LG compatible.

      Using TRiBot is now easy. Simply download the installer for your platform, install TRiBot, and run it. The TRiBot Loader will correctly identify the bundled JDK so there's no need to change the Java selection.

      Windows

      EXE installer: TRiBot-windows-x64-4.0.3.exe


      MSI installer: TRiBot-windows-x64-4.0.3.msi


      Portable version: TRiBot-windows-x64-4.0.3.zip


      Mac OS

      Installer: TRiBot-macos-4.0.3.dmg


      Portable version: TRiBot-macos-4.0.3.tgz


      Unix/Linux

      Installer: TRiBot-unix-4.0.3.sh


      RPM installer (CentOS/Fedora): TRiBot-linux-4.0.3.rpm


      DEB installer (Debian): TRiBot-linux-4.0.3.deb


      Portable version: TRiBot-unix-4.0.3.tar.gz


      Platform Independent

      JAR file: tribot-loader-4.0.3.jar


      Note that this jar file does not include the bundled JDK.



      Windows and Mac OS users may notice a warning message stating that the installer/application is un-recognized or un-trusted. Please ignore this message and proceed with running the installer/application. We need to acquire a code signing certificate so that we can sign the installers letting the operating system know that these files can be trusted. It will take a week or more to acquire one, so please hold tight.

      Other notable changes to the TRiBot Loader:

      Support getting the version from OpenJDK distributions


      Add check for bundled JDK


      Copy OpenJDK tools.jar to the bundled JDK if not present


      Set the current java as the first available list entry


      Ignore Java versions which are symbolic links


      Make the bundled JDK the preferred Java version


      Update icon images


      Reduce the number of HTTP calls
        • Thanks
        • Like
      • 24 replies
    • TRiBot is looking to improve a lot of its customer relationship management, customer on boarding process, customer experience, design elements, community engagement and pretty much everything else you can imagine when it comes to marketing.

      Our goal: To ensure that the marketing done TRULY reflects the experience and does not shine an inaccurate light on what TRiBot is lacking in.

      So I ask, what do you love about TRiBot and what do you hate about TRiBot? What does O S Bot, Rune M8, PowR Bot and Dre amBot do better? (yes I purposely didn't spell it right 😂).

      Love, 

      RileyZ
        • Like
      • 18 replies
    • Hello TRiBot,

      Today we have a significant release that has been in the works for the last month addressing several key issues, features and bugs in the backlog.

      With these changes, we are also including a new TRiBot Loader which will allow you to select any version that is released. This adds the flexibility of allowing you to revert to a previous version should an issue arise, run development only builds, view an accurate change log between versions etc. we are very proud to offer this feature and think it will add a lot more functionality down the road as we continue to release new versions.

      These changes include 80+ commits by our development team, a list of them is summarized below and also available for your viewing pleasure in the new TRiBot Loader.

      In addition, we have taken additional steps to improve as a development team by adding continuous integration and deployment into our workflow to assist in delivering timely releases such as bug fixes as well as new features on a weekly basis depending on our development cycle.
        • Thanks
        • Like
      • 39 replies
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...