BananaTown Posted November 4, 2020 Share Posted November 4, 2020 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); } Quote Link to comment Share on other sites More sharing options...
Hawk Posted November 4, 2020 Share Posted November 4, 2020 (edited) 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 November 4, 2020 by Hawk 1 Quote Link to comment Share on other sites More sharing options...
BananaTown Posted November 4, 2020 Author Share Posted November 4, 2020 (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? 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 November 4, 2020 by Fich420 Quote Link to comment Share on other sites More sharing options...
Heist Posted November 4, 2020 Share Posted November 4, 2020 3 minutes ago, Fich420 said: 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? 1 Quote Link to comment Share on other sites More sharing options...
BananaTown Posted November 4, 2020 Author Share Posted November 4, 2020 1 minute ago, Heist said: Are you logged in and the script has actually started? Yes, see XP gained (the first number in paint) Quote Link to comment Share on other sites More sharing options...
Hawk Posted November 4, 2020 Share Posted November 4, 2020 You need to pass getExperienceTracker().getTimeToLevel(Skill.DEFENCE) to the formatTime method. Quote Link to comment Share on other sites More sharing options...
BananaTown Posted November 4, 2020 Author Share Posted November 4, 2020 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. Quote Link to comment Share on other sites More sharing options...
Hawk Posted November 4, 2020 Share Posted November 4, 2020 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. 1 Quote Link to comment Share on other sites More sharing options...
BananaTown Posted November 4, 2020 Author Share Posted November 4, 2020 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 1 Quote Link to comment Share on other sites More sharing options...