Code: Select all
function love.load()
text = "A random 10 digit number (i.e. 5642452501)"
yours = tonumber(text)
new = tostring(yours)
text = "("..new:sub(1,3)..") "..new:sub(4,6).."-"..new:sub(7,10)
end
function love.draw()
love.graphics.print(text,0,15)
end
(564) 245-2501
However, if the 1st digit is 0, it just gets ignored. Let's say my generated number was 0642452501 instead. It would display as this:
(642) 452-501
As you can see, the number is only 9 digits. And if my number is all zeroes, it looks like this:
(0) -
How can I make it so any 1st digits of zero are not ignored? I'm struggling to find out how I can fix this. Any help would be appreciated.