Skip to content
Snippets Groups Projects
Commit 3c752800 authored by dg's avatar dg
Browse files

fix loading level

git-svn-id: http://svn.net-core.org/repos/t-engine4@407 51575b47-30f0-44d4-a5cc-537603b46e54
parent d5e3ef1f
No related branches found
No related tags found
No related merge requests found
......@@ -130,7 +130,7 @@ end
function _M:loadReal(load)
if self.loaded[load] then return self.loaded[load] end
local f = fs.open(self.load_dir..load, "r")
-- print("loading", load)
print("loading", load)
local lines = {}
while true do
local l = f:read()
......
......@@ -118,6 +118,12 @@ local function serialize_data(outf, name, value, saved, filter, allow, savefile,
else
saved[value] = name -- save name for next time
outf("{}\n") -- create a new table
-- If we are the base table, decalre ourselves
if name == "data" then
outf('setLoaded("'..savefile:getFileName(value)..'", data)\n')
end
for k,v in pairs(value) do -- save its fields
-- print(allow, k , filter[k])
if (not allow and not filter[k]) or (allow and filter[k]) then
......@@ -140,7 +146,7 @@ end
local function serialize(data, filter, allow, savefile)
local tbl = {}
local outf = function(...) for i,str in ipairs(arg) do table.insert(tbl, str) end end
local outf = function(...) for i,str in ipairs{...} do table.insert(tbl, str) end end
serialize_data(outf, "data", data, nil, filter, allow, savefile, true)
table.insert(tbl, "return data\n")
return tbl
......@@ -166,6 +172,10 @@ local function deserialize(string, src)
local f, err = loadstring(string)
if err then print("error deserializing", string, err) end
setfenv(f, {
setLoaded = function(name, t)
print("[setLoaded]", name, t)
engine.Savefile.current_save.loaded[name] = t
end,
loadstring = loadstring,
loadObject = function(n)
if n == src then
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment