term.clear()
term.setCursorPos(1,1)
left = 1
right = 2
password = "off"
while left<right do
rs.setOutput("left", true)
term.clear()
term.setCursorPos(1,1)
print("Password: ")
a = read()
if a == password then
left = left + 2
end
end
Also here is the pastebin link if you want it http://pastebin.com/L4eVG8pJ
3 replies to this topic
#1
Posted 05 August 2012 - 08:58 PM
HI guys, I have recently gotten into computercraft with in tekkit and I am still a beginner at this and my friend asked me to write him a simple code where the computer outputs redstone power from the left side by default and can be turned on/off with a password. So i tried my hand at making the program and i got it to output the power and ask for the password but when i put the password in it does nothing at all and the output stays on. If you need anymore information please ask for it and thanks for the help if you do help
#2
Posted 05 August 2012 - 09:33 PM
try this code:
that *should* work
term.clear()
term.setCursorPos(1,1)
rs.setOutput("left", true)
write("Password: ")
pss = read()
if pss = "off" then
rs.setOutput("left", false)
end
write("Password: ")
pss = read()
if pss = "on" then
shell.run("The Program's Name")
end
that *should* work
#3
Posted 05 August 2012 - 09:46 PM
Try with this:
rs.setOutput("left", true)
while true do
term.clear()
term.setCursorPos(1, 1)
write("Password: ")
local pass = read("*")
if pass == "Your Password Here" then
rs.setOutput("left", not rs.getOutput("left"))
end
end
#4
Posted 06 August 2012 - 01:55 AM
Your problem is that you never put the code in to switch the output off
Use this:
Use this:
password = "off"
rs.setOutput("left", true)
while true do
term.clear()
term.setCursorPos(1,1)
print("Password: ")
a = read()
if a == password then
print("correct")
rs.setOutput("left", false)
sleep(2)
-- put the word return here if you want the program to end after getting the password right
else
print("Incorrect")
sleep(2)
end
end
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users











