November 4, 20205 yr 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); }
November 4, 20205 yr 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, 20205 yr by Hawk
November 4, 20205 yr 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? 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, 20205 yr by Fich420
November 4, 20205 yr 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?
November 4, 20205 yr 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)
November 4, 20205 yr You need to pass getExperienceTracker().getTimeToLevel(Skill.DEFENCE) to the formatTime method.
November 4, 20205 yr 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.
November 4, 20205 yr 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.
November 4, 20205 yr 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