aboutsummaryrefslogtreecommitdiff
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 @@
1$debug
2
3
4function savevar (n,v)
5 if v = nil then return end;
6 if type(v) = "number" then print(n.."="..v) return end
7 if type(v) = "string" then print(n.."='"..v.."'") return end
8 if type(v) = "table" then
9 if v.__visited__ ~= nil then
10 print(n .. "=" .. v.__visited__);
11 else
12 print(n.."=@()")
13 v.__visited__ = n;
14 local r,f;
15 r,f = next(v,nil);
16 while r ~= nil do
17 if r ~= "__visited__" then
18 if type(r) = 'string' then
19 savevar(n.."['"..r.."']",f)
20 else
21 savevar(n.."["..r.."]",f)
22 end
23 end
24 r,f = next(v,r)
25 end
26 end
27 end
28end
29
30function save ()
31local n,v
32 n,v = nextvar(nil)
33 while n ~= nil do
34 savevar(n,v);
35 n,v = nextvar(n)
36 end
37end
38
39a = 3
40x = @{a = 4, b = "name", l=@[4,5,67]}
41
42b = @{t=5}
43x.next = b
44
45
46save()
47