SHARE
TWEET

Client.lua

a guest Oct 21st, 2019 69 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. local c = require("component")
  2. local event = require("event")
  3. local term = require("term")
  4. local text = require("text")
  5. local port = 123
  6. local gpu = c.gpu
  7.  
  8. local cmds = {}
  9.  
  10. cmds[1]="reactor_off"
  11. cmds[2]="reactor_on"
  12.  
  13. local w, h = gpu.getResolution()
  14.  
  15. if c.isAvailable("modem") then
  16.   m = c.modem
  17.   if m.isWireless() then
  18.     print("Wireless modem detected!")
  19.     m.open(port)
  20.   else
  21.     print("Modem is not wireless! aborting...")
  22.     os.exit()
  23.   end
  24. end
  25.  
  26. term.clear()
  27. gpu.set(1,1,"-----------------------------------------")
  28. gpu.set(1,2,"- S E C U R E   B A S E   C O N T R O L -")
  29. gpu.set(1,3,"-----------------------------------------")
  30. term.setCursor(1,4)
  31.  
  32. function reply(_, ladr, adr, _, _, msg)
  33.   local x,y = term.getCursor()
  34.   term.setCursor(1,(y-2))
  35.   print("\n>"..msg)
  36. end
  37.  
  38. event.listen("modem_message",reply)
  39. local continue = true
  40. while continue do
  41.   local x,y = term.getCursor()
  42.   term.setCursor(1,(y+2))
  43.   local input = text.trim(term.read(nil,false,cmds,nil))
  44.   if input == "close" then
  45.     event.ignore("modem_message",reply)
  46.     os.exit()
  47.   else
  48.     m.send("44827529-209a-4cb6-afdd-2bf536d7cb93", port, input)
  49.   end
  50. end
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top