Difference between revisions of "Read"
From ComputerCraft Wiki
Evil dan2wik (Talk | contribs) (Undo revision 4605 by 168.215.243.4 (talk)) |
m (Added history argument, clarified doesn't actually return 'nil'...) |
||
Line 2: | Line 2: | ||
{{Function | {{Function | ||
|name=read | |name=read | ||
− | |args= [[char (type)|char]] | + | |args= <nowiki>[</nowiki> [[char (type)|char]] replacement <nowiki>[, </nowiki>[[table (type)|table]] history<nowiki>]</nowiki> <nowiki>]</nowiki> |
|api= | |api= | ||
+ | |returns=[[string (type)|string]] The user's input | ||
|addon=ComputerCraft | |addon=ComputerCraft | ||
|desc=Lets you get input of the user. | |desc=Lets you get input of the user. |
Revision as of 18:44, 1 June 2013
Function read | |
Lets you get input of the user. | |
Syntax | read([ char replacement [, table history] ]) |
Returns | string The user's input |
Part of | ComputerCraft |
API | none |
Examples
Example | |
Prints what the user wrote. | |
Code |
print (read()) |
Output | Whatever the user wrote. |
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. |