Advertisement
karelvysinka

Load GIF MONITOR Computercraft

Dec 29th, 2019
376
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.16 KB | None | 0 0
  1. local version = 1.8
  2.  
  3. --History:
  4. --Load GIF MONITOR Computercraft
  5. --This is testing version
  6. --1.8 - fixed problem delete gifurl.gif (error reboot) 2.1.2020
  7. --Plan:
  8. -- create list gifs
  9. -- create menu for stop program
  10. ---------
  11. --Source:
  12. ---------
  13. --http://www.computercraft.info/forums2/index.php?/topic/23056-gif-api/
  14. --Resize your GIF: https://ezgif.com/resize
  15. ----------
  16. --Contact:
  17. ----------
  18. --Author: ScherryCZ - scherry@email.cz
  19. --Language: English, Czech
  20. --WWW: https://mineworldcc.blogspot.com/
  21.  
  22. function Start()
  23.     shell.run("delete gifurl.gif")
  24.     if fs.exists("perna.st") then
  25.         print(fs.exists("perna.st"))
  26.                 if fs.exists("perna.st") then
  27.                     loadGif()
  28.                 else
  29.                     print("Default GIF not exist. You paste URL GIF. Thx.")
  30.                 end
  31.     end
  32.  
  33.     write("Load new GIF? y/n: ")
  34.     local newgif = read()
  35.  
  36.     write("Pernamently GIF on reboot? y/n: ")
  37.     local gif_perna = read()
  38.  
  39.         if gif_perna == "y" then
  40.             local h = fs.open("perna.st", "w")
  41.             h.write("perna")           
  42.             h.close()
  43.             print("Program set pernament work.")
  44.             shell.run("delete gifurl.gif")
  45.         end
  46.  
  47.         if newgif == "y" then
  48.             Newgifs()
  49.         end
  50.  
  51.         if newgif == "n" then
  52.         print(fs.exists("gifurl_local.gif"))
  53.                 if fs.exists("gifurl_local.gif") then
  54.                     loadGif()
  55.                 else
  56.                     print("Default GIF not exist.")
  57.                     Start()                
  58.                 end
  59.         end
  60. print("This command is bad. You please write y or n.")
  61. Start()
  62. end
  63.  
  64. function Newgifs()
  65.     print("IF URL = BLANK (THEN START WITH LAST IMAGE.")
  66.     write("URL GIF and PRESS ENTER: ")
  67.     local gifurl = read()
  68.     print("Your URL: "..gifurl)
  69.     print("... Please WAIT.. GIF IMAGE CONVERSION IN PROCESS...")
  70.     finalurl = "bbpack mount "..gifurl.." gifurl.gif"
  71.     print(finalurl)
  72.     shell.run("pastebin get BMYUSgfV GIF")
  73.     shell.run("pastebin get Tk0UG8fm bbpack")
  74.     --LOAD GIF ON DISK from URL
  75.     -- load gif (only one gif on root!)
  76.     shell.run(finalurl)
  77.     print("Deleting default GIF...")
  78.     shell.run("delete gifurl_local.gif")
  79.     shell.run("copy gifurl.gif gifurl_local.gif")
  80.     print("GIF IMAGE CONVERSION IN PROCESS FOR BIG IMAGES ... Please WAIT ...")
  81.     print("PRESS CTRL + T = Terminate program")
  82.     print("And write REBOOT for START program.")
  83.     loadGif()
  84. end
  85.  
  86. function loadGif()
  87.     print("LOADADING GIF...")
  88.     os.loadAPI("GIF")
  89.     local mon = peripheral.find("monitor")
  90.     local gifs = fs.find("*.gif")  -- Note: fs.find() is case-sensitive, even if your file system isn't.
  91.     mon.setTextScale(0.5)
  92.     local x, y = mon.getSize()
  93.     while true do for i = 1, #gifs do
  94.         local image = GIF.loadGIF(gifs[i])
  95.         mon.setBackgroundColour(image[1].transparentCol or image.backgroundCol)
  96.         mon.clear()
  97.         GIF.animateGIF(image, math.floor((x - image.width) / 2) + 1, math.floor((y - image.height) / 2) + 1, mon)
  98.         print(a)
  99.     end
  100. end
  101.  
  102. function Update()
  103. --------------------------------------------------------------------------------------------
  104. --FUNCTION FOR UPDATE
  105. --------------------------------------------------------------------------------------------
  106.  
  107.     print("ERROR UPDATE...")
  108. end
  109.  
  110.  
  111. end
  112.  
  113.  
  114.  
  115. ----------------------------------------------------------------------
  116. --START
  117. ----------------------------------------------------------------------
  118. Start()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement