Jump to content
View in the app

A better way to browse. Learn more.

OSBot :: 2007 OSRS Botting

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Does this code make sense/will it work in the long run?

Featured Replies

  • Author

I think I understand the difference between both your codes, correct me if I'm wrong:

@TheMcPker Yours would function great in a script like crafting dragon hide armour, for example. I would have only 1 code for the whole script, and then the initial dialogue would let me choose which d-hide to use, for example, saving me a lot of work and making the code cleaner?

@Camaro Would work for a tasking system where I do different tasks like fletching darts vs fletching bows, but with some elements being the same (such as banking, dropping, etc) that I could just loop back instead of having to recode it?

Is that it? :) 

Just now, Camaro said:

What I put is perfectly fine for someone who is beginning to learn how to do different tasks in the same script. Its the 'state' style. Whats so bad about it for a beginner?

read the title than answer me is the code you made clean or good for long run? my code is simpel and operates in the same way your code does but in a more clean/easy to increase way. if your helping a beginner maybe you'd wanna focus on giving a good example rather than give a mess of useless methods and if/else statements. both can be done without making the code over complex.

13 minutes ago, Lol_marcus said:

I think I understand the difference between both your codes, correct me if I'm wrong:

@TheMcPker Yours would function great in a script like crafting dragon hide armour, for example. I would have only 1 code for the whole script, and then the initial dialogue would let me choose which d-hide to use, for example, saving me a lot of work and making the code cleaner?

@Camaro Would work for a tasking system where I do different tasks like fletching darts vs fletching bows, but with some elements being the same (such as banking, dropping, etc) that I could just loop back instead of having to recode it?

Is that it? :) 

please take a look at this example:

and tell me if something is unclear

Area bank;
@Override
    public void onStart() throws InterruptedException {

        String userOptions[] = {"Varrock", "Falador", "Edgeville"};
        String userChoice = ""+(String)JOptionPane.showInputDialog(null, "Choose a location", "Bank Walker", JOptionPane.PLAIN_MESSAGE, null, userOptions, userOptions[1]);
        String taskOptions[] = {"fletch", "craft"};
        String task = ""+(String)JOptionPane.showInputDialog(null, "Choose a action", "Bank Walker", JOptionPane.PLAIN_MESSAGE, null, actionOptions, actionOptions[1]);
        
        //we set the Area bank varible to the bank we want to use later on to be used in the WalkBank method;
        switch(userChoice) {
           case "Varrock":
            bank = Banks.FALADOR_WEST;
        break;
        case "Falador":
           bank = Banks.FALADOR_WEST;
        break;
        case "Edgeville":
           bank = Banks.GRAND_EXCHANGE;
        break;
    }
    combat.toggleAutoRetaliate(false);
    }
    
    @Override
    public int onLoop() throws InterruptedException {
        //only actives the task if the WalkBank method returned true (so the player is at the bank)
        if(WalkBank) {
            //based on the task we do something diffrent so if task = fletch then it activates the method you have in the return statement (uses return so you return diffrent int values)
            switch(task) {
            case "fletch":
                return Fletch();
            case "craft":
                return Craft();
            }
        }
        //if walk bank fails it will try again in 700 ms
        return 700;
    }
    
    public int Craft() {
        //code for crafting
        
        //if you'd want to fletching if something happens example run out of supplies you could use task = "fletch"; at what ever point in code here 
        
        //the amount you return here will count as sleep for x ms
        return 100;
    }
    
    public int Fletch() {
        //code for fletching
        
        //if you'd want to crafting if something happens example run out of supplies you could use task = "craft"; at what ever point in code here 
        
        //the amount you return here will count as sleep for x ms
        return 100;
    }
    
    //returns true if at the bank if its not at the bank it will try walk there and return false in the method in the onloop
    public boolean WalkBank() {
        if (bank.contains(myPosition())) {
            return true;
        } else {
            getWalking().webWalk(bank);
            return false;
        }
    }

 

this can be used to support big scripts if you'd have a wcing script you can have tasks: woodcutting/walk bank/bank/walk trees

