sorcery  Diff

Differences From Artifact [bee797c513]:

To Artifact [c60971c6b0]:


    37     37   				local mat = sorcery.matreg.lookup[name]
    38     38   				if mat and mat.gem then return mat end
    39     39   			end;
    40     40   		};
    41     41   		grindable = {
    42     42   			compat = 'grindables';
    43     43   			subclass = {'metallic'};
           44  +			conform = {
           45  +				metallic = function(m)
           46  +					if m and m.data and m.data.parts and m.data.parts.powder then
           47  +						return {
           48  +							hardness = m.data.hardness;
           49  +							value = m.value or 1, grindcost = 1;
           50  +							powder = m.data.parts.powder;
           51  +						}
           52  +					end
           53  +				end;
           54  +			};
    44     55   			predicate = function(name)
    45     56   				local def = minetest.registered_items[name]._sorcery
    46     57   				if not def then return nil end
    47     58   				def = def.material
    48     59   				if def and def.grindvalue then
    49     60   					return def end
    50     61   			end;
................................................................................
    62     73   				-- matreg is a registry binding crafted items,
    63     74   				-- like armors and tools, to the material they
    64     75   				-- are made out of
    65     76   				local mat = sorcery.matreg.lookup[name]
    66     77   				if mat and mat.metal then return mat end
    67     78   			end;
    68     79   		};
           80  +		ore = {
           81  +			groups = { 'ore' };
           82  +			compat = 'ore';
           83  +			predicate = function(name)
           84  +				-- maybe revise this at some point once sorcery is extricated
           85  +				-- from instant_ores and we have more control over the items
           86  +				-- we generate
           87  +				local orepfx = "stone_with_" -- }:<
           88  +				local barename = string.sub(name, string.find(name, ':') + 1)
           89  +				if string.sub(barename,1,string.len(orepfx)) == orepfx then
           90  +					local iname = string.sub(barename,string.len(orepfx) + 1)
           91  +					if sorcery.data.metals[iname] then
           92  +						return { metal = true, id = iname }
           93  +					elseif sorcery.data.gems[iname] then
           94  +						return { gem = true, id = iname }
           95  +					end
           96  +				end
           97  +			end;
           98  +		};
    69     99   	};
    70    100   	get = function(name,class)
    71    101   		local c = sorcery.itemclass.classes[class]
    72    102   		local o
    73    103   		if not c then return false end
    74    104   
    75    105   		if c.predicate then 
................................................................................
    81    111   			o = sorcery.data.compat[c.compat][name]
    82    112   			if o then return o end
    83    113   		end
    84    114   
    85    115   		if c.subclass then
    86    116   			for _,s in pairs(c.subclass) do
    87    117   				o = sorcery.itemclass.get(name,s)
    88         -				if o then return o end
          118  +				if o then
          119  +					if c.conform and c.conform[s] then
          120  +						return c.conform[s](o)
          121  +					else return o end
          122  +				end
    89    123   			end
    90    124   		end
    91    125   
    92    126   		if c.groups then
    93    127   			for _,g in pairs(c.groups) do
    94    128   				o = minetest.get_item_group(name,g) 
    95    129   				if o > 0 then return { kind = o } end