Skip to content

Instantly share code, notes, and snippets.

@Adidea
Last active August 29, 2015 14:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Adidea/d985a6abede037f51072 to your computer and use it in GitHub Desktop.
Save Adidea/d985a6abede037f51072 to your computer and use it in GitHub Desktop.
function module.Load(data)
--convert string to table
print(data)
local newData = http:JSONDecode(data) --convert json string to table
local function traverseTable(tab) --traverse table and hunt for C3(n,n,n) strings to convert to color3
for i,v in pairs(tab) do
if type(v) == "table" then
traverseTable(v)
elseif type(v) == "string" and v:match("^C3%(.+,.+,.+%)") then
--is a color3
local r,g,b = v:match("%((.+),(.+),(.+)%)")
tab[i] = Color3.new(r,g,b) --commenting out this line (or even using a different table prevents crash)
--could be the script requiring valid data crashing, but I don't see how. This snippet is the easiest to rip apart.
end
end
end
traverseTable(newData)
--print("save me: ", db.DisplayTable(newData))
return newData
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment