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.

Paint won't show

Featured Replies

I know this seems like a rookie problem but I can't find the issue. Here's my paint.

@Override
    public void onPaint(Graphics2D g) {
        
        DecimalFormat df = new DecimalFormat("#");
        timeRan = System.currentTimeMillis() - this.timeBegan;
        currentXp = skills.getExperience(Skill.FLETCHING);
        
        if (currentXp > logXp) {
            itemsMade += 15;
            logXp = currentXp;
        }
        
        if (guiOptionChose == "Arrow shafts") {

            int temp = Integer.parseInt(logPrice);
            int temp2 = Integer.parseInt(arrowShaftPrice);
            int temp3 = Integer.parseInt(headlessArrowPrice);
            int temp4 = Integer.parseInt(featherPrice);
            
            xpGained = currentXp - beginningXp;
            gpGained = (itemsMade * temp2) - (temp * itemsMade);
            totalGpGained = gpGained / 1000;
            gpPerHour = (int)(gpGained / ((System.currentTimeMillis() - timeBegan) / 3600000.0D));
            totalGpPerHour = gpPerHour / 1000;
        }
        
        if (guiOptionChose == "Headless arrows") {

            int temp = Integer.parseInt(logPrice);
            int temp2 = Integer.parseInt(arrowShaftPrice);
            int temp3 = Integer.parseInt(headlessArrowPrice);
            int temp4 = Integer.parseInt(featherPrice);
            int temp5 = temp2 + temp4;
            
            xpGained = currentXp - beginningXp;
            gpGained = (itemsMade * temp3) - (temp5 * itemsMade);
            totalGpGained = gpGained / 1000;
            gpPerHour = (int)(gpGained / ((System.currentTimeMillis() - timeBegan) / 3600000.0D));
            totalGpPerHour = gpPerHour / 1000;
        }
        
        g.setColor(Color.WHITE);
        g.drawString("Run Time: " + ft(timeRan), 5, 260);
        g.drawString("Xp Gained: " + xpGained, 5, 280);
        g.drawString("Gp Gained: " + df.format(totalGpGained) + " k", 5, 300);
        g.drawString("Gp Per Hour: " + df.format(totalGpPerHour) + " k/hr", 5, 320);
    }

 

Edited by Jack Shep

  • Author
22 minutes ago, Juggles said:

Does your GUI work and is typed exactly like it? 

Yeah, my GUI works fine and is written the same way. I also use the same two if statements in my onLoop() and it works fine.

Print the value of guiOptionChose and make sure it's being set correctly.

  • Author
57 minutes ago, HeyImJamie said:

Print the value of guiOptionChose and make sure it's being set correctly.

The value of guiOptionChose is being set correctly, I have a set of if statements identical to the pair in my paint in my onLoop() and they work fine.

if (guiOptionChose == "Headless arrows") {

 

Change to

 

if (true) {

 

If it's still not rendering, then it's a different issue.

  • Author
4 hours ago, liverare said:

if (guiOptionChose == "Headless arrows") {

 

Change to

 


if (true) {

 

If it's still not rendering, then it's a different issue.

Yeah, that didn't work either. I still have no clue what the issue is

I just noticed you're parsing a lot of strings to integers, so I suspect that's throwing an NumberFormatException error which is preventing the paint from being rendered. I would avoid parsing anything on the paint method, as the rendering is called a stupid amount of times per second and so you're re-parsing again and again. It's both inefficient and likely causing problems.

You should perhaps paint the raw string values and see whether they display as numbers, null, or empty. You can actually test this by going back to my earlier comment and making it "if (false)" instead, that way you're not parsing anything and are instead going straight to the drawing code.

Edited by liverare

  • Author
44 minutes ago, liverare said:

I just noticed you're parsing a lot of strings to integers, so I suspect that's throwing an NumberFormatException error which is preventing the paint from being rendered. I would avoid parsing anything on the paint method, as the rendering is called a stupid amount of times per second and so you're re-parsing again and again. It's both inefficient and likely causing problems.

You should perhaps paint the raw string values and see whether they display as numbers, null, or empty. You can actually test this by going back to my earlier comment and making it "if (false)" instead, that way you're not parsing anything and are instead going straight to the drawing code.

The only issue with leaving the variables as 'string' is that I don't actually print those values. I use them in my formulas to calculate the values of the variables that I do actually print. So I need those variables as 'int's. However, what you're saying about re-parsing again and again makes sense. I only need to convert the variables from 'string' to 'int' once as they're just the OSBuddy prices of a few items. So I'll try parsing my strings to integers in my onStart() method and see if that fixes the issue.

  • Author
1 hour ago, liverare said:

I just noticed you're parsing a lot of strings to integers, so I suspect that's throwing an NumberFormatException error which is preventing the paint from being rendered. I would avoid parsing anything on the paint method, as the rendering is called a stupid amount of times per second and so you're re-parsing again and again. It's both inefficient and likely causing problems.

You should perhaps paint the raw string values and see whether they display as numbers, null, or empty. You can actually test this by going back to my earlier comment and making it "if (false)" instead, that way you're not parsing anything and are instead going straight to the drawing code.

What I tried worked, my paint finally prints now, thank you for the help. But of course this generated another issue, now the script stops moments after I start it, although it sounds like an unrelated issue, the script worked 100% (besides for the paint) before I made the change. I tried parsing the strings in my onLoop() instead which fixed the new issues but again the constant re-parsing caused some issues. (So much lag that the script wouldn't run). Any Ideas?

int something;

@Override
public int onLoop() throws InterruptedException {

  try {
    something = Integer.parseInt("12345");
  } catch (NumberFormatException e) {
    logger.error(e);
  }
  
  return 200;
}

@Override
public void onPaint(Graphics2D g) {
  
  g.drawString(25, 25, "Something: " + something);
}

 

  • Author
On 11/22/2018 at 3:20 AM, liverare said:

int something;

@Override
public int onLoop() throws InterruptedException {

  try {
    something = Integer.parseInt("12345");
  } catch (NumberFormatException e) {
    logger.error(e);
  }
  
  return 200;
}

@Override
public void onPaint(Graphics2D g) {
  
  g.drawString(25, 25, "Something: " + something);
}

 

It works! Thank you so much for your help

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.