cadergator10

Accelerated Door Setup

Jan 31st, 2022 (edited)
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.52 KB | None | 0 0
  1. local component = require("component")
  2. local term = require("term")
  3. local io = require("io")
  4. local ser = require("serialization")
  5. local fs = require("filesystem")
  6. local modem = component.modem
  7.  
  8. term.clear()
  9. print("Enter 4 digit code")
  10. local text = term.read()
  11. local code = tonumber(text)
  12. modem.open(code)
  13. --local temp = {}
  14. --temp["analyzer"]=component.isAvailable("barcode_reader")
  15. modem.broadcast(code,"link",component.isAvailable("barcode_reader"))
  16. print("linking...")
  17. local e, _, from, port, _, msg = event.pull(3, "modem_message")
  18. if e then
  19.     print("successful link")
  20.     local stayIn = true
  21.     while stayIn do
  22.         local data
  23.         e, _, from, port, _, msg, data = event.pull("modem_message")
  24.         if msg == "print" then
  25.             print(data)
  26.         elseif msg == "write" then
  27.             term.write(data)
  28.         elseif msg == "getInput" then
  29.             text = term.read()
  30.             modem.send(from,port,text)
  31.         elseif msg == "clearTerm" then
  32.             term.clear()
  33.         elseif msg == "terminate" then
  34.             stayIn = false
  35.         elseif msg == "analyzer" then
  36.             text = event.pull("tablet_use")
  37.             modem.send(from,port,text)
  38.         end
  39.     end
  40.     print("Finished")
  41.     modem.close(code)
  42. else
  43.     modem.close(code)
  44.     print("failed to link")
  45. end
  46.  
  47. --modem.send(from,port,"print","")
  48. --modem.send(from,port,"getInput")
  49. --modem.send(from,port,"clearTerm")
  50. --modem.send(from,port,"terminate")
  51. --e, _, from, port, _, text = event.pull("modem_message")
Add Comment
Please, Sign In to add comment