Advertisement
Maineiac

client.lua

Jun 17th, 2019
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.92 KB | None | 0 0
  1. modem = peripheral.wrap("front")
  2. rednet.open("bottom")  
  3. connections = 0
  4. waitTimer = 0
  5. reboot = false
  6. term.clear()
  7. term.setCursorPos(1,1)
  8. function RunClient ()
  9.     while reboot == false do
  10.         local wire = {}
  11.         wire[1] = rs.testBundledInput("top", colors.white)
  12.         wire[2] = rs.testBundledInput("top", colors.orange)
  13.         wire[3] = rs.testBundledInput("top", colors.magenta)
  14.         wire[4] = rs.testBundledInput("top", colors.lightBlue)
  15.         wire[5] = rs.testBundledInput("top", colors.yellow)
  16.         wire[6] = rs.testBundledInput("top", colors.lime)
  17.         wire[7] = rs.testBundledInput("top", colors.pink)
  18.         wire[8] = rs.testBundledInput("top", colors.gray)
  19.         wire[9] = rs.testBundledInput("top", colors.lightGray)
  20.         wire[10] = rs.testBundledInput("top", colors.cyan)
  21.         wire[11] = rs.testBundledInput("top", colors.purple)
  22.         wire[12] = rs.testBundledInput("top", colors.blue)
  23.         wire[13] = rs.testBundledInput("top", colors.brown)
  24.         wire[14] = rs.testBundledInput("top", colors.green)
  25.         wire[15] = rs.testBundledInput("top", colors.red)
  26.         wire[16] = rs.testBundledInput("top", colors.black)
  27.         wire[17] = rs.testBundledInput("right", colors.white)
  28.         wire[18] = rs.testBundledInput("right", colors.orange)
  29.         wire[19] = rs.testBundledInput("right", colors.magenta)
  30.         wire[20] = rs.testBundledInput("right", colors.lightBlue)
  31.         wire[21] = rs.testBundledInput("right", colors.yellow)
  32.         wire[22] = rs.testBundledInput("right", colors.lime)
  33.         wire[23] = rs.testBundledInput("right", colors.pink)
  34.         wire[24] = rs.testBundledInput("right", colors.gray)
  35.         wire[25] = rs.testBundledInput("right", colors.lightGray)
  36.         wire[26] = rs.testBundledInput("right", colors.cyan)
  37.         wire[27] = rs.testBundledInput("right", colors.purple)
  38.         wire[28] = rs.testBundledInput("right", colors.blue)
  39.         wire[29] = rs.testBundledInput("right", colors.brown)
  40.         wire[30] = rs.testBundledInput("right", colors.green)
  41.         wire[31] = rs.testBundledInput("right", colors.red)
  42.         wire[32] = rs.testBundledInput("right", colors.black)
  43.         rednet.broadcast(wire, "percentprotocol")
  44.         waitTimer = 0
  45.         connections = connections+1
  46.         print("Client sending data... "..connections)
  47.         sleep(2)
  48.     end
  49.     rednet.broadcast("reboot", "rebootprotocol")
  50.     term.clear()
  51.     print("REBOOTING!!")
  52.     sleep(4)
  53.     os.reboot()
  54. end
  55. function RebootHandler()
  56.     while reboot == false do
  57.         print("RebootHandler waiting...")
  58.         modem.open(48745)
  59.         data = {os.pullEvent("modem_message")}
  60.         msg = data[5]
  61.         if msg == "reboot" then
  62.             print("Reboot command recieved")
  63.             reboot = true
  64.         else
  65.             term.setTextColor( colors.red )
  66.             print("Invalid command")
  67.             print("--------- Data -----------")
  68.             print("Event    : "..data[1])
  69.             print("Side     : "..data[2])
  70.             print("Channel  : "..data[3])
  71.             print("Return   : "..data[4])
  72.             print("Message  : "..data[5])
  73.             print("Distance : "..data[6])
  74.             print("---- End Transmission ----")
  75.             term.setTextColor( colors.white )
  76.         end
  77.     end
  78. end
  79. parallel.waitForAll(RebootHandler, RunClient)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement