Advertisement
moo3oo3oo3

Pocket Phone Tekxit 3 Pack

Jul 30th, 2019
167
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.14 KB | None | 0 0
  1. local monitor = peripheral.find("monitor")
  2. if (monitor) then
  3.     term.redirect(monitor)
  4. end
  5.  
  6. term.clear()
  7. term.setCursorPos(1, 1)
  8.  
  9. local modem = peripheral.find("modem")
  10. local channel = 355
  11. modem.open(channel)
  12.  
  13. local speaker = peripheral.find("speaker")
  14.  
  15. if (os.getComputerLabel() == nil) then
  16.     os.setComputerLabel("Server")
  17. end
  18.  
  19. while (true) do
  20.         local event, keycode, isHeld, _, message, _ = os.pullEvent()
  21.  
  22.         if (event == "modem_message") then
  23.  
  24.             if (speaker) then
  25.                 speaker.playSound("minecraft:entity.player.levelup", 3, 0.5297)
  26.             end
  27.  
  28.             if (message.label and message.message and message.replies) then
  29.  
  30.                 term.setTextColor(colors.lightBlue)
  31.                 write("[" .. textutils.formatTime(os.time(), true ) .. "] (" .. message.label .. "): ")
  32.                 term.setTextColor(colors.white)
  33.                 write(message.message .. "\n")
  34.  
  35.                 local next = next   --For efficiency
  36.                 if (next(message.replies) ~= nil) then
  37.                     term.setTextColor(colors.yellow)
  38.                     print("Press any key to mark as read")
  39.                     os.pullEvent("key")
  40.                 end
  41.  
  42.                 modem.transmit(channel, channel, {label = os.getComputerLabel(), message = "continue"})
  43.             end
  44.         end
  45.  
  46.     end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement