Jump to content

A Beginners Guide to Writing OSBot Scripts (where to get started!) by Apaec


Apaec

Recommended Posts

Man, hey! i got a problem i use this

 

 

import org.osbot.rs07.api.model.Entity;
import org.osbot.rs07.script.Script;
import org.osbot.rs07.script.ScriptManifest;
 
 
import java.awt.*;
 
@ScriptManifest(author = "Vacalao", info = "My first mining script", name = "MiningBankVarrock", version = 1.0, logo = "")
public class Main extends Script {
 private static final int rock_id = 14864;
   private static final int ore_id = 438;
 
    @Override
    public void onStart() {
        log("lets try");
    }
 
    @Override
    public int onLoop() throws InterruptedException {
        if(!myPlayer().isAnimating()){
            if(inventory.isFull()){
                inventory.dropAll(ore_id);
            }
            Entity rocks = objects.closest(rock_id);
            if(rocks != null){
                rocks.interact("Mine Rock");
                sleep(random(25, 30));
            }
        }
        return random(200, 300);
    }
 
    @Override
    public void onExit() {
        log("Thanks for test my script");
    }
 
    @Override
    public void onPaint(Graphics2D g) {
 
    }
 
}
 
 
Obviously i will put the iron value on the ores.. but when i compile all see good, but when i try run in my osbot the script no appear on local scripts, why? 
Link to comment
Share on other sites

 

Man, hey! i got a problem i use this

 

 

import org.osbot.rs07.api.model.Entity;
import org.osbot.rs07.script.Script;
import org.osbot.rs07.script.ScriptManifest;
 
 
import java.awt.*;
 
@ScriptManifest(author = "Vacalao", info = "My first mining script", name = "MiningBankVarrock", version = 1.0, logo = "")
public class Main extends Script {
 private static final int rock_id = 14864;
   private static final int ore_id = 438;
 
    @Override
    public void onStart() {
        log("lets try");
    }
 
    @Override
    public int onLoop() throws InterruptedException {
        if(!myPlayer().isAnimating()){
            if(inventory.isFull()){
                inventory.dropAll(ore_id);
            }
            Entity rocks = objects.closest(rock_id);
            if(rocks != null){
                rocks.interact("Mine Rock");
                sleep(random(25, 30));
            }
        }
        return random(200, 300);
    }
 
    @Override
    public void onExit() {
        log("Thanks for test my script");
    }
 
    @Override
    public void onPaint(Graphics2D g) {
 
    }
 
}
 
 
Obviously i will put the iron value on the ores.. but when i compile all see good, but when i try run in my osbot the script no appear on local scripts, why? 

 

 

Do you have any other local scripts?

 

What you should do is close OSBot and delete (or move) your other local scripts (and delete this one). Then reboot your OSBot, and then compile the code. It should then show up

 

apa

Link to comment
Share on other sites

2.3.117

now i donwload the 119 OSbot, and running the 119 i can see you teaThiever but no my script, i am doing any barely wrong?

tired :/ cant do any, i just will buy scripts, cant make

Don't give up so easily, if you can see the thiever but not ur script then I have no idea...

are u sure that there are no errors? everything in ur script looks okay...

apa

Link to comment
Share on other sites

private State getState() {
        Entity stall = objects.closest("Tea stall");
        if (!inventory.isEmpty())
            return State.DROP;
        if (stall != null)
            return State.STEAL;
        return State.WAIT;
    }

is it really necessary here define the stall again?  because you dont seem to need it in this block of code and u define it in your onloop or am i wrong here? 

 

nvm figured it out

Edited by amoeder
Link to comment
Share on other sites

Can someone give me some directions on how to make a simple bone grabber and banker? (port sarim, seagulls)

 

Follow the framework I have for the tea thiever.

 

But you're going to need different states:

 

BANK, GRAB

 

the grab state would have a check for bones:

 

GroundItem bone = groundItems.closest("Bones");

if (bone != null && bone.exists()) {

bone.interact("Take");

}

 

The other state would be bank

define bank the same way as stall, and interact wtih it the same way. Take a look at the banking API to see the interactinos :)

 

apa

Link to comment
Share on other sites

Awesome guide, would making a yew chopper be the same sort of idea? Except states would be CHOP, BANK and WAIT. I've spent a lot of time using actionscript 2 in flash, could never be bothered to use java for rsbots. You made all the hard parts seem so simple though so I might try it out smile.png

 

Yep. exactly the same idea except you may need walking states aswell (eg to and from). You could equally condense it into 1 state but then you're not making full use of the framework available :D

 

Ye it's really not as complicated as you may first think. Deffo worth a try and hopefully you'll be able to pull off some nice scripts :)

 

apa

 

i dont understand how i get the codes i want to make chop& dropper i didnt seee how u got ur script coding thing there?

 

Open the spoilers stage by stage and it will talk you through it!

 

apa

Link to comment
Share on other sites

Yep. exactly the same idea except you may need walking states aswell (eg to and from). You could equally condense it into 1 state but then you're not making full use of the framework available biggrin.png

 

Ye it's really not as complicated as you may first think. Deffo worth a try and hopefully you'll be able to pull off some nice scripts smile.png

 

apa

 

Do I need to set my own path (tiles and such) or is there some sort of API that has easy bank methods there?

Link to comment
Share on other sites

Do I need to set my own path (tiles and such) or is there some sort of API that has easy bank methods there?

 

 

in terms of pathwalking, you'll have to record your own path (you can use divine's utility on the sdn to do this, i've heard it's good :)

with the pre-recorded path (as a Position[]), you can use localwalker to walk it:

 

localWalker.walkPath(Position[] path);

 

and that will get you from A to B.

 

As for banking, you can use the fruitful banking API which will allow you to open the closest bank provided you're close enough, as well as allow you to withdraw, deposit etc 

 

eg

 

bank.depositAll()

deposits your inventory.

 

apa

Link to comment
Share on other sites

  • Alek unpinned this topic

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.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...