Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- elevatorLeft = "left"
- elevatorRight = "right"
- function checkElevators()
- toCall = ""
- --Left Elevator Check
- orange,lime,lightBlue = 0,0,0
- for i=0,2,1 do
- if rs.testBundledInput(elevatorLeft, colors.orange) then
- orange = orange + 1
- elseif rs.testBundledInput(elevatorLeft, colors.lightBlue) then
- lightBlue = lightBlue + 1
- elseif rs.testBundledInput(elevatorLeft, colors.lime) then
- lime = lime + 1
- end
- sleep(0.5)
- end
- if lime == 3 or lightBlue == 3 or orange == 3 then
- toCall = "left"
- end
- --Right Elevator Check
- orange,lime,lightBlue = 0,0,0
- for i=0,2,1 do
- if rs.testBundledInput(elevatorRight, colors.orange) then
- orange = orange + 1
- elseif rs.testBundledInput(elevatorRight, colors.lightBlue) then
- lightBlue = lightBlue + 1
- elseif rs.testBundledInput(elevatorRight, colors.lime) then
- lime = lime + 1
- end
- sleep(0.5)
- end
- if lime == 3 or lightBlue == 3 or orange == 3 then
- toCall = "right"
- end
- return toCall
- end
- function callElevator()
- if rs.testBundledInput("top", colors.white) then
- print("Elevator Called to Ground Floor!")
- toCall = checkElevators()
- if toCall == "left" then
- rs.setBundledOutput(elevatorLeft, 0)
- rs.setBundledOutput(elevatorLeft, colors.white)
- elseif toCall == "right" then
- rs.setBundledOutput(elevatorRight, 0)
- rs.setBundledOutput(elevatorRight, colors.white)
- end
- elseif rs.testBundledInput("top", colors.magenta) then
- print("Elevator Called to 1st Floor!")
- toCall = checkElevators()
- if toCall == "left" then
- rs.setBundledOutput(elevatorLeft, 0)
- rs.setBundledOutput(elevatorLeft, colors.magenta)
- elseif toCall == "right" then
- rs.setBundledOutput(elevatorRight, 0)
- rs.setBundledOutput(elevatorRight, colors.magenta)
- end
- elseif rs.testBundledInput("top", colors.yellow) then
- print("Elevator Called to 2nd Floor!")
- toCall = checkElevators()
- if toCall == "left" then
- rs.setBundledOutput(elevatorLeft, 0)
- rs.setBundledOutput(elevatorLeft, colors.yellow)
- elseif toCall == "right" then
- rs.setBundledOutput(elevatorRight, 0)
- rs.setBundledOutput(elevatorRight, colors.yellow)
- end
- end
- end
- --Run Above
- while true do
- local event = {os.pullEvent()}
- if event[1] == "redstone" then
- callElevator()
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment