formating numbers... IE 02 09:12 ...

DarkLizerd
14 Apr 2017, 17:31

I lost the posting where this was brought up...
Someone wanted to display their game time with leading zeros...
Like 09:45... or 12:05... not like 9:45 or 12:5
Here is the simple answer...
player.hr = right("00"+player.time, 2)
player.mm = right("00"+player.time, 2)
then the time would be:
"the current time is {player.hr}:{player.mm}

or for 3 digits like a heading.. 045...
player.hd = right("000"+player.heading, 3)


hegemonkhan
16 Apr 2017, 01:12

awesome code, very creative and simple/concise design! well done! this will be of great use for people!


DarkLizerd
16 Apr 2017, 05:41

This is the "old Basic" way of doing this before the Basic programmers created the Format command...
(and thanks!)