MadScience2728

MINECHATTER

Feb 23rd, 2022 (edited)
368
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. -- Awake
  2. print("Chatty turtle awake: Hello World!")
  3.  
  4. -- Setup wireless
  5. local modem = peripheral.wrap("left")
  6. modem.open(11)
  7. modem.open(12)
  8. print("Channel 11 and 12 are open")
  9.  
  10. --Setup Chatbox
  11. local chatbox = peripheral.wrap("right")
  12.  
  13. -- Setup receiving wireless messages
  14. function WaitForMessage(messageCompare)
  15.     while true do
  16.         local a,b,c,d,e,f = os.pullEvent("modem_message")
  17.         print("Message received: ")
  18.         print(e)
  19.         if(e == messageCompare) then
  20.             print("Message accepted")
  21.             break
  22.         end
  23.     end
  24. end
  25.  
  26. local cycleTracker = 0
  27.  
  28. -- Mine loop
  29. while true do
  30.     print("Waiting for start of next cycle")
  31.     WaitForMessage("_StartNextCycle")
  32.    
  33.     textOut = os.date() .. " >> Mine cycle: " .. tostring(cycleTracker)
  34.     print(textOut)
  35.     chatbox.sendMessage(textOut)
  36.     cycleTracker = cycleTracker + 1
  37.    
  38.     print(">>")
  39.     print(">>")
  40.     print(">>")
  41. end
  42.  
  43. print("Goodbye >>")
  44. read()
Add Comment
Please, Sign In to add comment