Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- term.clear()
- while true do
- local channel = 4021--NFC Message Receiving Channel(must match with the sending channel of NFC Sender Device)
- local mside = "top"--NFC Modem Side
- --Programm
- --Open Modem
- local modem = peripheral.wrap(mside)
- modem.open(channel)
- --Wait for distance check
- local devent, dsside, dschannel, drchannel, dsmess, dsdis = os.pullEvent("modem_message")
- if dsside == mside and dschannel == channel and dsmess == "hey" then
- --Reply to Distance Check
- modem.transmit(drchannel, channel, "okay fam")
- --Start listening
- local event, sside, schannel, rchannel, smess, sdis = os.pullEvent("modem_message")
- if sside == mside and schannel == channel and sdis < 3 then
- --What should be done with the message?
- if smess == "open plz" then
- redstone.setOutput("back", true)
- redstone.setOutput("right", true)
- sleep(2)
- redstone.setOutput("right", false)
- redstone.setOutput("back", false)
- end
- --Answer Device with success
- modem.transmit(rchannel, channel, "success")
- --End
- else
- --What to do if message failures, e.g. too high distance
- --Answer Device with failure
- modem.transmit(rchannel, channel, "failure")
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement