Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- monitor = peripheral.wrap("top")
- monitor.clear()
- -- Gets the redstone state
- local function RP()
- return redstone.getInput("left")
- end
- local function SetClose()
- monitor.setBackgroundColor(colors.red)
- monitor.clear()
- monitor.setTextColor(colors.lime)
- monitor.setCursorPos(1,1)
- monitor.write("Closing...")
- sleep(12)
- monitor.clear()
- end
- local function SetOpen()
- monitor.setBackgroundColor(colors.red)
- monitor.clear()
- monitor.setTextColor(colors.lime)
- monitor.setCursorPos(1,1)
- monitor.write("Opening...")
- monitor.setCursorPos(1,2)
- monitor.write("Please wait!")
- sleep(12)
- monitor.setBackgroundColor(colors.lime)
- monitor.clear()
- end
- local lastRS = RP()
- if lastRS then
- print("Initial State: Opened")
- monitor.setBackgroundColor(colors.lime)
- monitor.clear()
- else
- print("Initial State: Closed")
- monitor.setBackgroundColor(colors.red)
- monitor.clear()
- end
- while true do
- local newRS = RP()
- if not newRS == lastRS then
- lastRS = newRS
- if newRS then
- print("Now opening...")
- SetOpen()
- else
- print("Now closing...")
- SetClose()
- end
- end
- sleep(0.1)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement