william200027

Twitch Chat in minecraft

May 31st, 2021 (edited)
932
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.30 KB | None | 0 0
  1. google = peripheral.wrap("top")
  2. chat = peripheral.wrap("right")
  3. os.loadAPI("json")
  4. monitor = peripheral.wrap("back")
  5. monitor.setBackgroundColor(colors.black)
  6. monitor.clear()
  7. google.clear()
  8. monitor.setTextScale(1.7)
  9. write = "test"
  10.  
  11. while true do
  12.  
  13.     dat = http.get("http://51.83.42.69:9000/data.json").readAll()
  14.     data = json.decode(dat)
  15.  
  16.     colo = colors[data.color]
  17.     username = data.username
  18.     message = data.message
  19.    
  20.     print(colo)
  21.    
  22.     if write == message then
  23.     else
  24.         monitor.scroll(-3)
  25.        
  26.         monitor.setCursorPos(1,1)
  27.         monitor.setTextColor(colors.white)
  28.         monitor.write("---------------------------------------------------")
  29.         monitor.setCursorPos(1,2)
  30.         monitor.setTextColor(colo)
  31.         monitor.write(username.." : "..message)
  32.         chat.sendMessage(username.." : "..message)
  33.         google.clear()
  34.         google.drawCenteredString(username.." : "..message,400,10,100000000000000000000)
  35.         monitor.setCursorPos(1,3)
  36.         monitor.setTextColor(colors.white)
  37.         monitor.write("---------------------------------------------------")
  38.        
  39.         write = message
  40.         redstone.setOutput("left",true)
  41.         sleep(0.1)
  42.         redstone.setOutput("left",false)
  43.     end
  44.    
  45.     sleep(0.1)
  46.  
  47. end
Advertisement
Add Comment
Please, Sign In to add comment