Advertisement
PeachGaming

ticketdock

Mar 24th, 2017
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.14 KB | None | 0 0
  1. term.clear()
  2. while true do
  3. local channel = 4021--NFC Message Receiving Channel(must match with the sending channel of NFC Sender Device)
  4. local mside = "top"--NFC Modem Side
  5. --Programm
  6. --Open Modem
  7. local modem = peripheral.wrap(mside)
  8. modem.open(channel)
  9. --Wait for distance check
  10. local devent, dsside, dschannel, drchannel, dsmess, dsdis = os.pullEvent("modem_message")
  11. if dsside == mside and dschannel == channel and dsmess == "hey" then
  12. --Reply to Distance Check
  13. modem.transmit(drchannel, channel, "okay fam")
  14. --Start listening
  15.  
  16. local event, sside, schannel, rchannel, smess, sdis = os.pullEvent("modem_message")
  17. if sside == mside and schannel == channel and sdis < 3 then
  18.  --What should be done with the message?
  19. if smess == "open plz" then
  20. redstone.setOutput("back", true)
  21. redstone.setOutput("right", true)
  22. sleep(2)
  23. redstone.setOutput("right", false)
  24. redstone.setOutput("back", false)
  25. end
  26.  --Answer Device with success
  27.  modem.transmit(rchannel, channel, "success")
  28.  --End
  29.  
  30. else
  31.  --What to do if message failures, e.g. too high distance
  32.  
  33.  --Answer Device with failure
  34.  modem.transmit(rchannel, channel, "failure")
  35.  
  36. end
  37. end
  38. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement