Hey there,
I’ve been working on a live screen renderer script (for testing, don’t plan on doing some banunos stuff), and I’ve come across an issue while looping through a table of colors.
Whenever I loop through the color list, there is a massive lag spike (a few actually!) due to using pairs
. I’ve come across this as the issue while testing out what the main issue was.
Video:
Code:
local Current = Queue[1]
if Current and #Queue >= Threshold then
local Pixels = Current.Pixels
local List = Current.List
local Published = List.Time
local Frames = List.Frames
local Delay = 1 / #Frames
local Time = ostime()
warn("Now rendering frames, received", Time - Published, "seconds ago")
warn("Delaying by", Delay)
for Frame, Colors in pairs(Frames) do
warn("Rendering Frame", Frame)
for XPos, ColorList in pairs(Colors) do
local Found = Pixels[XPos]
if Found then
for Index, Part in pairs(Found) do
local Color = ColorList[Index]
if Color then
local Converted = C3RGB(up(Color))
Part.Color = Converted
end
end
end
end
Wait:Wait(Delay)
end
remove(Queue, 1)
Is there any way to speed up pairs
, or are there any alternatives I can use to remove the giant lag spikes (aside from decreasing the screen size)?