Advertisement
nagoL2015

chatbot_minion

Oct 1st, 2017
683
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.68 KB | None | 0 0
  1. send = 119
  2. receive = 121
  3.  
  4. os.pullEvent = os.pullEventRaw
  5.  
  6. local chat = peripheral.find("chat_box")
  7. chat.setName("DLA")
  8. chat.setDistance(math.huge)
  9.  
  10. modem = peripheral.wrap("top")
  11. modem.open(receive)
  12.  
  13. function say(text)
  14.   chat.say(text)
  15. end
  16.  
  17. function modemListen()
  18.     while true do
  19.       local _, _, _, _, text, _ = os.pullEvent("modem_message")
  20.        if text == "update" then
  21.          os.reboot()
  22.        else
  23.          say(text)
  24.        end
  25.     end
  26. end
  27.  
  28. function chatListen()
  29.     while true do
  30.       _, _, username, text = os.pullEvent("chat_message")
  31.       modem.transmit(send, receive, {username, text})
  32.     end
  33. end
  34.  
  35. parallel.waitForAll(chatListen, modemListen)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement