continuing with this, from the sample code/storage/saveTable/main.lua file, in the function loadData(), it calls out a library str that is not found by the simulator. it doesn’t look like a typo for string. it is used to split the line up & reformat it.
my goal is to take a table, store in a file, retrieve it later and put into the original table it came from via an intermediate table;
Where is the ‘str’ library & how do I get it ready to use?
Thanks.
[lua]
local str = require(“str”) – LIBRARY CAN NOT BE LOCATED
if file then
– Read file contents into a string
local dataStr = file:read( “*a” )
– Break string into separate variables and construct new table from resulting data
local datavars = str.split(dataStr, “,”)
dataTableNew = {}
for i = 1, #datavars do
– split each name/value pair
local onevalue = str.split(datavars[i], “=”)
dataTableNew[onevalue[1]] = onevalue[2]
end
io.close( file ) – important!
– Note: all values arrive as strings; cast to numbers where numbers are expected
dataTableNew[“numValue”] = tonumber(dataTableNew[“numValue”])
dataTableNew[“randomValue”] = tonumber(dataTableNew[“randomValue”])
else
print (“no file found”)
end
[/lua]