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

Saving values to variables

Started by Razputin, 11 March 2013 - 04:01 PM
Razputin #1
Posted 11 March 2013 - 05:01 PM
What code do I need for a program to take user inputted # values and save them to variables so I can use them later in the program? I want it to take the variables and compare them.


if var1, var2, var3 >=30 then
...
theoriginalbit #2
Posted 11 March 2013 - 05:04 PM
You can use 'read()' to get input from users
You can use 'tonumber()' to convert a string into a number

local num1 = tonumber( read() )

As for comparisons

if var1, var2, var3 >= 30 then
would not work. you would have to do this

if var1 >= 30 and var2 >= 30 and var3 >= 30 then