sorcery  Diff

Differences From Artifact [bee797c513]:

To Artifact [c60971c6b0]:


37
38
39
40
41
42
43











44
45
46
47
48
49
50
..
62
63
64
65
66
67
68



















69
70
71
72
73
74
75
..
81
82
83
84
85
86
87



88

89
90
91
92
93
94
95
				local mat = sorcery.matreg.lookup[name]
				if mat and mat.gem then return mat end
			end;
		};
		grindable = {
			compat = 'grindables';
			subclass = {'metallic'};











			predicate = function(name)
				local def = minetest.registered_items[name]._sorcery
				if not def then return nil end
				def = def.material
				if def and def.grindvalue then
					return def end
			end;
................................................................................
				-- matreg is a registry binding crafted items,
				-- like armors and tools, to the material they
				-- are made out of
				local mat = sorcery.matreg.lookup[name]
				if mat and mat.metal then return mat end
			end;
		};



















	};
	get = function(name,class)
		local c = sorcery.itemclass.classes[class]
		local o
		if not c then return false end

		if c.predicate then 
................................................................................
			o = sorcery.data.compat[c.compat][name]
			if o then return o end
		end

		if c.subclass then
			for _,s in pairs(c.subclass) do
				o = sorcery.itemclass.get(name,s)



				if o then return o end

			end
		end

		if c.groups then
			for _,g in pairs(c.groups) do
				o = minetest.get_item_group(name,g) 
				if o > 0 then return { kind = o } end







>
>
>
>
>
>
>
>
>
>
>







 







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







 







>
>
>
|
>







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
..
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
...
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
				local mat = sorcery.matreg.lookup[name]
				if mat and mat.gem then return mat end
			end;
		};
		grindable = {
			compat = 'grindables';
			subclass = {'metallic'};
			conform = {
				metallic = function(m)
					if m and m.data and m.data.parts and m.data.parts.powder then
						return {
							hardness = m.data.hardness;
							value = m.value or 1, grindcost = 1;
							powder = m.data.parts.powder;
						}
					end
				end;
			};
			predicate = function(name)
				local def = minetest.registered_items[name]._sorcery
				if not def then return nil end
				def = def.material
				if def and def.grindvalue then
					return def end
			end;
................................................................................
				-- matreg is a registry binding crafted items,
				-- like armors and tools, to the material they
				-- are made out of
				local mat = sorcery.matreg.lookup[name]
				if mat and mat.metal then return mat end
			end;
		};
		ore = {
			groups = { 'ore' };
			compat = 'ore';
			predicate = function(name)
				-- maybe revise this at some point once sorcery is extricated
				-- from instant_ores and we have more control over the items
				-- we generate
				local orepfx = "stone_with_" -- }:<
				local barename = string.sub(name, string.find(name, ':') + 1)
				if string.sub(barename,1,string.len(orepfx)) == orepfx then
					local iname = string.sub(barename,string.len(orepfx) + 1)
					if sorcery.data.metals[iname] then
						return { metal = true, id = iname }
					elseif sorcery.data.gems[iname] then
						return { gem = true, id = iname }
					end
				end
			end;
		};
	};
	get = function(name,class)
		local c = sorcery.itemclass.classes[class]
		local o
		if not c then return false end

		if c.predicate then 
................................................................................
			o = sorcery.data.compat[c.compat][name]
			if o then return o end
		end

		if c.subclass then
			for _,s in pairs(c.subclass) do
				o = sorcery.itemclass.get(name,s)
				if o then
					if c.conform and c.conform[s] then
						return c.conform[s](o)
					else return o end
				end
			end
		end

		if c.groups then
			for _,g in pairs(c.groups) do
				o = minetest.get_item_group(name,g) 
				if o > 0 then return { kind = o } end