Leo_Verto

rednetconsole

Dec 22nd, 2012
533
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.88 KB | None | 0 0
  1.     local delay = 2
  2.     local tArgs = {...}
  3.     local id = -1
  4.      
  5.     term.clear()
  6.     term.setCursorPos(1,1)
  7.     rednet.open("top")
  8.      
  9.     if tonumber(tArgs[1]) ~= nil then
  10.       id = tonumber(tArgs[1])
  11.     end
  12.      
  13.     print("LeoSat Console -- Receiver ID: "..id)
  14.     print("-----------------\n")
  15.     while true do
  16.       write("> ")
  17.       cmd = read()
  18.       if cmd == "" then
  19.         print("Invalid Command!")
  20.       elseif cmd == "exit" then
  21.         return
  22.       else
  23.         if id == -1 then
  24.           rednet.broadcast(cmd)  
  25.         else
  26.           rednet.send(id, cmd)
  27.         end
  28.         os.startTimer(delay)  
  29.         while true do
  30.           evt, p1, p2, p3 = os.pullEvent()
  31.           if evt == "timer" then
  32.             break
  33.           elseif evt == "rednet_message" then
  34.             print(p1,": ",p2)
  35.           end
  36.         end
  37.       end
  38.     end
Advertisement
Add Comment
Please, Sign In to add comment