Negative integers are nil, positive integers aren't

Code: local num = -tonumber(3 .. string.format("%0.2i", tostring(16 - 17))) print(num)

Run this code in your command line and it will print nil. Change 16 to something higher and it’ll run as expected… The purpose of this code is to print, for example, 01 instead of 1 and 02 instead of 2 and so on.

Solution: gsub the negative string (-) with nothing and it’ll be fixed.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.