Advertisement
iMajesticButter

Untitled

Feb 16th, 2022
39
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.96 KB | None | 0 0
  1. local modem = peripheral.find("modem", rednet.open);
  2.  
  3. local idFilename = "id.lua"
  4.  
  5. local protocol = "Potion_Brewer_SCANNER"
  6. local logging = "Potion_Brewer_LOGGER"
  7.  
  8. local id = ""
  9.  
  10. function log(string)
  11. print(string)
  12. rednet.broadcast("[SCANNER_"..id.."] "..string, logging)
  13. end
  14.  
  15. function init()
  16.  
  17. -- get this selectors id
  18. local idFile = fs.open(idFilename, "r")
  19. if idFile then
  20. id = idFile.readAll()
  21. idFile.close()
  22. else
  23. log("failed to open id file: "..idFilename)
  24. end
  25.  
  26. log("ID file loaded, this selector is: "..id)
  27.  
  28. rednet.host(protocol, id)
  29.  
  30. --wait for an event to dispense the item
  31. while true do
  32. -- wait for a redstone event
  33. os.pullEvent("redstone")
  34. if rs.getInput("back") then
  35. -- send scanner event
  36. log("signal detected. broadcasting.")
  37. rednet.broadcast("EVENT_SCANNER_"..id, protocol)
  38. end
  39. end
  40. end
  41.  
  42. init()
  43.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement