Advertisement
EnderReaper64

ComputerCraft Image Loader

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