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

elevator controller

Started by Revolution, 25 November 2012 - 07:34 AM
Revolution #1
Posted 25 November 2012 - 08:34 AM
i have been making a elevator controller in my computer train station but when i use the code i wrote i put in Up and it disappears i don't know why just wanted to know if you guys knew why? I coded it so that you put in Up and it sleeps for 3 seconds for you to get on then set the Redstone on for 12 seconds so it reaches the top and turns off after. but it doesn't do that.

term.clear()
term.setCursorPos(16,1)
print "Elevator Control"

while true do
term.setCursorPos(1,3)
term.clearLine()
write "Up or Down:"
local input = string.lower( read() )

if input == "Up" then
print("Elevating in 3 seconds")
sleep(3)
rs.setOutput("right", true)
sleep(12)
rs.setOutput("right", false)
end

if input == "Down" then
print("Elevating in 3 Seconds")
sleep(3)
rs.setOutput("left", true)
sleep(12)
rs.setOutput("left", false)
end
end

Sorry for not putting it in properly im coping from a server
dissy #2
Posted 25 November 2012 - 08:44 AM
You are calling string.tolower on the read command, so the input is "up" which is not equal to "Up"
Revolution #3
Posted 25 November 2012 - 08:50 AM
Thanks! its working now