Advertisement
Grexxity

Gif Projector

Dec 18th, 2022 (edited)
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.76 KB | None | 0 0
  1. local GithubRepo = "https://github.com/Grexxity/GifProjector/tree/main"
  2.  
  3. local sSavename = "GCC1.gif"
  4.  
  5. -----------------------------------------------------------
  6. local tbl = {}
  7. local args = {...}
  8. if not fs.exists("bbpack") then
  9. shell.run("pastebin","get","cUYTGbpb","bbpack")
  10. term.clear()
  11. end
  12.  
  13. if not fs.exists("GIF") then
  14. shell.run("pastebin","get","5uk9uRjC","GIF")
  15. term.clear()
  16. end
  17.  
  18. function APICheck(t, api)
  19.   for list,_ in pairs(t) do
  20.     if list == api then
  21.       return true
  22.     end
  23.   end
  24.   return false
  25. end
  26.  
  27.        if not (APICheck(_G,"GIF")) then
  28.         os.loadAPI("GIF")
  29.         end
  30.          if not (APICheck(_G,"bbpack")) then
  31.         os.loadAPI("bbpack")
  32.         end
  33.  
  34. for a,v in pairs(peripheral.getNames()) do
  35.   if (peripheral.getType(v) == "monitor" ) then
  36.         tbl[#tbl + 1] = peripheral.wrap(v)
  37.   end
  38. end
  39.  
  40. function display(i)
  41. local mon = tbl[tonumber(i)]
  42. mon.setTextScale(0.5)
  43. term.redirect(mon)
  44. local x,y = term.getSize()
  45. local Stored = x.."x"..y..sSavename
  46.  
  47. if not fs.exists("GIFs/"..Stored) then
  48. bbpack.fileSys(GithubRepo, "pain/")
  49. local image = GIF.loadGIF("pain/"..sSavename)
  50. local image = GIF.resizeGIF(image, x,y)
  51. GIF.saveGIF(image,"GIFs/"..Stored)
  52. end
  53. local image = GIF.loadGIF("GIFs/"..Stored)
  54. while true do
  55.     term.setBackgroundColour(image.backgroundCol)
  56.     term.clear()
  57.     parallel.waitForAny(
  58.         function()
  59.         for i = 1,#tbl do
  60.             GIF.animateGIF(image, math.floor((x - image.width) / 2) + 1, math.floor((y - image.height) / 2) + 1)
  61.             end
  62.         end)
  63. end
  64. end
  65. local PrgmName = shell.getRunningProgram()
  66. if args[1] == nil then if(#tbl >= 1) then for i = 1,#tbl do shell.openTab(PrgmName,i) end end elseif (tonumber(args[1]) >= 1) then display(args[1]) end
  67. shell.exit()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement