Jump to content

TTL formatting help


BananaTown

Recommended Posts

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

 

Link to comment
Share on other sites

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
Link to comment
Share on other sites

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
Link to comment
Share on other sites

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
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

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