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.

getState() with multiple if statements

Featured Replies

private enum State{
		BANK,
		MAKE,
		GRANDEXCHANGE,
	}
	
	private State getState() {
		
		if(inventory.contains(227) && inventory.contains(HighestMarginHerbId))
			return State.MAKE;
		return State.BANK;
	}

First of all im a beginner in scripting and in java.

Im trying to make getState() return GRANDEXCHANGE when bank does not contain the item 227 and HighestMarginHerbId. But it keeps giving me errors. 

if(!getBank().contains(227) || !getBank.contains(HighestMarginHerbId)) {
  return State.GRANDEXCHANGE;
}

Put that into your getState() method.

If the bank does not contain any of the items with id 227 OR HighestMarginHerbId, it will return to state GRANDEXCHANGE.

Edited by Woody

10 minutes ago, Chris said:

dont use states its trash

just throw it all on loop bro

17 minutes ago, HeyImJamie said:

Ur trash

:???::peanut:
 

:think: 

1 hour ago, Woody said:

if(!getBank().contains(227) || !getBank.contains(HighestMarginHerbId)) {
  return State.GRANDEXCHANGE;
}

Put that into your getState() method.

If the bank does not contain any of the items with id 227 OR HighestMarginHerbId, it will return to state GRANDEXCHANGE.

Should be && instead of || for the result you describe

1 hour ago, andrewboss said:

Why?

Because you're a beginner in java and osbot scripting. PLus states are garbage to learn from

2 hours ago, FrostBug said:

Should be && instead of || for the result you describe

But then it will only return to GRANDEXCHANGE if both of the items are missing

Am I missing something?

1 hour ago, andrewboss said:

Why?

Don't listen to them. You should learn how state machine works because you're new to java and it's a good start for you.

They want you to use the onLoop() method to do sequential instead of using the states as it is "easier to learn java with" as they said. :) 

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.