Advertisement
Guest User

startup

a guest
Nov 28th, 2014
187
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.57 KB | None | 0 0
  1. local id = 1
  2.  
  3. rednet.open("bottom")
  4.  
  5. local bit = peripheral.wrap("top")
  6.  
  7. while true do
  8.   local e,i,m = os.pullEvent()
  9.  
  10.   if e == "rednet_message" then
  11.     local p = {id}
  12.     p.m = m
  13.     bit.transmit(p)
  14.     print("Rednet: "..m)
  15.   elseif e == "bitnet_message" then
  16.     if m[1] then
  17.       local t = false
  18.      
  19.       for k,v in pairs(m) do
  20.         if v == id then t = true end
  21.       end
  22.      
  23.       if not t then
  24.         rednet.broadcast(m.m)
  25.         table.insert(m,id)
  26.         bit.transmit(m)
  27.         print("Bitnet: "..m.m)
  28.       end
  29.     end
  30.   end
  31. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement