read

From ComputerCraft Wiki
(Redirected from Io.read)
Jump to: navigation, search


Grid Redstone.png  Function read
Lets you get input of the user.
Syntax read([ char replacement [, table history [, function auto complete ]] ])
Returns string The user's input
Part of ComputerCraft
API none

Examples

Grid paper.png  Example
Prints what the user wrote.
Code
print (read())
Output Whatever the user wrote.



Grid paper.png  Example
Ask for a Password and lets the user enter it. The letters are hidden by '*'.
Code
local password = "computercraft"
print ("Enter Password")
local input = read("*")
if input == password then
 print("Password is correct. Access granted.")
else
 print("Password is incorrect. Access denied.")
end
Output Enter Password

*******

Password is correct. Access granted. or Password is incorrect. Access denied.