Advertisement
minecraft_storm

hub code

Feb 24th, 2021 (edited)
178
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.88 KB | None | 0 0
  1. msg = nil
  2. local devices = 0
  3. while msg ~= "terminate" do
  4.    modem = peripheral.wrap("back")
  5.    modem.open(0)
  6.    os.queueEvent("run", 2, "nil")
  7.    sleep(0.1)
  8.    local event, par1, par2, par3, par4, par5 = os.pullEvent()
  9.    if event == "modem_message" then
  10.      side = par1
  11.      recive = par2
  12.      send = parm3
  13.      msg = par4
  14.      dist = par5
  15.    end
  16.    print(msg)
  17.    if msg == "new" then
  18.      devices = devices + 1
  19.      modem.transmit(1,devices+2,"send")
  20.    end
  21.    if event == "key" then
  22.        input = read()
  23.        if input == "send" then
  24.         input = nil
  25.         print("address")
  26.         while input == nil do
  27.             input = read()
  28.             sendaddress = tonumber(input)
  29.         end
  30.         print("message")
  31.         input = nil
  32.         while input == nil do
  33.             input = read()
  34.             sendmsg = input
  35.         end
  36.         modem.transmit(sendaddress,0,sendmsg)
  37.        end
  38.    end
  39. end
  40. print("stoped")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement