sorcery  Diff

Differences From Artifact [8803c503c6]:

To Artifact [58ff591804]:


11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29

























30
31
32
33
34
35
36
..
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65


66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
...
102
103
104
105
106
107
108




109
110
111
112
113
114
115
...
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
...
144
145
146
147
148
149
150

151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
		end
	end
	local worldcfg = function(str)
		return minetest.get_worldpath() .. '/' .. str
	end
	local cfg = function(str) return worldcfg('sorcery/' .. str) end
	local selfname = minetest.get_current_modname()
	local stage = function(s,...)
		local f = sorcery.cfg(s .. '.lua')
		if test(f) then return loadfile(f)(...) or true end
		return false
	end

	local function
	argjoin(arg, nxt, ...)
		if arg and not nxt then return tostring(arg) end
		if not arg then return "(nil)" end
		return tostring(arg) .. ' ' .. argjoin(nxt, ...)
	end


























	sorcery = {
		self = selfname;
		path = path;
		load = function(name) get(name) end;
		worldcfg = worldcfg, cfg = cfg;
		stage = stage;
................................................................................
			else
				minetest.log('info',string.format('[%s] %s',selfname,text))
			end
		end;
		act = function(module,text)
			minetest.log('action',string.format('[%s :: %s] %s',selfname,module,text))
		end;
		logger = function(module)
			local emit = function(lvl)
				return function(...)
					if module then
						minetest.log(lvl,string.format('[%s :: %s] %s',selfname,module,argjoin(...)))
					else
						minetest.log(lvl,string.format('[%s] %s',selfname,argjoin(...)))
					end
				end
			end
			return {
				log = emit('info');
				warn = emit('warning');
				err = emit('error');
				act = emit('action');
			}
		end;
		unit = function(ns,sfx,override)


			local target
			if ns then
				sorcery[ns] = {}
				target = sorcery[ns]
			else target = sorcery end
			if override == true then override = ''
				elseif override then override = override .. '-' end
			local loaded = {}
			return function(lst)
				for i,name in pairs(lst) do
					if not loaded[name] then
						loaded[name] = true
						local log = sorcery.logger(name)
						local fpath = ((ns and ns..'/') or '')..name
						local extra = cfg(string.format('%s%s-extra.lua', override,name))
						local replace = cfg(string.format('%s%s.lua', override,name))
						local default = get(fpath)
						if override and test(replace) then
							log.info('loading local replacement for', fpath,'from', replace)
							target[name] = loadfile(replace)(default)
................................................................................
	sorcery.act = function(mod,...) return sorcery.logger(mod).act(...) end
end

-- unfortunately we can't just iterate over the files
-- and load them automatically, as interdependencies
-- exist (especially with /lib) and we need to be very
-- careful about the order they're loaded in





local data = sorcery.unit('data',nil,'lore')
local root = sorcery.unit()
sorcery.stage('bootstrap',data,root)

data {'ui'}
sorcery.unit('lib') {
................................................................................
root {'compat','matreg'}
if not sorcery.stage('loadlore', data, root) then
	data {
		'compat';
		'affinities'; 'gods';
		'calendar', 'signs';
		'resonance';
		'gems', 'metals';
		'enchants', 'spells', 'runes';
		'potions', 'oils', 'greases',
			'draughts', 'elixirs',
			'philters', 'extracts';
	}
end

................................................................................
sorcery.load('registration') do
	local exclude = {'compat','ui'}
	for k,v in pairs(sorcery.data) do
		if not sorcery.lib.tbl.has(exclude,k) then
			sorcery.registry.mk(k,v)
		end
	end

end

sorcery.stage('startup',data)
for _,u in pairs {
	'vfx'; 'attunement'; 'context'; 'itemclass'; 'spell';
	'liquid'; 'potions'; 'metal', 'gems'; 'leylines'; 'infuser';
	'altar'; 'wands'; 'tools', 'crafttools'; 'enchanter';
	'harvester'; 'metallurgy-hot', 'metallurgy-cold';
	'entities'; 'recipes'; 'coins'; 'interop';
	'tnodes'; 'forcefield'; 'farcaster'; 'portal';
	'cookbook', 'writing'; 'disassembly'; 'displacer';
	'gravitator'; 'precipitator'; 'calendar', 'astrolabe';
	'keypunch'; 'runeforge'; 'keg';

	'privs', 'admin';
} do sorcery.load(u) end
sorcery.stage('finalize')

sorcery.registry.defercheck()







<
<
<
<
<
<






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







 







|
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<

>
>












|







 







>
>
>
>







 







|







 







>




|
|
|
|




|






11
12
13
14
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
..
60
61
62
63
64
65
66
67
















68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
...
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
...
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
...
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
		end
	end
	local worldcfg = function(str)
		return minetest.get_worldpath() .. '/' .. str
	end
	local cfg = function(str) return worldcfg('sorcery/' .. str) end
	local selfname = minetest.get_current_modname()






	local function
	argjoin(arg, nxt, ...)
		if arg and not nxt then return tostring(arg) end
		if not arg then return "(nil)" end
		return tostring(arg) .. ' ' .. argjoin(nxt, ...)
	end

	local logger = function(module)
		local emit = function(lvl)
			return function(...)
				if module then
					minetest.log(lvl,string.format('[%s :: %s] %s',selfname,module,argjoin(...)))
				else
					minetest.log(lvl,string.format('[%s] %s',selfname,argjoin(...)))
				end
			end
		end
		return {
			info = emit('info');
			warn = emit('warning');
			err = emit('error');
			act = emit('action');
		}
	end;

	local stage = function(s,...)
		logger().info('entering stage',s)
		local f = sorcery.cfg(s .. '.lua')
		if test(f) then return loadfile(f)(...) or true end
		return false
	end

	sorcery = {
		self = selfname;
		path = path;
		load = function(name) get(name) end;
		worldcfg = worldcfg, cfg = cfg;
		stage = stage;
................................................................................
			else
				minetest.log('info',string.format('[%s] %s',selfname,text))
			end
		end;
		act = function(module,text)
			minetest.log('action',string.format('[%s :: %s] %s',selfname,module,text))
		end;
		logger = logger;
















		unit = function(ns,sfx,override)
			if ns then logger('loader').info('opening unit',ns) end
			local log = logger(ns and ('loader/'..ns))
			local target
			if ns then
				sorcery[ns] = {}
				target = sorcery[ns]
			else target = sorcery end
			if override == true then override = ''
				elseif override then override = override .. '-' end
			local loaded = {}
			return function(lst)
				for i,name in pairs(lst) do
					if not loaded[name] then
						loaded[name] = true
						log.info('installing component', name)
						local fpath = ((ns and ns..'/') or '')..name
						local extra = cfg(string.format('%s%s-extra.lua', override,name))
						local replace = cfg(string.format('%s%s.lua', override,name))
						local default = get(fpath)
						if override and test(replace) then
							log.info('loading local replacement for', fpath,'from', replace)
							target[name] = loadfile(replace)(default)
................................................................................
	sorcery.act = function(mod,...) return sorcery.logger(mod).act(...) end
end

-- unfortunately we can't just iterate over the files
-- and load them automatically, as interdependencies
-- exist (especially with /lib) and we need to be very
-- careful about the order they're loaded in

local log = sorcery.logger()

log.info('loading data')

local data = sorcery.unit('data',nil,'lore')
local root = sorcery.unit()
sorcery.stage('bootstrap',data,root)

data {'ui'}
sorcery.unit('lib') {
................................................................................
root {'compat','matreg'}
if not sorcery.stage('loadlore', data, root) then
	data {
		'compat';
		'affinities'; 'gods';
		'calendar', 'signs';
		'resonance';
		'trees', 'gems', 'metals';
		'enchants', 'spells', 'runes';
		'potions', 'oils', 'greases',
			'draughts', 'elixirs',
			'philters', 'extracts';
	}
end

................................................................................
sorcery.load('registration') do
	local exclude = {'compat','ui'}
	for k,v in pairs(sorcery.data) do
		if not sorcery.lib.tbl.has(exclude,k) then
			sorcery.registry.mk(k,v)
		end
	end
	sorcery.registry.mk('residue',false)
end

sorcery.stage('startup',data)
for _,u in pairs {
	'vfx'; 'context'; 'attunement'; 'itemclass'; 'craft'; 'spell';
	'liquid'; 'tree'; 'potions'; 'metal', 'gems'; 'leylines';
	'infuser'; 'altar'; 'wands'; 'tools', 'crafttools';
	'enchanter'; 'harvester'; 'metallurgy-hot', 'metallurgy-cold';
	'entities'; 'recipes'; 'coins'; 'interop';
	'tnodes'; 'forcefield'; 'farcaster'; 'portal';
	'cookbook', 'writing'; 'disassembly'; 'displacer';
	'gravitator'; 'precipitator'; 'calendar', 'astrolabe';
	'keypunch'; 'runeforge'; 'keg'; 'tap';

	'privs', 'admin';
} do sorcery.load(u) end
sorcery.stage('finalize')

sorcery.registry.defercheck()