Code:
-- 3d array containing 7 2d arrays
a = {{{'b732da'}, {3, 0, 2}}, {{'d7a47a'}, {'b732da'}}, {{5, -10, 2}, {5, 3, 5}}, {{'da88aa'}, {'bjx8a8'}}, {{'b77a7a'}, {7, 5, 1}}, {{'has53js'}, {'nose321'}}, {{8, 3, 4}, {0, 0, 0}}}
loadedArray = {} -- Will be set in the save TTS object that you spawn
function save()
-- create object in save_slot variable
local save_slot = spawnObject() etc.
local i = 0
local data = "data = {"
-- z here will be {{'b732da'}, {3, 0, 2}} at first
for _,z in ipairs(a) do
i = i + 1
data = data .. "{"
-- x here will be {'b732da'} first (decided to input single values as arrays for simplicity)
-- then it will be {3, 0, 2}
local i2 = 0
for _,x in ipairs(z) do
i2 = i2 + 1
data = data .. "{"
local i3 = 0
for _,val in ipairs(x) do
i3 = i3 + 1
if type(val) == "string" then
if i3 == #x then
data = data .. "'" .. val .. "'"
else
data = data .. "'" .. val .. "', "
end
else
if i3 == #x then
data = data .. val
else
data = data .. val .. ", "
end
end
end
if i2 == #z then
data = data .. "}"
else
data = data .. "}, "
end
end
if i == #a then
data = data .. "}"
else
data = data .. "}, "
end
end
data = data .. "\nfunction onload() Global.setVar('loadedArray', data) end"
-- Haven't tested so might not work
save_slot.setLuaScript(data)
end
function onload()
loadData()
end
function loadData()
-- Load the data into the proper variables
end