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.

How do I stop/prevent an action?

Featured Replies

I'm trying to write a script for myself so I can craft green dragon hide body armour.
So far it works fine, but there's one issue with the script.
Sometimes after clicking "make all" it uses the needle with the green dragonhide leather so the widget pops up again. 
This happens randomly and even after I don't have enough green dragon leather in my inventory left it still does it once. 
Can someone help me out? 

package fckcruz.test1;

import java.awt.Color;
import java.awt.Graphics2D;

import org.osbot.rs07.api.ui.RS2Widget;
import org.osbot.rs07.script.Script;
import org.osbot.rs07.script.ScriptManifest;
@ScriptManifest(author = "fckcruz", info = "", logo = "", name = "Green dhide body maker", version = 0)

public class Test1 extends Script {
	
	@Override
	public int onLoop() throws InterruptedException {
		getInventory();
		myPlayer();
		getObjects();
		getWidgets();
		if (leatherleft()) {
			craft();
		}else {
			bank();
		}
		while(myPlayer().isAnimating())
		{
		     sleep(1000);
		}
		return 1000;
	}
	
	private void bank() throws InterruptedException {
		if (!getBank().isOpen()) {
			getBank().open();
		} else if (!leatherleft()) {
			getBank().depositAll(1135);
			if (getBank().contains("Green dragon leather")) {
				getBank().withdrawAll("Green dragon leather");
				bank.close();
			}
		} else {
			stop(true);
		}
	}
	
	private boolean leatherleft() {
		if(getInventory().getAmount("Green dragon leather") > 3) {
			return true;
		}else {
			return false;
		}
	}
	
	private boolean CraftScreenVisible() {
		RS2Widget makewidget = getWidgets().getWidgetContainingText("How many do you wish to make?");
        return makewidget != null && makewidget.isVisible();
    }
	
	public void craft() {
		if (!myPlayer().isAnimating()) {
		if (getInventory().contains("Thread") && getInventory().contains("Needle")) {
			if (getInventory().getSelectedItemName() == null && !CraftScreenVisible()) {
					if (getInventory().interact("Use", "Needle")) {
						getInventory().interact("Use", "Green dragon leather");
						}
			} else {
		        getInventory().deselectItem(); 
		    }
		}
		if(CraftScreenVisible()) {
			RS2Widget makeBody = getWidgets().get(270, 14);
			if(makeBody != null) {
				if(makeBody.isVisible()) {
					log("visible");
					makeBody.interact();
					mouse.moveOutsideScreen();
				}
			}
		}
		}
	}
	
	public void onStart() {
		
		
	}
	
	public void onExit() {
		
	}

	@Override

    public void onPaint(Graphics2D g) {

		if (getClient().isLoggedIn()) {
            Color tanColor = new Color(204, 187, 154);
            g.setColor(tanColor);
            g.fillRect(9, 459, 91, 15);
        }

    }
	
}

 

You need to realize that most interactions are booleans. You need to take advantage of that.

getInventory().interact("Use", "Green dragon leather")

This should be an if statement where the code inside the block would be a conditional sleep.

A conditional sleep looks like this:

new ConditionalSleep(5000) {
    @Override
    public boolean condition() throws InterruptedException {
    	return !getInventory().contains("Coins");
    }
 }.sleep();

5000 <-- Timeout threshold in ms

If the condition: getInventory().contains("Coins") is not met, then after 5 seconds, your program continues executing. However if the condition is met, then the program continues to execute.

You would want to use, 'return my player is animating'.

 

There's a lot of random stuff that you're doing. If you want to continue writing gibberish go ahead, else read up on some beginner java or just programming in general. Basics overlap in all languages.

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.