sorcery  init.lua at [9ef6cbcf31]

File init.lua artifact 73a80c3c4b part of check-in 9ef6cbcf31


do
	local path = minetest.get_modpath('sorcery');
	local get = function(unit)
		return dofile(path .. '/' .. unit .. '.lua')
	end
	sorcery = {
		path = path;
		load = function(name) get(name) end;
		unit = function(ns,sfx)
			local target
			if ns then
				sorcery[ns] = {}
				target = sorcery[ns]
			else target = sorcery end
			return function(lst)
				for i=1,#lst do
					target[lst[i]] = get(((ns and ns..'/') or '')..lst[i])
				end
			end
		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

sorcery.unit('data') {'ui'}
sorcery.unit('lib') {
	-- convenience
	'str';
	-- serialization
	'marshal', 'json';
	-- data structures
	'tbl', 'class';
	-- wrappers
	'color', 'image', 'ui';
	-- game
	'node';
}

sorcery.unit() { 'compat', 'matreg' }
sorcery.unit('data') {
	'compat';
	'affinities'; 'gods';
	'enchants', 'spells';
	'gems', 'metals';
	'potions', 'oils', 'greases',
		'draughts', 'elixirs',
		'philters', 'extracts';
	'register';
}

for _,u in pairs {
	'attunement'; 'ores'; 'gems'; 'leylines';
	'potions'; 'infuser'; 'altar'; 'wands';
	'tools'; 'crafttools'; 'enchanter'; 'harvester';
	'metallurgy-hot', 'metallurgy-cold';
	'entities'; 'recipes'; 'coins';
	'interop'; 'tnodes'; 'forcefield';
	'farcaster'; 'portal'; 'cookbook'; 'disassembly';
} do sorcery.load(u) end