~philho/+junk/Lua

1 by plhoste
Initial import of Lua scripts (take 2...)
1
dofile[[../Lua/DumpObject.lua]]
2
3
a = { _ = true, __ = false }
4
b = { 'a', 'b' }
5
6
t =
7
{
8
	a =
9
	{
10
		x = 5.0,
11
		y = 104.3,
12
	},
13
	b =
14
	{
15
		-- Numerical index
16
		[5] = 42,
17
		-- Simple string index ('simple' means having the syntax of variables)
18
		ls = [[
19
Multiline
20
Value
21
]],
22
		-- Complex string index
23
		['Regular Expression'] = [[(?:\d{1,3}\.){3}\d{1,3}]],
24
	},
25
	others =
26
	{
27
		-- Table as key
28
		tables =
29
		{
30
			[a] = '',
31
			[b] = "",
32
			-- This one is different of the previous one because the created
33
			-- table is different of b. You cannot reference it directly,
34
			-- it is reachable only by iterating on all keys/values...
35
			[ { 'a', 'b' } ] = { "aa", "bb" },
36
		},
37
		-- Complex strings as key
38
		strings =
39
		{
40
			[ [[C:\Lua\Lua.exe]] ] = true,
41
			[ "O'Neil" ] = false,
42
			[ 'Will "Liam" Cheese Pear' ] = not nil,
43
		},
44
		-- Boolean as key
45
		[true] = a,
46
	}
47
}
48
-- Réferences in the table
49
t.others.tables.reference = t.a
50
t.others.tables.otherRef = b
51
18 by PhiLho
Improving DumpObject to handle nicely the array part of the tables
52
DumpObjectToFile(t, "~DumpedObject.lua")
1 by plhoste
Initial import of Lua scripts (take 2...)
53
18 by PhiLho
Improving DumpObject to handle nicely the array part of the tables
54
-- Read back
55
tab = dofile("~DumpedObject.lua")
56
-- And save again (roundtrip)
57
DumpObjectToFile(tab, "~DumpedObject2.lua")