Advertisement
EnderReaper64

ComputerCraft Image Loader

Jul 10th, 2023 (edited)
1,274
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.99 KB | None | 0 0
  1. print("What is the image you want to have? (Image Address)")
  2. local image = read()
  3. local monitor = peripheral.wrap("top")
  4. monitor.setTextScale(0.5)
  5. local SizeX, SizeY = monitor.getSize()
  6. SizeX = SizeX * 2
  7. SizeY = SizeY * 3
  8. local image = http.post(
  9.     "https://computercraftimage.enderreaper64.repl.co/post",
  10.     '{"Image":"' .. image .. '", "SizeX":' .. tostring(SizeX) .. ', "SizeY":' .. tostring(SizeY) .. '}',
  11.     {["Content-Type"] = "application/json"}
  12. )
  13.  
  14. shell.run("wget https://github.com/9551-Dev/apis/raw/main/pixelbox_lite.lua")
  15.  
  16. local imageData = image.readAll()
  17. local count = 0
  18. local count2 = 1
  19. os.loadAPI("json")
  20.  
  21. local data = json.decode(imageData)
  22. for a,b in pairs(data[1][1]) do
  23.     monitor.setPaletteColor(2^(a-1), tonumber(b))
  24.     print(a-1, tonumber(b), b)
  25. end
  26.  
  27. local box = require("pixelbox_lite").new(monitor)
  28.  
  29. for y = 1, SizeY do
  30.     for x = 1, SizeX do
  31.         box.CANVAS[y][x] = 2^tonumber(data[1][2][tostring(y-1)][tostring(x-1)])
  32.     end
  33. end
  34.  
  35. box:render()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement