Guest User

Chat

a guest
Jun 11th, 2016
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.55 KB | None | 0 0
  1. os.loadAPI("eAPI")
  2. os.loadAPI("json")
  3. local allmsg={}
  4.  
  5. function writeHex(color,txt)
  6. local colorBank={FF55FF={colors.pink}}--,AA0000=colors.red,00AA00=colors.green,00AAAA=colors.cyan,000000=colors.black}
  7. if color and txt then
  8. term.setTextColor(colorBank[color])
  9. write(txt)
  10. term.setTextColor(colors.white)
  11. end
  12. end
  13.  
  14. writeHex(FF55FF,txt)
  15. function main()
  16. local x=http.get("http://tekkit.craftersland.net:25800/up/world/world/").readAll()
  17. local data=json.decode(x)
  18. for _,x in pairs(data['updates']) do
  19. if x["type"]=="chat" and not eAPI.table_contains(allmsg,x["playerName"].." | "..x["message"]) then
  20. local lines={}
  21. f=fs.open("chat.temp","w")
  22. f.write(x["playerName"]:gsub("'>","'\n>"))
  23. f.close()
  24. for tmp in io.lines("chat.temp") do lines[#lines+1]=tmp end
  25. for _,ln in pairs(lines) do
  26. local color=ln:match("color:#(.-)'")
  27. local msg=ln:match(">(.-)<")
  28. end
  29. print(x["account"].." | "..x["message"])
  30. eAPI.tbInsert(allmsg,x["playerName"].." | "..x["message"])
  31. elseif x["type"]=="playerjoin" and not eAPI.table_contains(allmsg,x["account"].." has joined the game.") then
  32. eAPI.cprint(x["account"].." has joined the game.",colors.orange)
  33. eAPI.tbInsert(allmsg,x["account"].." has joined the game.")
  34. elseif x["type"]=="playerquit" and not eAPI.table_contains(allmsg,x["account"].." has left the game.") then
  35. eAPI.cprint(x["account"].." has left the game.",colors.orange)
  36. eAPI.tbInsert(allmsg,x["account"].." has left the game.")
  37. end
  38. end
  39. end
  40.  
  41. while true do
  42. main()
  43. sleep(1)
  44. end
Advertisement
Add Comment
Please, Sign In to add comment