dacman9

CCVideo

Jun 15th, 2022 (edited)
23
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.18 KB | None | 0 0
  1. local args = {...}
  2. local data
  3. local readPos = 1
  4.  
  5. local width
  6. local height
  7. local fps
  8. local tape = peripheral.find("tape_drive")
  9.  
  10. function readByte()
  11. readPos = readPos + 1
  12. return string.byte(data, readPos-1)
  13. end
  14.  
  15. function readShort()
  16. return readByte() * 256 + readByte()
  17. end
  18.  
  19. --Code
  20. local page = http.get(args[1],{},true)
  21. data = page.readAll()
  22. page.close()
  23.  
  24. if (tape ~= nil) then
  25. tape.seek(-1000000000)
  26. tape.play()
  27. end
  28.  
  29. width = readShort()/2
  30. height = readShort()/3
  31. fps = readByte()
  32.  
  33. while (readPos < #data) do
  34. local pSize = readByte()
  35. for i = 1, pSize do
  36. term.setPaletteColor(2^(i-1), colors.packRGB(readByte()/255, readByte()/255, readByte()/255))
  37. --readByte()
  38. --readByte()
  39. --readByte()
  40. end
  41. for y = 1, height, 1 do
  42. local text = ""
  43. local fg = ""
  44. local bg = ""
  45. for x = 1, width, 1 do
  46. text = text..string.char(readByte())
  47. fg = fg..string.format("%x",readByte())
  48. bg = bg..string.format("%x",readByte())
  49. end
  50. term.setCursorPos(1,y)
  51. term.blit(text,fg,bg)
  52. end
  53. sleep(1/fps)
  54. end
  55. sleep(2)
  56. tape.stop()
Add Comment
Please, Sign In to add comment