Jump to content

How do I stop/prevent an action?

Recommended Posts

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 {
	public int onLoop() throws InterruptedException {
		if (leatherleft()) {
		}else {
		return 1000;
	private void bank() throws InterruptedException {
		if (!getBank().isOpen()) {
		} else if (!leatherleft()) {
			if (getBank().contains("Green dragon leather")) {
				getBank().withdrawAll("Green dragon leather");
		} else {
	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 {
		if(CraftScreenVisible()) {
			RS2Widget makeBody = getWidgets().get(270, 14);
			if(makeBody != null) {
				if(makeBody.isVisible()) {
	public void onStart() {
	public void onExit() {


    public void onPaint(Graphics2D g) {

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



Link to comment
Share on other sites

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) {
    public boolean condition() throws InterruptedException {
    	return !getInventory().contains("Coins");

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.

  • Like 2
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

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...