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.

Debugging error in onStart()?

Featured Replies

What's the general rule of thumb at debugging scripts?

 

What I do is

 

- realize it's buggy

- log out of client

- rewrite one line

- recompile

- copy to scripts folder

- relauch client

- log in to account manually

- start script

- GOTO 1;

 

It takes more than a minute.

 

I'm getting a mysterious error in onStart() and I can locate which method causes it. I can't get a clearer error message though. The error must be that widget child/grandchild IDs do not always match, and cant't figure out why.

 

What's the general rule of thumb at debugging scripts?

 

What I do is

 

- realize it's buggy

- log out of client

- rewrite one line

- recompile

- copy to scripts folder

- relauch client

- log in to account manually

- start script

- GOTO 1;

 

It takes more than a minute.

 

I'm getting a mysterious error in onStart() and I can locate which method causes it. I can't get a clearer error message though. The error must be that widget child/grandchild IDs do not always match, and cant't figure out why.

 

are you null checking them? post the code

Edited by Precise

You don't have to relaunch the client. Configure an artifact (or w/e it's called in your IDE) in the script folder and your IDE will replace it after each compilation. So all you have to do is refresh and restart the script.

I think it's possible to just catch any exception in onStart and print its message.

try {

....

} catch(Exception e) {
 if(e.getMessage() != null) log(e.getMessage());

}

  • Author

I'll google for this artifact stuff.

 

Here's the current messy code.

	public int getPriceOnTheRight() throws InterruptedException{

		RS2Widget rightside = widgets.get(465, 23, 39);
		
		if(rightside != null){

			// log(rightside.getMessage()); 
                        // maybe this has no getMessage method, how to check this?

			String msg = rightside.getMessage(); // the error is thrown here I guess

			if(msg != null){
				return Integer.parseInt(msg.replace(" coins", ""));
			}else{
				log("getMessage didnt find any text");
				return 0;
			}
			
		}else{
			log("Right side widget area not found");
			return 0;
		}

	}

Edited by casual

What's the general rule of thumb at debugging scripts?

 

I'm getting a mysterious error in onStart() and I can locate which method causes it. I can't get a clearer error message though. The error must be that widget child/grandchild IDs do not always match, and cant't figure out why.

put a log between each line and see which line was last called. Anything under that is where the problem is coming from

  • Author

I mean isn't there a stack trace or something I could enable?

 

noone likes these bruteforce woodchopping style debugs

Edited by casual

As others have said wrap your onStart method in a try catch statement.

 

You could print the track stace like;


	try {
	
		/* YOUR CODE HERE */

	} catch(final Exception e) {
		final StackTraceElement[] stack = e.getStackTrace();
		for (final StackTraceElement ste : stack)
			log(ste.getMessage());
	}
	

The only area I can see any error potentially being thrown there is your Integer.parseInt, make sure that the text doesn't have trailing or leading whitespace, you can use .trim() to ensure that.

 

Also, print it out to see what it's actually trying to parse to ensure it's not going to throw a NumberFormatException.

Edited by Zee Best

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.