I have a feeling using tables would make the data larger than it would using a string and then parsing it when you want to load it. I’m not quite sure what the limitations are for data stores though.
It’s to store all parts’ respective information on a player’s plot (sandbox-esque game). I know you can’t store some data types like Vector3s and Color3s and what not, so my question really is:
Is serialising it with tables okay?
local data = {
size = {1, 2, 3}
position = {1, 1, 1}
color = {1, 1, 1}
}
Or using a string?
local data = "(3,4,2) (2,2,2) (0,1,0)"
I tried to muster up what I knew about string manipulation already, and got this:
local data = "(3,4,2) (2,2,2) (0,1,0)"
local pattern = "([%d+^%p]+) ([%d+^%p]+) ([%d+^%p]+)"
local function parseData()
local position, size, color = data:match(pattern)
local parsed = {
position = position;
size = size;
color = color;
}
for i, data in next, parsed do
parsed[i] = data:gsub("%,", " ")
parsed[i] = parsed[i]:gsub("%(", "")
parsed[i] = parsed[i]:gsub("%)", "")
end
for name, data in next, parsed do
local a, b, c = data:match("(%d+) (%d+) (%d+)")
print(name:upper() .. " : " .. data)
end
end
parseData()
Which prints the following:
SIZE : 2 2 2
POSITION : 3 4 2
COLOR : 0 1 0