7 posts
Location
North Carolina
Posted 19 June 2012 - 03:01 AM
how can i get read() to take in a number instead of a string.
992 posts
Posted 19 June 2012 - 03:07 AM
No but you can convert a string to a number with tonumber()
local variable = tonumber(read())
7 posts
Location
North Carolina
Posted 19 June 2012 - 03:09 AM
well all i want to do is take the string 4 an make it the number 4
992 posts
Posted 19 June 2012 - 03:13 AM
the tonumber() function takes a string and converts it to number.
7 posts
Location
North Carolina
Posted 19 June 2012 - 03:18 AM
im trying to make a program that takes a number i type ex:4 and evaluates as the number 4 and evaluates it as 4 and not ist string value
992 posts
Posted 19 June 2012 - 03:30 AM
there is no function capable of reading a value into a program in a number format. there is how ever a way to change a string into a number this is with the tonumber() function. this function takes a string and converts it into a number. this number can now be used as you would any other number in lua. this line will read in a string then convert it to a number and dump that NUMBER into the variable "variable"
local variable = tonumber(read())
see this for more info
7 posts
Location
North Carolina
Posted 19 June 2012 - 03:40 AM
ok i understand now thank you