Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local distance = 6.4
- local modemSide = "top"
- local outputSide = "front"
- local flipped = false
- local amountInactive = 0
- function inactiveLoop()
- while true do
- os.sleep(.2)
- amountInactive = amountInactive + 1
- if amountInactive >= 4 then
- amountInactive = 4
- redstone.setOutput(outputSide, not flipped)
- end
- end
- end
- function mainLoop()
- local modem = peripheral.wrap(modemSide)
- modem.open(188)
- while true do
- local event, modemSide, senderChannel, replyChannel, message, senderDistance = os.pullEvent("modem_message")
- if message == "opendoor" and senderDistance <= distance then
- amountInactive = 0
- redstone.setOutput(outputSide, flipped)
- end
- end
- end
- parallel.waitForAll(inactiveLoop, mainLoop)
Add Comment
Please, Sign In to add comment