mjmac85

mainterm

Dec 26th, 2013
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.40 KB | None | 0 0
  1.  
  2. side = "left"
  3. local monitor = peripheral.wrap("right")
  4. rednet.open(side)
  5. term.redirect(monitor)
  6.  
  7.  
  8. monitor.write("Booted!")
  9.  
  10.  
  11. function clear()  -- screen-clearing function
  12.         term.clear()
  13.         term.setCursorPos(1,1)
  14. end
  15.  
  16. clear()
  17.  
  18. while true do
  19.         event, param1, param2 = os.pullEvent("rednet_message") -- with rednet messages, the second variable is the ID of
  20.                                                                                                                    --   the computer from which it was sent (integer) and
  21.                                                                                                                    --   the third is the message itself (string)
  22.                                                                                                                    -- parameter argument "rednet_message" limits the event
  23.                                                                                                                    --   accepted to just "rednet_message"
  24.         if param2 == "e" then -- if the message received is the string "e",
  25.             clear()
  26.                 break                    --   break the loop and exit
  27.         end
  28.         print(param2) -- if the loop isn't broke, it will print from which the ID came from and
  29.        
  30.                                                                --   the message itself
  31.  
  32. end
Advertisement
Add Comment
Please, Sign In to add comment