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.

Keeps spamclicking

Featured Replies

This is my first script i made. Everything works fine except when it starts using the items. It will keep spamming them. I've used if(!myplayer().isanimating()). But there seems to be a small gap in the animations so it will still be spamming the vials of water and herbs and it will eventually cancel the crafting.

 

 

 

import org.osbot.rs07.script.Script;
import org.osbot.rs07.script.ScriptManifest;

@ScriptManifest(author = "MarWo", info = "simple bot for making unfinished potions", logo = "", name = "HerbloreBot", version = 0)

public class Bot extends Script {
	
private enum State {
	BANK, MAKE
};

private State getState() {
	if(inventory.contains(227) && inventory.contains(255)) 
		return State.MAKE;
				return State.BANK;
	}
	
	public void onStart(){
		
	}
	
	public void onExit() {
		
	}
	
	public int onLoop() throws InterruptedException {
		switch (getState()) {
		case BANK:
			if(!getBank().isOpen()) {
				getBank().open();
			}

			sleep(100);
			bank.depositAll();
			sleep(100);
			bank.withdraw(227, 14);
			sleep(100);
			bank.withdraw(255, 14);
			sleep(100);
			bank.close();
			break;
		case MAKE:
		if(!getWidgets().isVisible(270, 14)) {
			if(!myPlayer().isAnimating()) {

			inventory.interact("Use", 227);
			sleep(250);
			inventory.interact("Use", 255);
	}
}
			
			
			if (getWidgets().isVisible(270, 14)) {
				getWidgets().interact(270, 14, "Make");
				
			}
				break;
	}
		return 500;
	
	}
}

 

I'd recommend learning conditional sleeping, this would both solve your issue and make it more responsive. Since it seems you're new to programming, you could add a 500ms sleep after your second interaction.

Also you have :

if (!getWidgets().isVisible(270, 14)) { 
//do stuff


if (getWidgets().isVisible(270, 14)) {
//do more stuff
}


You can replace this with:

if (!getWidgets().isVisible(270, 14)) {

} else {

}

The else is faster on the machine since it's only checking that if statement once. The else is the inverse of the if statement. In human english terms, you would read this as, "if widget 270, 14 is NOT NOT visible", NOT NOT, double not so this is true, therefore "if widget 270, 14 is visible".



Edit: accidentally missed a !

  • Author

Sorry im new to scripting.  Can someone do an example of the conditional sleep cause i cant get it to work.

20 minutes ago, MarWo22 said:

Sorry im new to scripting.  Can someone do an example of the conditional sleep cause i cant get it to work.

 

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.