sorcery  Diff

Differences From Artifact [5046584198]:

  • File lib/tbl.lua — part of check-in [72eebac4bc] at 2020-09-26 18:49:51 on branch trunk — add writing stand for editing codexes; add scissors, ink, erasure fluid, pens; touch up codex UI; add many recipe notes; add craft divination type for crafttools; defuckulate fucktarded crafttool impl; enhance table library with missing features like lua's table.unpack; many bug fixes and enhancements; blood for the blood god (user: lexi, size: 1805) [annotate] [blame] [check-ins using]

To Artifact [4e80a60df8]:

  • File lib/tbl.lua — part of check-in [3f6a913e4e] at 2020-09-29 12:40:28 on branch trunk — * remove former hacky registration system, replace with consistent and flexible API; rewrite metal/gem generation to take advantage of this new API; tweaks to init system to enable world-local tweaks to lore and sorcery behavior * initial documentation commit * initial steps towards calendar - add default date format, astrolabe; prepare infra for division/melding/transmutation spells, various tweaks and fixes (user: lexi, size: 2543) [annotate] [blame] [check-ins using]

15
16
17
18
19
20
21












22
23
24
25
26
















27
28
29
30
31
32
33
...
105
106
107
108
109
110
111
112












113

fn.copy = function(t)
	local new = {}
	for i,v in pairs(t) do new[i] = v end
	setmetatable(new,getmetatable(t))
	return new
end













fn.merge = function(base,override)
	local new = fn.copy(base)
	for k,v in pairs(override) do
		new[k] = v
















	end
	return new
end

fn.append = function(r1, r2)
	local new = fn.copy(r1)
	for i=1,#r2 do
................................................................................
	else
		for i=0,#tbl do
			acc = fn(acc,tbl[i],i)
		end
	end
	return acc
end













return fn







>
>
>
>
>
>
>
>
>
>
>
>





>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







 








>
>
>
>
>
>
>
>
>
>
>
>

15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
...
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153

fn.copy = function(t)
	local new = {}
	for i,v in pairs(t) do new[i] = v end
	setmetatable(new,getmetatable(t))
	return new
end

fn.deepcopy = table.copy or function(t)
	new = {}
	for k,v in pairs(t) do
		if type(v) == 'table' then
			new[k] = fn.deepcopy(v)
		else
			new[k] = v
		end
	end
	return new
end

fn.merge = function(base,override)
	local new = fn.copy(base)
	for k,v in pairs(override) do
		new[k] = v
	end
	return new
end

fn.deepmerge = function(base,override)
	local new = {}
	local keys = fn.merge(fn.keys(base),fn.keys(override))
	for _,k in pairs(keys) do
		if type(base[k]) == 'table' and
		   type(override[k]) == 'table' then
			new[k] = fn.deepmerge(base[k], override[k])
		elseif override[k] then
			new[k] = override[k]
		else
			new[k] = base[k]
		end
	end
	return new
end

fn.append = function(r1, r2)
	local new = fn.copy(r1)
	for i=1,#r2 do
................................................................................
	else
		for i=0,#tbl do
			acc = fn(acc,tbl[i],i)
		end
	end
	return acc
end

fn.walk = function(tbl,path)
	if type(path) == 'table' then
		for _,p in pairs(path) do
			if tbl[p] == nil then return nil end
			tbl = tbl[p]
		end
	else
		tbl = tbl[path]
	end
	return tbl
end

return fn