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.

java.lang.NumberFormatException: For input string: "-----"

Featured Replies

So I'm getting this error thrown whenever the script detects more than 1 player near me. This doesn't happen if it detects 1 player > 

[ERROR][Bot #1][08/07 03:50:59 AM]: Error in script executor!
java.lang.NumberFormatException: For input string: "-----"
	at java.lang.NumberFormatException.forInputString(Unknown Source)
	at java.lang.Integer.parseInt(Unknown Source)
	at java.lang.Integer.parseInt(Unknown Source)
	at org.osbot.rs07.api.Map.getWildernessLevel(dn:80)
	at vAlert.onLoop(vAlert.java:37)
	at org.osbot.rs07.event.ScriptExecutor$InternalExecutor.run(un:19)
	at java.lang.Thread.run(Unknown Source)

Never seen that before, I did some research, I found this is a common issue when parsing integers. However, I'm not parsing anything.

Code:

Spoiler

@Override
    public int onLoop() throws InterruptedException {
        for (Player p : getPlayers().getAll()) {
          
            int wildernessLevel = getMap().getWildernessLevel();
          
            if (whenVisible && wildernessLevel >= 1) {
                if (p != myPlayer() && p.exists()) {
                    log("====================================================================");
                    log("DANGER! Logging Out >" + " " + "Name:" + " " + p.getName() + " " + "-" + " " + "Combat:" + " " + p.getCombatLevel());
                    log("====================================================================");
                    logoutTab.logOut();
                }
            } else if (whenAttackable && wildernessLevel >= 1) {
                if (p != myPlayer() && p.exists()) {
                  
                    int enemyCombatPosi = p.getCombatLevel() + wildernessLevel;
                    int enemyCombatNeg = p.getCombatLevel() - wildernessLevel;

                    if (enemyCombatPosi >= myPlayer().getCombatLevel() && enemyCombatNeg <= myPlayer().getCombatLevel()) {
                        log("====================================================================");
                        log("DANGER! Logging Out >" + " " + "Name:" + " " + p.getName() + " " + "-" + " " + "Combat:" + " " + p.getCombatLevel());
                        log("====================================================================");
                        logoutTab.logOut();
                    }
                }
            }
        }
        return 100;
    }

 

The issue is coming from getWildernessLevel() which is weird, but meh.

Edited by Visty

  • Author
3 minutes ago, Chris said:

p != null 

!p.equals(myPlayer())

Same error :feels:

getWildernessLevel() is 0 when not in wilderness

  • Author
2 minutes ago, Chris said:

getWildernessLevel() is 0 when not in wilderness

Yeah. The if statements only executes when inside the wilderness anyways

  • Author
1 minute ago, Chris said:

where dis 


vAlert.java:37)
int wildernessLevel = getMap().getWildernessLevel();
16 minutes ago, Visty said:

int wildernessLevel = getMap().getWildernessLevel();

Firstly, fix the two errors that Chris stated above, but it's likely that the actual method has an issue.

 

Secondly, grab your wildy level outside of the loop (no need to repeatedly call it when chances are that your wildy level will not change in the span of < 50ms).

 

Thirdly, I would recommend making this into a method like shouldLogOut(), instead of having your log outs inside of a loop like that.

 

Fourthly, it should be easy to remake that method if it's giving you problems (issue a bug report though, is my recommendation). Check if the widget displaying the wilderness level is there, and if it is and it's visible, that means that you're in the wilderness (so otherwise return 0). From there, parse the text from the widget and you'll get the wildy level :)

Edited by Imateamcape

I wrote a Wilderness API a very long time ago. I'll re-write it at some point, but until then, here:

	/**
	 * Calculate Y coordinate by wilderness level.
	 * 
	 * Note: This is based of Edgeville Wilderness and there are some zones
	 * where the Wilderness level increments are inconsistent with the rest of
	 * the Wilderness (which is 8 tiles per Wilderness level).
	 * 
	 * @param wildernessLevel
	 *            - Wilderness level
	 * @param upperBound
	 *            - Upper-most tile for that Wilderness level
	 * @return Y coordinate
	 * @see {@link WildernessAPI#calculateYCoordinate(int, boolean)}
	 */
	public static int calculateYCoordinate(Vector3D vector3d, boolean upperBound) {
		return calculateYCoordinate(vector3d.getY(), upperBound);
	}
	
	/**
	 * Calculate Y coordinate by wilderness level.
	 * 
	 * Note: This is based of Edgeville Wilderness and there are some zones
	 * where the Wilderness level increments are inconsistent with the rest of
	 * the Wilderness (which is 8 tiles per Wilderness level).
	 * 
	 * @param vector3d
	 *            - 3D vector
	 * @param upperBound
	 *            - Upper-most tile for that Wilderness level
	 * @return Y coordinate
	 */
	public static int calculateYCoordinate(int wildernessLevel, boolean upperBound) {
		
		int yCoordinate;
		
		if (wildernessLevel <= 0) {
			
			yCoordinate = 3524;
			
		} else if (wildernessLevel <= 1) {
			
			yCoordinate = 3527;
			
		} else if (wildernessLevel <= 2) {
			
			yCoordinate = 3535;
			
		} else {

			wildernessLevel -= 3;

			yCoordinate = 3535;
			yCoordinate += (wildernessLevel * 8);
			
			if (upperBound) {
				
				yCoordinate += 8;
				
			} else {
				
				yCoordinate++;
			}
		}
		
		return yCoordinate;
	}

	/**
	 * Calculates Wilderness level by Y coordinate
	 * 
	 * Note: This is based of Edgeville Wilderness and there are some zones
	 * where the Wilderness level increments are inconsistent with the rest of
	 * the Wilderness (which is 8 tiles per Wilderness level).
	 * 
	 * @param vector3d
	 *            - 3D vector
	 * @return Wilderness level
	 * @see {@link WildernessAPI#calculateWildernessLevel(int)}
	 */
	public static int calculateWildernessLevel(Vector3D vector3d) {
		return calculateWildernessLevel(vector3d.getY());
	}

	/**
	 * Calculates Wilderness level by Y coordinate
	 * 
	 * Note: This is based of Edgeville Wilderness and there are some zones
	 * where the Wilderness level increments are inconsistent with the rest of
	 * the Wilderness (which is 8 tiles per Wilderness level).
	 * 
	 * @param yCoordinate
	 *            - Y coordinate
	 * @return Wilderness level
	 */
	public static int calculateWildernessLevel(int yCoordinate) {
		
		int wildernessLevel;
		
		if (yCoordinate <= 3524) { // not in wilderness
			
			wildernessLevel = 0;
			
		} else if (yCoordinate <= 3527) { // Level 1 wilderness
			
			wildernessLevel = 1;
			
		} else if (yCoordinate <= 3535) { // Level 2 wilderness
			
			wildernessLevel = 2;
			
		} else {
			
			wildernessLevel = (yCoordinate - 3535);
			wildernessLevel = (int) Math.ceil(wildernessLevel / 8D);
			wildernessLevel += 2; // can't remember why...
		}
		
		return wildernessLevel;
	}

With this, you can begin to assess stuff like:

  • What level must I be in before player X can attack me?
  • Who can I attack?
  • Where's the nearest/furthest safe Y coordinate?
  • etc.

I sprung up quite a beefy API around this, it could do all kinds of checks.

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.