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.

Smelting with banking

Featured Replies

Hey guys,

Recently I started scripting, I've got a decent level with PHP and web developing so the java basics are easy for me.

 

My problem is : 

I'm making a smithing script for al kharid, I've got the backbone basicly but im kinda stuck with the conditions.

 

Like when the player has 9 iron and 19 coal it needs to walk to the furnace (case smithing) then it needs to make steel bars until it can no longer make them, then it needs to bank. But my brain thinks way to complex so I'm not able to get it to work flawlessly.

 

 private State getState() {
        if (inventory.getAmount("Coal") > 1 && inventory.getAmount("Iron ore") > 0 ){
            return State.SMITH;
            }
        return State.BANK;
    }

^ This is one method I used.

 

Can somebody please make it clear how to condition this the right way :)

 

 

I'm not sure what you mean by "condition it the right way", is it the logic or java / the API you're having difficulties with?

The logic is quite simple:
 

if we have enough ores and near furnace then SMELT
if we have enough ores and not near furnace then WALK_TO_FURNACE
 
if we don't have enough ores and near bank then BANK
if we don't have enough ores and not near bank then WALK_TO_BANK
  • Author

I think it's a logic problem.

I make things to difficult for myself I guess.

 

So if I'm right:

 

This:

private State getState() {
        if (inventory.getAmount("Coal") > 1 && inventory.getAmount("Iron ore") > 0 ){
            return State.SMITH;
            }
        return State.BANK;
    }

Should be:

private State getState() {
        if ( got ores && not close to furnace){
            Walk to furnace
         }
   
        if ( got ores && close to furnace){
            Smelt
         }

        if ( got no ores && not close to bank ){ 
            walk to bank
         }

        if ( got no ores && close to bank){
            bank
         } 

The problem I have is that in this situation what should I compare with, should I use the iron ores or coal or both?

 

 

btw Thanks for the fast respone!

 

Edited by herojord

I think it's a logic problem.

I make things to difficult for myself I guess.

So if I'm right:

This:

private State getState() {        if (inventory.getAmount("Coal") > 1 && inventory.getAmount("Iron ore") > 0 ){            return State.SMITH;            }        return State.BANK;    }
Should be:

private State getState() {        if ( got ores && not close to furnace){            Walk to furnace         }           if ( got ores && close to furnace){            Smelt         }        if ( got no ores && not close to bank ){             walk to bank         }        if ( got no ores && close to bank){            bank         }
The problem I have is that in this situation what should I compare with, should I use the iron ores or coal or both?

btw Thanks for the fast respone!

Use both because without one you can't make what you need. I say make a boolean that check both supplies. And use that as one of the conditions.

Edited by Joseph

  • Author

Use both because without one you can't make what you need. I say make a boolean that check both supplies. And use that as one of the conditions.

 

I know this is a kinda dumb question but how can I use an integer to create a boolean. I mean the variable creation. PHP is not that strict on var types.

 

 

Edited by herojord

I know this is a kinda dumb question but how can I use an integer to create a boolean. I mean the variable creation. PHP is not that strict on var types.

The function type is boolean. Within the function, you have it return if you have got enough ores, like so:

 

  boolean gotOres() {
       return getInventory().getAmount("Coal") >= 2 && getInventory().getAmount("Iron ore") >= 1;
    }

Then call gotOres() in your getState() like you already have it written.

Edited by Volta

  • Author

The function type is boolean. Within the function, you have it return if you have got enough ores, like so:

 

  boolean gotOres() {
       return getInventory().getAmount("Coal") >= 2 && getInventory().getAmount("Iron ore") >= 1;
    }

Then call gotOres() in your getState() like you already have it written.

I've got this atm:

private Position[] pathto = {
            new Position(3276, 3171, 0),new Position(3280, 3181, 0)
    };

	private Position[] pathback = {
            new Position(3280, 3181, 0), new Position(3276, 3171, 0)
    };
		
	boolean gotOres() {
       return getInventory().getAmount("Coal") >= 2 && getInventory().getAmount("Iron ore") >= 1;
    }
	
	
	boolean gotFurnace() {
	       return objects.closest("Furnace").isVisible();
	}
	
	boolean gotBankbooth() {
	       return objects.closest("Bank booth").isVisible();
	}
	
	
	

 private enum State {
  SMITH, BANK, WALKTO, WALKBACK
 };

 private State getState() {
        if (gotOres() == true && gotFurnace() == true){
            return State.SMITH;
         }
        
        if(gotFurnace() == false && gotOres() == true ){
        	return State.WALKTO;
        }
     
        
        if(gotBankbooth() == false && gotOres() == false){	
        	return State.WALKBACK;
        }
        
        
        	return State.BANK;
        

    } 

This is not working because getstate needs a default so whats the best approach for this situation?

I've added the boolean variables. (thanks for that)

Edited by herojord

You got the ore boolean which works. But the other two methods you are using them wrong. The furnace and bank booth are entitys. You should rather compare the distance between you and the entity that you are Looking for.

Use this same logic.

I'm not sure what you mean by "condition it the right way", is it the logic or java / the API you're having difficulties with?

The logic is quite simple:

 

if we have enough ores and near furnace then SMELT

if we have enough ores and not near furnace then WALK_TO_FURNACE

 

if we don't have enough ores and near bank then BANK

if we don't have enough ores and not near bank then WALK_TO_BANK

  • Author

You got the ore boolean which works. But the other two methods you are using them wrong. The furnace and bank booth are entitys. You should rather compare the distance between you and the entity that you are Looking for.

Use this same logic.

 

 

Yeah I kinda figured that out but thanks, makes things clear for me!

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.