From 3c752800bc6cba4693a9674a71dbb8bf3930b9e9 Mon Sep 17 00:00:00 2001 From: dg <dg@51575b47-30f0-44d4-a5cc-537603b46e54> Date: Fri, 12 Mar 2010 22:11:12 +0000 Subject: [PATCH] fix loading level git-svn-id: http://svn.net-core.org/repos/t-engine4@407 51575b47-30f0-44d4-a5cc-537603b46e54 --- game/engine/Savefile.lua | 2 +- game/engine/class.lua | 12 +++++++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/game/engine/Savefile.lua b/game/engine/Savefile.lua index a6adb5b4e4..e2c24fa9cf 100644 --- a/game/engine/Savefile.lua +++ b/game/engine/Savefile.lua @@ -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() diff --git a/game/engine/class.lua b/game/engine/class.lua index 32fd2b2cd6..eb31aeb0a1 100644 --- a/game/engine/class.lua +++ b/game/engine/class.lua @@ -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 -- GitLab