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

wierd read if thing ? (plz help)

Started by Crowdy199, 16 January 2013 - 09:29 AM
Crowdy199 #1
Posted 16 January 2013 - 10:29 AM
ok guys i dont now how to do this but it sound pretty simple i want to use the function read to allow the user to put in a command or something so here's the thing i want them to be able to use the computer normaly but if they type home it does whatever

MY CODE NOW
——-
print("what would u like to do")
input = read() – here is the problem i want them to be able to type what they want like run a program or open a disk or whatever but if they type home do this
if input == "home" then
shell.run("clear")
end
Lyqyd #2
Posted 16 January 2013 - 11:11 AM
Moved to Ask a Pro.
grand_mind1 #3
Posted 16 January 2013 - 11:49 AM
If I understand you correctly, you want to run this program and if the user types "home" then it will do a specific task but otherwise do something else?

If that is what you want to do then I think this will work:

print("what would u like to do")
input = read()
if input == "home" then
	  shell.run("clear")
else
	   --stuff you want it to do if it is not "home"
end
If this is not what you want it do then I would need you to be more clear.