Jump to content

string formatting


IIYAMA

Recommended Posts

  • Moderators
local theString = tostring(2) 
if string.len(theString) == 1 then 
 theString = 0 .. theString 
end  
  
print(theString) 

Does anybody knows how to do this shorter?

So if there is one character, it will have a zero at front.

  
So: 
01 
02 
03 
04 
05 
06 
07 
08 
09 
10-- 2 characters. 
11 
12 
etc. 

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

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