I've been trying to make my own 3 floor elevator program, and yeah.. I'm stuck.
I have 3 floors at different heights, and my elevator runs on carriage engine which moves as long as it has redstone signal powering it. Inside the elevator floor corner is a built in redstone block which sends redstone signal to the either lime, black or yellow wire whenever it reaches on of those 3 floors. On the left side of the computer is bundled cable.
Cable colors:
Red - carriage engine down
Green - carriage engine up
Lime - first floor
Yellow - second floor
black - third floor
And this is what I wrote so far..
print("Press 0 if you'd like to call the elevator.")
print("Select the floor by entering 1,2 or 3.")
input = read()
if input == "0" then
print("Elevator is on the way. Please wait.")
if rs.getBundledInput("left", colors.lime) then
end
if rs.getBundledInput("left". colors.yellow) then
rs.setBundledOutput("left", colors.green, true)
sleep(12)
rs.setBundledOutput("left", colors.green, false)
end
if rs.getBundledInput("left", colors.black) then
rs.setBundledOutout("left", colors.green, true)
sleep(17)
rs.setBundledOutout("left", colors.green, false)
end
elseif input == "1" then
print("Elevator is on this floor.")
elseif input == "2" then
sleep(4)
rs.setBundledOutput("left", colors.red, true)
sleep(12)
rs.setBundledOutput("left", colors.red, false)
os.shutdown()
elseif input == "3" then
sleep(4)
rs.setBundledOutput("left", colors.red, true)
sleep(17)
rs.setBundledOutput("left", colors.red, false)
os.shutdown()
end
else
print("Wrong input, please try again.")
sleep(2)
os.shutdown()
end
Here's what I want in short:
If standing on first floor and I enter "0", I want the program to check which one those 3 wires (either lime, black or yellow) have redstone signal <On> and then depending on that it outputs redstone signal to the carriage engine for either 12 or 17 seconds (if the elevator was on second floor then 12, if third then 17) and if the elevator is on the first floor then it does nothing.
If I'm standing on first floor and I press "2" it should wait 4 seconds for me to enter in the elevator and send redstone signal to the red wire (which is for carriage engine - down) for 12 seconds
If I'm standing on first floor and I press "3" it should wait 4 seconds for me to enter in the elevator and send redstone signal to the red wire (which is for carriage engine - down) for 17 seconds
And I know that I'll need to change timings for second and third floor computer.
There's a lot of things I still don't know about Computercraft, and hence why my program doesn't work & I'm here.
I'd appreciate any help from you guys!