Advertisement
kd8lvt

Example for TwitchAPI PreConfigured for Friends of Kd8lvt

Jan 4th, 2016
162
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.96 KB | None | 0 0
  1. --::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  2. --::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  3. --::                    TwitchAPI Example                           ::
  4. --::                        By: Kd8lvt                              ::
  5. --::       --------------------------------------------------       ::
  6. --::       Shows:                                                   ::
  7. --::          If the streamer is live:                              ::
  8. --::              Latest Follower                                   ::
  9. --::              Viewer Count                                      ::
  10. --::          Otherwise:                                            ::
  11. --::              That they aren't live                             ::
  12. --::       --------------------------------------------------       ::
  13. --::       To configure:                                            ::
  14. --::           Change the streamers in the 'streamers' table        ::
  15. --::       --------------------------------------------------       ::
  16. --::                                                                ::
  17. --::                                                                ::
  18. --::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  19. --::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  20. os.loadAPI("twitchapi")
  21. m = peripheral.find("monitor")
  22. m.setTextScale(2) --Getting around a CC bug
  23. m.setTextScale(1)
  24. liveX = 5
  25. notLiveX = 1
  26. startY = 1
  27. color = m.isColor()
  28. streamers = {
  29.   "choobtastic",
  30.   "wolftaz",
  31.   "itanshi",
  32.   "soraleoyfaith",
  33.   "odduser",
  34.   "3lementalstudios",
  35.   "D3athB0b",
  36.   "lokbatch",
  37.   "kd8lvt"
  38. }
  39. function nextY()
  40.   x,y = m.getCursorPos()
  41.   newY = y + 1
  42. end
  43. function streamerloop(streamer)
  44.   nextY()
  45.   m.setCursorPos(notLiveX,newY)
  46.   if color then  
  47.     if twitchapi.checkLive(streamer) then
  48.       m.setTextColor(colors.green)
  49.       m.write(streamer.." is live!")
  50.       m.setTextColor(colors.white)
  51.       nextY()
  52.       m.setCursorPos(liveX,newY)
  53.       m.write(streamer.."'s Latest Follower: "..twitchapi.lastFollower(streamer))
  54.       nextY()
  55.       m.setCursorPos(liveX,newY)
  56.       m.write(streamer.."'s Viewer Count: "..twitchapi.viewerCount(streamer))
  57.     else
  58.       m.setTextColor(colors.red)
  59.       m.write(streamer.." is not live!")
  60.       m.setTextColor(colors.white)
  61.     end
  62.   else
  63.     if twitchapi.checkLive(streamer) then
  64.       m.write(streamer.." is live!")
  65.       nextY()
  66.       m.setCursorPos(liveX,newY)
  67.       m.write(streamer.."'s Latest Follower: "..twitchapi.lastFollower(streamer))
  68.       nextY()
  69.       m.setCursorPos(liveX,newY)
  70.       m.write(streamer.."'s Viewer Count: "..twitchapi.viewerCount(streamer))
  71.     else
  72.       m.write(streamer.." is not live!")
  73.     end
  74. end
  75. function main()
  76.   while true do
  77.     m.clear()
  78.     for k,v in pairs(streamers) do
  79.       streamerloop(streamers[k])
  80.       sleep(5)
  81.     end
  82.   sleep(30)
  83.   m.setCursorPos(1,1)
  84.   end
  85. end
  86. main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement