qwerty6543, on 28 August 2013 - 04:36 PM, said:
I am trying to make a piston airlock and I was wondering how to make it so at a certant point it will go back to a place in the command, Here is my script:
redstone.setOutput("right", true)
print "Type 'open' or 'close' to Open or close the airlock."
function A()
print ""
write ">"
input = read()
if input == "open" then
print "Opening..."
redstone.setOutput("right", false)
A()
else
print "Command not recognised."
A()
end
if input == "close" then
print "Closing..."
redstone.setOutput("right", true)
A()
else
print "Command not recognised."
A()
end
end
When I try to run it it just says the first line and then goes to the normal console. Help?
You really should have posted a new topic instead of replying to an old one like this.
But to answer your question you dont even need to have a function. Just put certain parts of the code in a loop. You also do not need two if statements, you can do what your wanting using an elseif in the statement.
redstone.setOutput("right", true)
print "Type 'open' or 'close' to Open or close the airlock."
while true do
print ""
write ">"
input = read()
if input == "open" then
print "Opening..."
redstone.setOutput("right", false)
elseif input == "close" then
print "Closing..."
redstone.setOutput("right", true)
else
print "Command not recognized."
end
end