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.

Won't run

Featured Replies

I finished my script but when I try to run it, it simply won't run. In eclipse everything looks fine, but I guess there is some problem with the code that I can't understand.

 

package miner;
import org.osbot.rs07.api.map.Area;
import org.osbot.rs07.api.map.Position;
import org.osbot.rs07.api.model.Entity;
import org.osbot.rs07.api.ui.Skill;
import org.osbot.rs07.script.Script;
import org.osbot.rs07.script.ScriptManifest;
@ScriptManifest(author = "Mex", info = "mi", logo = "mx", name = "Miner", version = 0)
 
public class miner extends Script {
 Entity iron = objects.closest(7488, 7455);
 Entity tin = objects.closest(7486, 7485);
 Entity bankbooth = objects.closest(7409, 7478);
 final Area BANK_AREA = new Area(3250, 3423, 3257, 3420);
 final Area MINING_AREA = new Area(3282, 3371, 3290, 3361);
 Position player = myPlayer().getPosition();
 

public void onStart() {
 log("Script started");
}
 private enum State {
  MINEIRON, BANK, WALKBANK, WALKMINE, MINETIN, WAIT
 }
 private State getState() {
  if (MINING_AREA.contains(player) && skills.getStatic(Skill.MINING) >= 15)
   return State.MINEIRON;
  if (MINING_AREA.contains(player) && skills.getStatic(Skill.MINING) < 15)
   return State.MINETIN;
  if (getInventory().isFull()&& !BANK_AREA.contains(player))
   return State.WALKBANK;
  if (!getInventory().isFull() && !MINING_AREA.contains(player))
   return State.WALKMINE;
  if (BANK_AREA.contains(player)&& getInventory().isFull())
   return State.BANK;
  
  return State.WAIT;
  
 }
 @@Override
 public int onLoop() throws InterruptedException {
  switch (getState()) {
  case MINETIN:
   if (tin != null && !myPlayer().isAnimating() && !myPlayer().isMoving()) {
    tin.interact("Mine");
    sleep(random(300, 600));
   }
   break;
  case MINEIRON:
   if (iron != null && !myPlayer().isAnimating() && !myPlayer().isMoving()) {
    iron.interact("Mine");
    sleep(random(300, 600));
   }
   break;
  
  case BANK:
   if (getBank().isOpen()) {
    bank.depositAllExcept("Bronze pickaxe", "Iron pickaxe", "Black pickaxe", "Mithril pickaxe",
      "Adamant pickaxe", "Rune pickaxe");
   } else {
    if (bankbooth != null) {
     if (bankbooth.isVisible()) {
      bankbooth.interact("Bank");
      sleep(random(1500, 2500));
     }
    }
   }
 break;
 
  case WALKBANK:
   walking.walk(BANK_AREA);
   break;
   
  case WALKMINE:
   walking.walk(MINING_AREA);
 
  break;
 }
  return 0;
 }
 public void onExit() {
log("Thanks for using this script");
 }
}

 

 

Its because you've defined entities before the script has started

 Entity iron = objects.closest(7488, 7455);
 Entity tin = objects.closest(7486, 7485);

define these somewhere else, like in your mine tin & iron cases.

 

EDIT, didnt notice the bank booth object. Feel free to ignore this as its your script, but you don't actually need to define a bank booth entity.

 

If a bank is in range, all you have to write is:

bank.open();

or

getBank().open();

You can use these instead of your "bankbooth.interact();" stuff. And for checking if bank is null can be done like so:

if(getBank() != null) {
     // do stuff
}

Hope you don't mind me commenting on stuff about your script, feel free to ignore me.  Do you want more advice or? 

Edited by PlagueDoctor

  • Author

Thanks for the advice, I will do some changes.

Also as a last piece of advice, look up conditional sleeps.

 

Rather than having a random sleep time say, after you interact with the iron, you could use a conditional sleep so it sleeps until your player is interacting with the rock.

 

In combination with this you would also want to include somewhere in the script that if your player is already interacting, the script shouldn't do anything.. I'll let you sort that out yourself if you decide to. 

 

The conditional sleep can be written like so.. 

iron.interact();
new ConditionalSleep(10000) { // 10000 is the time it sleeps before it tries to interact again if you're still not.
   @[member='Override']

   public boolean condition() throws InterruptedException {
         return myPlayer().getInteracting(); // The condition you want to check, this line means.. my player is interacting.
         }
    }.sleep();

Edited by PlagueDoctor

  • Author

It works perfect now, I will look in to the conditional sleep when i get home, thanks again!

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.