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.

Super Basic Smithing script

Featured Replies

Made my first script today, and by first I mean first OSBot script. I struggled through the API, so be gentle: I'm learning.

 

import org.osbot.rs07.script.Script;
import org.osbot.rs07.script.ScriptManifest;
import org.osbot.rs07.api.map.constants.Banks;
import org.osbot.rs07.api.ui.RS2Widget;

@ScriptManifest(author = "Chikan", name = "Dagger Maker 3.0", info = "Dagger Maker 3.0", version = 0.3, logo = "")
public final class Main extends Script  
{
	public enum State {
		USEANVIL, SMITH, BANK, WAIT		
	}
	
	private State getState()
	{
		RS2Widget smithingInterface = getWidgets().get(312, 2, 2);
		if(smithingInterface == null&&canSmithBars())
			return State.USEANVIL;
		if (smithingInterface != null&&canSmithBars())
            return State.SMITH;
		if (!getInventory().contains("Bronze Bar"))
		
			return State.BANK;
		return State.WAIT;
	}
	
    @Override
    public final int onLoop() throws InterruptedException 
    {
       switch (getState()) {
    	   case USEANVIL:
    		   getObjects().closest("anvil").interact("Smith");
    		   sleep(random(3000, 4000));
    		   log("starting state: USEANVIL");
    		   break;
    	   case SMITH:
    		   log("starting state: SMITH");
    		   getWidgets().get(312, 2, 2).interact("Smith 10");
    		   sleep(random(12500, 14500));
    		   break;
    	   case BANK:
    		   log("starting state: BANK");
    		   bankHandler();
    	   case WAIT:
   			log("starting state: Wait");
   			sleep(random(250, 700));
   			break;
       }
    	return random(200, 400) ;
    }
       
    //space for making variables
    //inventory check
    private boolean canSmithBars() {
    	return getInventory().contains("Bronze Bar");
    }
    
     //anvil entity
    public boolean useAnvil() {
    	return getObjects().closest("anvil").interact("Smith");
    }
    
    //bank handler (if statement loop)
    private void bankHandler() throws InterruptedException 
    {
    	if (!Banks.VARROCK_WEST .contains(myPosition())) {
            getWalking().webWalk(Banks.VARROCK_WEST );
        } else if (!getBank().isOpen()) {
            getBank().open();
        } else if (!getInventory().isEmptyExcept("Bronze Bar", "Hammer")) {
            getBank().depositAll();
        } else if (getBank().contains("Bronze Bar")) {
            getBank().withdrawAll("Bronze Bar");
        } else {
            stop(true);
        }
    } 	
}

 

Nice work! 

Just a few tips -

  • Firstly, be sure to check out Conditional Sleeps https://osbot.org/api/org/osbot/rs07/utility/ConditionalSleep.html (Note that the class is abstract so you will have to provide your own implementation, anonymous or otherwise). They will help cut slack time in your script, and make your script suitable for SDN application!
  • Secondly, perhaps you have considered not using static widget child ids? I noticed that when you're checking for widgets in your 'getState()' method, you check for child and grandchild ids; since these values often change, it is advised to use other filters like perhaps checking for the presence of text. Since the parent id rarely (if ever) changes when new content is added, you should be able to refine your filters by providing the root id as a parameter to the Widgets#containingText method. Again, you will probably need to do this for SDN submission.
  • Finally, maybe add a paint? (:

Keep it up

Apa

Isn't your bank handler going to deposit your hammer as well when you deposit all? I don't see where you withdraw your hammer again to be able to smith.

  • Author
1 minute ago, Deathimminent said:

Isn't your bank handler going to deposit your hammer as well when you deposit all? I don't see where you withdraw your hammer again to be able to smith.

Yeah, you're right. I just fixed it I think, but I got lazy and just added bank fillers so I didn't make a difference when I was testing.

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.