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.

First Script, Poor Scripting, Running Slowly

Featured Replies

Hi, this is my first post. I've had no experience with coding but I gave it a go. I tried to write a script that works in my logic, and it does, kinda. I know that it is messy. I'm looking for guidance on how to improve the script because the main reason being after about 5 seconds of it loading it starts to lag a whole lot from a certain point.

package FisherPack;

import java.awt.Graphics2D;

import org.osbot.rs07.api.map.Position;
import org.osbot.rs07.script.Script;
import org.osbot.rs07.script.ScriptManifest;

@ScriptManifest(author = "Cal", info = "fisher", name = "Fisher", version = 0, logo = "")
public class CalsFish extends Script {
    
    private int animateChange;
    private int getNet;
    @Override
    public void onStart() {
        animateChange = 0;
        log("Let's get started!");
    }

    @Override
    public int onLoop() throws InterruptedException {
        
//////////////////////////////////////////////////////////////////////////////////////////////////////////
        if (getInventory().contains("Small fishing net")) {
            getNet = 2;
        }
        if (inventory.isEmpty()) {
            animateChange = 10;
            getNet = 1;
        }
        
        while (((getInventory().contains("Raw shrimps")) || (getInventory().contains("Raw anchovies"))) && (animateChange == 0)){
            objects.closest("Cooking range").interact("Cook");
            sleep(2000);
            widgets.interact(270, 14, "Cook");
            
            if (myPlayer().isAnimating()) {
                animateChange = animateChange + 1;
                log(animateChange);
                log("animate Change");                   //Sees if any raw anch or shrimp and cooks them
            }
            if (!myPlayer().isAnimating()) {
                animateChange = 0;                       //ill need to put this at end also
                sleep(100);
            }
        }
///////////////////////////////////////////////////////////////////////////////////////////////////////////////    
        if ((getInventory().contains("Shrimps")) || (getInventory().contains("Anchovies"))){
            if ((!getInventory().contains("Raw shrimps")) || (!getInventory().contains("Raw anchovies"))){                
            }    
            walking.webWalk(new Position(3208,3218,2));
            sleep(random(100,500));
            objects.closest("Bank booth").interact("Bank");
            sleep(random(991,2873));                                  //when cook complete go and bank all
            widgets.interact(12, 42, "Deposit inventory");
            sleep(random(798,981));
        }
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////        
        if (getNet == 1) {
            walking.webWalk(new Position(3208,3218,2));
            sleep(random(100,500));                           //walk to bank for net if none
            objects.closest("Bank booth").interact("Bank");
            sleep(random(1289,2101));
            bank.withdraw("Small fishing net", 1);
            sleep(random(867,1245));                         
            walking.webWalk(new Position(3242,3154,0));
            sleep(random(100,498));
            getNet = 0;
        }
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
        bank.withdraw("Small fishing net", 1);
        sleep(random(867,1245));                                     //withdraw net
        walking.webWalk(new Position(3242,3154,0));
        sleep(random(100,498));
///////////////////////////////////////////////////////////////////////////////////////////////////////////
        //fishing begins here
        if (getNet == 2) {
            walking.webWalk(new Position(3241,3152,0));        //if start with fish net
            sleep(random(809,1109));    
            getNet = 0;
        }
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
        npcs.closest(1530).interact("Net");
        sleep(random(2003,3001));
        while (myPlayer().isAnimating()){
            sleep(random(3506,5007));
        }
        if ((!myPlayer().isAnimating()) && (!inventory.isFull())) {
            npcs.closest(1530).interact("Net");
        }
        
        
/////////////////////////////////////////////////////////////////////////////////////////////////////////////        
            return random(500, 1000);
            }

    @Override
    public void onExit() {
        log("Thanks for running my Tree Cutter!");
    }

    @Override
    public void onPaint(Graphics2D g) {

    }

}

  • 2 weeks later...

Breaking your above code out into functions will allow for ease and better coding practise..

Also get rid of your "sleep"s & "while"s and look into conditional sleeps, feel free to add me on discord :)
 

"Thanks for running my Tree Cutter!"
what tutorial did you pull this from... 😁

 

^^this guys spot on

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.