summaryrefslogtreecommitdiff
path: root/save.lua
diff options
context:
space:
mode:
Diffstat (limited to 'save.lua')
-rw-r--r--save.lua47
1 files changed, 47 insertions, 0 deletions
diff --git a/save.lua b/save.lua
new file mode 100644
index 00000000..1a4ba04d
--- /dev/null
+++ b/save.lua
@@ -0,0 +1,47 @@
+$debug
+
+
+function savevar (n,v)
+ if v = nil then return end;
+ if type(v) = "number" then print(n.."="..v) return end
+ if type(v) = "string" then print(n.."='"..v.."'") return end
+ if type(v) = "table" then
+ if v.__visited__ ~= nil then
+ print(n .. "=" .. v.__visited__);
+ else
+ print(n.."=@()")
+ v.__visited__ = n;
+ local r,f;
+ r,f = next(v,nil);
+ while r ~= nil do
+ if r ~= "__visited__" then
+ if type(r) = 'string' then
+ savevar(n.."['"..r.."']",f)
+ else
+ savevar(n.."["..r.."]",f)
+ end
+ end
+ r,f = next(v,r)
+ end
+ end
+ end
+end
+
+function save ()
+local n,v
+ n,v = nextvar(nil)
+ while n ~= nil do
+ savevar(n,v);
+ n,v = nextvar(n)
+ end
+end
+
+a = 3
+x = @{a = 4, b = "name", l=@[4,5,67]}
+
+b = @{t=5}
+x.next = b
+
+
+save()
+