in woodcutting you would put task = "walk bank" after your inventory is full making the script swap to the task walk bank.

then in walk bank you would instead of return true have task = "bank"

then in that task if you inventory is empty (or only axe in inventory remains) you would use task = "walk trees" ect that way you can create a logical flow in your script and have many diffrent actions most often in a setup like this you would have the task preset to 1 of the tasks so the script starts at task a and from there on just goes though all tasks and repeat i know it can be a tiny bit complex but the code above with the explanation should give you some of the groundwork to write a clean wcing script or any other script of the sorts

Edited by TheMcPker

  • Author
15 minutes ago, TheMcPker said:

please take a look at this example:

and tell me if something is unclear

Area bank;
@Override
    public void onStart() throws InterruptedException {

        String userOptions[] = {"Varrock", "Falador", "Edgeville"};
        String userChoice = ""+(String)JOptionPane.showInputDialog(null, "Choose a location", "Bank Walker", JOptionPane.PLAIN_MESSAGE, null, userOptions, userOptions[1]);
        String taskOptions[] = {"fletch", "craft"};
        String task = ""+(String)JOptionPane.showInputDialog(null, "Choose a action", "Bank Walker", JOptionPane.PLAIN_MESSAGE, null, actionOptions, actionOptions[1]);
        
        //we set the Area bank varible to the bank we want to use later on to be used in the WalkBank method;
        switch(userChoice) {
           case "Varrock":
            bank = Banks.FALADOR_WEST;
        break;
        case "Falador":
           bank = Banks.FALADOR_WEST;
        break;
        case "Edgeville":
           bank = Banks.GRAND_EXCHANGE;
        break;
    }
    combat.toggleAutoRetaliate(false);
    }
    
    @Override
    public int onLoop() throws InterruptedException {
        //only actives the task if the WalkBank method returned true (so the player is at the bank)
        if(WalkBank) {
            //based on the task we do something diffrent so if task = fletch then it activates the method you have in the return statement (uses return so you return diffrent int values)
            switch(task) {
            case "fletch":
                return Fletch();
            case "craft":
                return Craft();
            }
        }
        //if walk bank fails it will try again in 700 ms
        return 700;
    }
    
    public int Craft() {
        //code for crafting
        
        //if you'd want to fletching if something happens example run out of supplies you could use task = "fletch"; at what ever point in code here 
        
        //the amount you return here will count as sleep for x ms
        return 100;
    }
    
    public int Fletch() {
        //code for fletching
        
        //if you'd want to crafting if something happens example run out of supplies you could use task = "craft"; at what ever point in code here 
        
        //the amount you return here will count as sleep for x ms
        return 100;
    }
    
    //returns true if at the bank if its not at the bank it will try walk there and return false in the method in the onloop
    public boolean WalkBank() {
        if (bank.contains(myPosition())) {
            return true;
        } else {
            getWalking().webWalk(bank);
            return false;
        }
    }

 

this can be used to support big scripts if you'd have a wcing script you can have tasks: woodcutting/walk bank/bank/walk trees

in woodcutting you would put task = "walk bank" after your inventory is full making the script swap to the task walk bank.

then in walk bank you would instead of return true have task = "bank"

then in that task if you inventory is empty (or only axe in inventory remains) you would use task = "walk trees" ect that way you can create a logical flow in your script and have many diffrent actions most often in a setup like this you would have the task preset to 1 of the tasks so the script starts at task a and from there on just goes though all tasks and repeat i know it can be a tiny bit complex but the code above with the explanation should give you some of the groundwork to write a clean wcing script or any other script of the sorts

I think I understand it all. I'll have to keep practicing new and more complex things little by little. The next script for sure I'll try implementing some tasking. :) Thanks for all the input.

1 minute ago, Lol_marcus said:

I think I understand it all. I'll have to keep practicing new and more complex things little by little. The next script for sure I'll try implementing some tasking. :) Thanks for all the input.

np happy to help if you ever need help feel free to contact me on my discord themcpker#8210

Create an account or sign in to comment

Recently Browsing 0

  • No registered users viewing this page.

Account

Navigation

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.