Let's say I have a JSONEncoded table that looks like this:
l = "[24,24,24,24,24,55,12,12,56,87,87,87,87,92]"
I want to turn it into something like this:
l = "[24.5,55,12.2,56,87.4,92]"
So the . is really an exponent symbol ^.
I've already tried my hand at this, and it somewhat worked. The problem is that it mixes parts my table up. Here is my script so far (although it uses a model's children for the table, not a JSONEncoded table). A script that formats JSONEncoded tables or a model's children would be helpful.
ImgScript = {} --The main holder for all of the color values
Temp = {} --The temporary holder for color values. This is so we can collect the '4, 4, 4' and turn it into '4^3'. Due to JSON limitations, the ^ has to be replaced with a . So when you see 4.3, remember it means 4, 4, 4!
for index, child in pairs(workspace.IMG:GetChildren()) do
n = child.BrickColor.Number
if n == Temp[1] then
Temp[2] = Temp[2] + 1
else
if #Temp == 0 then
table.insert(Temp, n)
table.insert(Temp, 1)
else
table.insert(ImgScript, Temp[1] .. '.' .. Temp[2])
Temp = {}
table.insert(Temp, n)
table.insert(Temp, 1)
end
end
end

4 comments
Is the order of the list significant?
You are going through the table in pairs. This does not specifically iterate over every index in order. Have you tried ipairs?
@BlueTaslem Yes the order of the list is significant
@randomsmileyface Changing pairs to ipairs didn't change the output. The numbers are still out of order, although the exponents are right.