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.

Can anyone figure out the problem with this code?

Featured Replies

Basically, if I add an icon to the JOptionPane, it doesn't recognize my option anymore. If I leave it without an image, it does recognize the option. It's obviously something with the code, but what is it? O_O

What it does is, I let the user select the type of log they want, and then perform an action based on that. Here's a snippet:

 

Code that works

	@Override
	public void onStart() throws InterruptedException {	
		
		String userOptions[] = { "Logs", "Oak logs", "Teak logs", "Mahogany logs" };
		String userChoice = "" + (String) JOptionPane.showInputDialog(null, "Choose a log type", "Log Selection Menu",
				JOptionPane.PLAIN_MESSAGE, null, userOptions, userOptions[1]);
	}

Code that doesn't work

	@Override
	public void onStart() throws InterruptedException {
		
		ImageIcon icon = null;
		try {
			icon = new ImageIcon(new URL(
					"https://vignette.wikia.nocookie.net/2007scape/images/6/65/Demon_butler_chathead.png/revision/latest?cb=20151103211007"));
		} catch (MalformedURLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
		String userOptions[] = { "Logs", "Oak logs", "Teak logs", "Mahogany logs" };
		String userChoice = "" + (String) JOptionPane.showInputDialog(null, "Choose a log type", "Log Selection Menu",
				JOptionPane.PLAIN_MESSAGE, icon, userOptions, userOptions[1]);
	}

 

Edited by Lol_marcus

Seems to work fine for me. Print userChoice to the logger at the end of onStart and see if you see the result.

By not recognizing your option anymore, do you mean that it is returning a value that was not selected? Or is it that the values in the JOptionPane are not the options you are passing into it?

  • Author

It's not passing on the option to the rest of the script. I'm getting "userChoice is an invalid variable" if I try to do something like getBank().withdrawAll(userChoice); with the code that doesn't work. If I remove all the code to add my icon it works fine. :???:

 

The code itself works, it's just not passing the users choice for some odd reason.

Edited by Lol_marcus

On 6/6/2020 at 4:40 AM, Lol_marcus said:

It's not passing on the option to the rest of the script. I'm getting "userChoice is an invalid variable" if I try to do something like getBank().withdrawAll(userChoice); with the code that doesn't work. If I remove all the code to add my icon it works fine. :???:

 

The code itself works, it's just not passing the users choice for some odd reason.

If the code above is the same that you are using and you are trying to access the userChoice variable outside of the onStart() than it will show invalid variable, as you have only created that variable inside of the onStart(). Add the userChoice var to the class and set that value in the onStart(), you will than be able to use that variable.

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.