This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
angrygoose72's profile picture

Help converting string to variable

Started by angrygoose72, 18 July 2012 - 12:37 AM
angrygoose72 #1
Posted 18 July 2012 - 02:37 AM
Hey guys,
I need help with some code.
I need to be able to take user input (for a number) from io.read() and change it from a string into a variable or whatever can be used in math.
e.g

print("please enter a number: ")
number = io.read()
type(number)
when the type(number) executes, it says that the number is a string, how can i change it into a number?
Pinkishu #2
Posted 18 July 2012 - 02:46 AM
number = tonumber(number)
or directly number = tonumber(io.read())
angrygoose72 #3
Posted 18 July 2012 - 02:51 AM
Okay thanks :P/>/>