Jump to content

TTL formatting help


Recommended Posts

Posted

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);
    }

 

Posted (edited)
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
Posted
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.

  • Heart 1
Posted
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 

  • Like 1

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...