Jump to content

Symbols limit


Drakath

Recommended Posts

  • Moderators

And in the "manual" way:

1 - turn it into a string

2 - take the 4 first caracters of it (in "5,12" there are 4 caracters)

3 - turn the result back into a number

local number = 5.123456 
number = tonumber(string.sub(tostring(number), 1, 4)) 
outputChatBox(number) --outputs 5.12 

Link to comment
And in the "manual" way:

1 - turn it into a string

2 - take the 4 first caracters of it (in "5,12" there are 4 caracters)

3 - turn the result back into a number

local number = 5.123456 
number = tonumber(string.sub(tostring(number), 1, 4)) 
outputChatBox(number) --outputs 5.12 

Code should be this:

local number = 5.123456 
number = tonumber(string.sub(tostring(number), 1, number < 0 and 5 or 4)) 
outputChatBox(...) -- 5.123456 outputs 5.12 
outputChatBox(...) -- -5.123456 outputs -5.12 

Link to comment
  • Moderators
And in the "manual" way:

1 - turn it into a string

2 - take the 4 first caracters of it (in "5,12" there are 4 caracters)

3 - turn the result back into a number

local number = 5.123456 
number = tonumber(string.sub(tostring(number), 1, 4)) 
outputChatBox(number) --outputs 5.12 

Code should be this:

local number = 5.123456 
number = tonumber(string.sub(tostring(number), 1, number < 0 and 5 or 4)) 
outputChatBox(...) -- 5.123456 outputs 5.12 
outputChatBox(...) -- -5.123456 outputs -5.12 

Totally right, I didn't think about it.

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...