Advertisement
Axprotss

Helping a person#1

Aug 15th, 2022 (edited)
766
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 23.52 KB | Gaming | 0 0
  1. local http = game:GetService("HttpService""png" then
  2.         return warn("[IMAGE RENDER V2]: Image must be a png!")
  3.     end
  4.     local requestedImage = http:GetAsync(urlToRender)
  5.     print(requestedImage)
  6. end
  7.  
  8. function renderFromJSON(jsonTable)
  9.     local decodedJSON = http:JSONDecode(jsonTable)
  10.     local x = 1
  11.     local y = 1
  12.     local curX = 1
  13.     local skipAmount = 0
  14.     local needToRepeatX = 55
  15.  
  16.     local startY = owner.Character.HumanoidRootPart.Position.Y
  17.     local startX = owner.Character.HumanoidRootPart.Position.X
  18.  
  19.     local start = os.time()
  20.  
  21.     for i=1,35 do
  22.         curX=1
  23.         y = y+1
  24.         needToRepeatX=27
  25.         for i=1,needToRepeatX do
  26.             curX = i
  27.  
  28.             local foundColor = false
  29.             local chosenColorTable = nil
  30.             local newPixel = Instance.new("Part")
  31.             newPixel.Position = Vector3.new((startX+curX),startY,y)
  32.  
  33.             for _, pixelColor in pairs(jsonTable) do
  34.                 if jsonTable[_][4] == curX and jsonTable[_][5] == y-1 then
  35.                     chosenColorTable = pixelColor
  36.                     newPixel.BrickColor = BrickColor.new(Color3.fromRGB(pixelColor[1], pixelColor[2], pixelColor[3]))
  37.                     newPixel.Size = Vector3.new(1,1,1)
  38.                     foundColor = true
  39.                 end      
  40.             end
  41.  
  42.             if foundColor == false then newPixel.Transparency = 1 end
  43.  
  44.             --[[
  45.             if foundColor == false then newPixel.Transparency = 1 else
  46.                 for _, pixelColor in pairs(jsonTable) do
  47.                     if pixelColor[1] == chosenColorTable[1] and pixelColor[2] == chosenColorTable[2] and pixelColor[3] == chosenColorTable[3] then
  48.                         skipAmount = skipAmount+1
  49.                         needToRepeatX = needToRepeatX-1
  50.                         curX=curX+1
  51.                         newPixel.Size = Vector3.new(1+skipAmount,1,1)
  52.                         newPixel.Position = Vector3.new((startX+curX)+1,startY,y)
  53.                     else
  54.                         break
  55.                     end            
  56.                 end
  57.             end        
  58.             --]]
  59.             newPixel.Material = Enum.Material.SmoothPlastic
  60.             newPixel.Anchored = true
  61.             --newPixel.Position = Vector3.new((startX+curX)-(skipAmount),startY,y)
  62.  
  63.             newPixel.Parent = workspace
  64.             task.wait(0.0375)
  65.             x = x+1
  66.         end
  67.     end
  68.     print("Done! It took ".. start-os.time().. " seconds!")
  69. end
  70.  
  71. owner.Chatted:Connect(function(m)
  72.     if m:sub(1,2):lower() == "#r" then
  73.         renderFromJSON(torenderJSON)
  74.     end
  75. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement