ID:267051
 
Is it possible to have 0 be displayed as 00 (I can do it, but Im after a easier way)
-DogMan
PS: 'My' way involves checking to see if the number is less then 10, then conerting it to text, then adding a text 0 to the start of it.
world << "[N-N%10][N%10]"
In response to Garthor
Garthor wrote:
world << "[N-N%10][N%10]"

Totally wrong. Again I exhort you to please pay more attention to your code before you post it.

Problem: N-N%10 will still have a 0 at the end of it. round(N/10) or N/10%10 (for just 1 digit) will work, however.

My solution when doing this with time is as follows:
var/ticks = endtime - world.time  // ticks till end of round
if(ticks>=0)
stat("Time remaining: [ticks/600%60]:[ticks/100%6][ticks/10%10]")
The % operator handily will round down for you, so you don't need to worry about using round().

To explain that code a little better: 600 ticks make up a minute, so the above display will show the number of minutes--up to just under an hour. Then there's the colon, followed by the 10s of the seconds; every 10 seconds is 100 ticks, so I use ticks/100, and I use %6 to keep that from 0 to 5. (At 6 it'd be 60+ seconds, which is at least a full minute.) The last digit is 0 to 9, and is just single seconds (10 ticks each), so first I divide ticks by 10, then take modulo 10 (%10) to get 0 to 9.
Again, fractions won't matter because % takes them right out.

Lummox JR
In response to Lummox JR
Thanks for that. Ive really got to become more familiar with the % operator. Right now Im pretty sure Ive got what it does figured out.
I'll just have to try and slip it into my code more often to get used to reading it.
-DogMan
In response to Lummox JR
Oops, I forgot the /10.