Jump to content

Script wont start


Gearfighter

Recommended Posts

Hi guys, got a script that i am NEARLY done, but now it doesnt seem to wont to work at all when i start it. Can i get you guys to have a look and see what might be the cause of it not starting?

 

cheers,

 

Gearfighter

import java.awt.Graphics2D;
import org.osbot.rs07.api.Bank;
import org.osbot.rs07.api.Inventory;
import org.osbot.rs07.api.Mouse;
import org.osbot.rs07.api.Objects;
import org.osbot.rs07.api.Settings;
import org.osbot.rs07.api.map.Area;
import org.osbot.rs07.api.map.Position;
import org.osbot.rs07.api.model.NPC;
import org.osbot.rs07.api.model.Player;
import org.osbot.rs07.api.model.RS2Object;
import org.osbot.rs07.input.mouse.MiniMapTileDestination;
import org.osbot.rs07.script.Script;
import org.osbot.rs07.script.ScriptManifest;
import org.osbot.rs07.utility.ConditionalSleep;
import org.osbot.rs07.api.ui.RS2Widget;

@SuppressWarnings("unused")
@ScriptManifest(name = "Gearz Pizza Maker", author = "Gearfighter", version = 1.0, info = "About your script", logo = "Logo of your script. Imgur links here [DIRECT LINKS ONLY]")
public class GearzPizzaMaker extends Script {
	public void makeAll() throws InterruptedException {
		RS2Widget PizzaWidget;
		PizzaWidget = getWidgets().get(309, 6);
		if (PizzaWidget != null && PizzaWidget.isVisible())
			if (PizzaWidget.interact("Make all"))
				sleep(18000);
	}

	public void onStart() {
		log("Ima Make some a Pizza");
	}

	private enum State {
		Bank, Banka, Bankb, Bank1, Bank1a, Pizza, Bank2, Pizza2, Bank3
	}

	private State getState() {

		if (getInventory().isEmpty() && !getBank().contains("Incomplete pizza")) {
			return State.Bank;
		}
		if (getInventory().contains("Pizza base") && getInventory().contains("Tomato")) {
			return State.Pizza;
		}
		if (getInventory().contains("Incomplete pizza") && !getInventory().contains("Cheese")) {
			return State.Bank1;
		}
		if (getInventory().contains("Incomplete pizza") && getInventory().contains("Cheese")) {
			return State.Pizza2;
		}
		if (getInventory().contains("Uncooked pizza")) {
			return State.Bank2;
		}
		if (getBank().contains("Incomplete pizza")) {
			return State.Bank3;
		}
		if (getInventory().onlyContains("Tomato")) {
			return State.Banka;
		}
		if (getInventory().onlyContains("Pizza base")) {
		return State.Bankb;
		}
		if (getInventory().onlyContains("Cheese")) {
		return State.Bank1a;
		}
		
		return null;
		}
	
	@[member=Override]
	public void onExit() {
		// Code here will execute after the script ends
		// Examples: logs, listeners, or dynamic sig data. Really anything that
		// needs to be ended when the user of your script stops it.
		log("Script ended! Please leave feedback on the forums");
	}

	@[member=Override]
	public int onLoop() throws InterruptedException {
		switch (getState()) {

		case Bank:
				if (!getBank().isOpen()) {
					getBank().isOpen();
					getBank().withdraw("Pizza base", 14);
				if (getInventory().contains("Pizza base"))
					;
				sleep(1000);
				getBank().withdraw("Tomato", 14);
				getBank().close();
				}
				break;
  
		case Banka:
			if (!getBank().isOpen()) {
				getBank().open();
					getBank().withdraw("Pizza base", 14);
					getBank().close();	
			}
			break;
			
			case Bankb:
				if (!getBank().isOpen()) {
					getBank().open();
					getBank().withdraw("Tomato", 14);
				getBank().close();
				}
				break;
				
		case Pizza:
				if (getInventory().getItem("Pizza base").interact("Use", "Pizza base"))
					if (getInventory().getItem("Tomato").interact("Use", "Tomato"))
						sleep(3000);
			makeAll();

			break;

		case Bank1:
			if (!getBank().isOpen()) {
				getBank().open();
				getBank().withdraw("Cheese", 14);
				getBank().close();
			}
			break;
			
		case Bank1a:
			if (!getBank().isOpen()) {
				getBank().open();
					getBank().withdraw("Incomplete pizza", 14);
					getBank().close();	
			}
			break;
			

		case Bank2:
			if (!getBank().isOpen()) {
				getBank().open();
				getBank().depositAll();

			}
			break;

		case Pizza2:
			if (getInventory().getItem("Incomplete pizza").interact("Use", "Incomplete pizza"))
				if (getInventory().getItem("Cheese").interact("Use", "Cheese"))
					sleep(3000);
			makeAll();
		case Bank3:
			if (!getBank().isOpen()) {
				getBank().open();
				sleep(800);
				getBank().withdraw("Incomplete pizza", 14);
				if (getInventory().contains("Incomplete pizza"));
				sleep(1000);
				getBank().withdraw("Cheese", 14);
				getBank().close();
			}
			break;
		}
		return 0;
	}
}

Link to comment
Share on other sites

Do some debugging, like does it loop? Does getState() return anything? It could be a problem with your logic when finding the state, so it returns null.

And I'm pretty sure you can't just check whether your bank contains a certain thing if it isn't open.

TBH you should redo getState completely, split it into logical steps.

if (!getBank().isOpen()) {
	getBank().isOpen();

wat

 

And use conditional sleeps, or at least use regular sleeps.

				if (!getBank().isOpen()) {
					getBank().open();
					getBank().withdraw("Tomato", 14);
				getBank().close();

sleeeeeep

 

If ya need any help holla

Edited by Auron
Link to comment
Share on other sites

public void makeAll() throws InterruptedException {
		RS2Widget PizzaWidget;
		PizzaWidget = getWidgets().get(309, 6);
		if (PizzaWidget != null && PizzaWidget.isVisible())
			if (PizzaWidget.interact("Make all"))
				sleep(18000);
	}

For this part i don't recommend using static widgets as sometimes if something got updated it would change the widget IDs.

if (getInventory().isEmpty() && !getBank().contains("Incomplete pizza")) {

            return State.Bank;

        }

 

The red text would return a null if the bank is not opened i think

if (getBank().contains("Incomplete pizza")) {

            return State.Bank3;

        }

 

Same for this

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.
Note: Your post will require moderator approval before it will be visible.

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