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.

TTL formatting help

Featured Replies

So, I am working on the paint for my NMZ bot, everything works great except for the TTL paint. It is displayed in MS. I have tried multiple time formatters and stringbuilders but my implementation has to be wrong because none of them work. 

 

Current code 

 g.drawString(this.getExperienceTracker().getGainedXP(Skill.DEFENCE) + " (" + this.getExperienceTracker().getGainedXPPerHour(Skill.DEFENCE) + ")" + " [" + this.getExperienceTracker().getGainedLevels(Skill.DEFENCE) + "]" + " {" + getExperienceTracker().getTimeToLevel(Skill.DEFENCE) + "}", 223, 443);

(yes I know there is nothing currently there to format time, I removed non working snippets.) 

 

Current time formatting 

 public final String formatTime(final long ms){
        long s = ms / 1000, m = s / 60, h = m / 60, d = h / 24;
        s %= 60; m %= 60; h %= 24;
        return d > 0 ? String.format("%02d:%02d:%02d:%02d", d, h, m, s) :
                h > 0 ? String.format("%02d:%02d:%02d", h, m, s) :
                        String.format("%02d:%02d", m, s);
    }

 

What is an example of your input? It prints 02:00:00 for an input of 7_200_000 which is what you want, right?

Edited by Hawk

  • Author
13 minutes ago, Hawk said:

What is an example of your input? It prints 02:00:00 for an input of 7_200_000 which is what you want, right?

z3E3AY5.png

as you can see, its displaying in MS, id like it to display 00:52:48

EDIT: realized that's output and am retarded, input is in the first code line, specifically 

{" + getExperienceTracker().getTimeToLevel(Skill.DEFENCE) + "}

Edited by Fich420

3 minutes ago, Fich420 said:

z3E3AY5.png

 

as you can see, its displaying in MS, id like it to display 00:52:48

Are you logged in and the script has actually started?

  • Author
1 minute ago, Heist said:

Are you logged in and the script has actually started?

Yes, see XP gained (the first number in paint) 

You need to pass getExperienceTracker().getTimeToLevel(Skill.DEFENCE) to the formatTime method.

  • Author
10 minutes ago, Hawk said:

You need to pass getExperienceTracker().getTimeToLevel(Skill.DEFENCE) to the formatTime method.

I guess my question is whats the correct way of doing that? The way I tried before just displayed ms + 00:00:00, which didnt really help me. 

3 minutes ago, Fich420 said:

I guess my question is whats the correct way of doing that?

I would recommend starting with a Java book to learn the basics of Java first.
The method formatTime takes one argument of type long. The method getTimeToLevel() returns a long value. So to get the output that you're wanting, you need to pass the long value to the format method.

formatTime(getExperienceTracker().getTimeToLevel(Skill.DEFENCE))

formatTime returns a String value which is a required argument of the drawString() method in the Graphics2D class.

  • Author
1 minute ago, Hawk said:

I would recommend starting with a Java book to learn the basics of Java first.
The method formatTime takes one argument of type long. The method getTimeToLevel() returns a long value. So to get the output that you're wanting, you need to pass the long value to the format method.

formatTime(getExperienceTracker().getTimeToLevel(Skill.DEFENCE))

formatTime returns a String value which is a required argument of the drawString() method in the Graphics2D class.

Thank you, I figured it out literally as u posted this. I feel slow 

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.