Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local OPEN = colors.combine(colors.magenta, colors.orange)
- local CLOSE = colors.white
- local IS_OPEN = colors.yellow
- local IS_CLOSED = colors.lightBlue
- local CABLE = "top"
- local LEVER = "right"
- local function is_open()
- return redstone.testBundledInput(CABLE, IS_OPEN)
- end
- local function is_closed()
- return redstone.testBundledInput(CABLE, IS_CLOSED)
- end
- local function pulse_until(signal, fn)
- repeat
- redstone.setBundledOutput(CABLE, signal)
- sleep(0.2)
- redstone.setBundledOutput(CABLE, 0)
- sleep(0.2)
- until fn()
- print "Done"
- end
- while true do
- local door_should_open = redstone.getInput(LEVER)
- if door_should_open and not is_open() then
- print "Opening"
- pulse_until(OPEN, is_open)
- elseif not door_should_open and is_closed then
- print "Closing"
- pulse_until(CLOSE, is_closed)
- end
- os.pullEvent "redstone"
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement