sorcery  Diff

Differences From Artifact [32259e26c1]:

To Artifact [f9db217ceb]:

  • File metal.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: 6107) [annotate] [blame] [check-ins using]

     5      5   	name = "sorcery:delete_duranium_ore_again";
     6      6   	nodenames = {'sorcery:stone_with_duranium'};
     7      7   	action = function(pos,node)
     8      8   		minetest.set_node(pos, {name = 'default:stone'})
     9      9   	end
    10     10   }
    11     11   
    12         -sorcery.data.alloys = {}
    13         -sorcery.data.kilnrecs = {}
           12  +sorcery.registry.mk('alloys',false)
           13  +sorcery.registry.mk('kilnrecs',false)
    14     14   sorcery.data.metallookup = {
    15     15   	-- compat bullshit
    16     16   	['moreores:silver_ingot'] = {
    17     17   		id = 'silver'; data = sorcery.data.metals.silver;
    18     18   		value = fragments_per_ingot;
    19     19   	};
    20     20   	['moreores:silver_block'] = {
................................................................................
    37     37   	['morelights_vintage:brass_block'] = {
    38     38   		id = 'brass'; data = sorcery.data.metals.brass;
    39     39   		value = fragments_per_ingot * 9;
    40     40   	};
    41     41   }
    42     42   
    43     43   local tools, armors = sorcery.matreg.tools, sorcery.matreg.armors
    44         -for name, metal in pairs(sorcery.data.metals) do
           44  +-- for name, metal in pairs(sorcery.data.metals) do
           45  +sorcery.register.metals.foreach('sorcery:generate',{},function(name,metal)
    45     46   	local ingot = metal.ingot or 'sorcery:' .. name .. '_ingot'
    46     47   	local block = metal.block or 'sorcery:' .. name .. 'block'
    47     48   	local screw = 'sorcery:screw_' .. name
    48     49   	local fragment = 'sorcery:fragment_' .. name
    49     50   	local powder = 'sorcery:powder_' .. name
    50     51   	metal.parts = {
    51     52   		ingot = ingot;
................................................................................
    76     77   		id = name; data = metal;
    77     78   		value = fragments_per_ingot * 9;
    78     79   	}
    79     80   	sorcery.data.metallookup[fragment] = {
    80     81   		id = name; data = metal;
    81     82   		value = 1;
    82     83   	}
    83         -	sorcery.data.metallookup[screw] = {
    84         -		id = name; data = metal;
    85         -		value = 0; -- prevent use in smelting
    86         -	}
    87     84   	minetest.register_craftitem(screw, {
    88     85   		description = sorcery.lib.str.capitalize(name) .. ' Screw';
    89     86   		inventory_image = sorcery.lib.image('sorcery_screw.png'):multiply(sorcery.lib.color(metal.tone)):render();
           87  +		_sorcery = {
           88  +			material = {
           89  +				id = name, data = metal;
           90  +				grindcost = 2, grindvalue = 1;
           91  +				value = 0.5;
           92  +			};
           93  +		};
    90     94   	})
    91     95   	minetest.register_craftitem(powder, {
    92     96   		description = sorcery.lib.str.capitalize(name) .. ' Powder';
    93     97   		inventory_image = 'sorcery_' .. name .. '_powder.png';
    94     98   	})
    95     99   	if metal.dye then
    96    100   		minetest.register_craft {
................................................................................
   140    144   			armor_weight = metal.armor_weight;
   141    145   			armor_protection = metal.armor_protection;
   142    146   		}
   143    147   	end
   144    148   	minetest.register_craftitem(fragment, {
   145    149   		inventory_image = 'sorcery_' .. name .. '_fragment.png';
   146    150   		description = sorcery.lib.str.capitalize(name) .. ' Fragment';
          151  +		_sorcery = {
          152  +			recipe = {
          153  +				canonical = {
          154  +					cook = {{ingot}};
          155  +				};
          156  +			};
          157  +		};
   147    158   	})
   148    159   	minetest.register_craft {
   149    160   		type = 'cooking';
   150    161   		recipe = powder;
   151    162   		cooktime = (metal.cooktime or 4) * 0.25;
   152    163   		output = fragment;
   153    164   	}
................................................................................
   171    182   		minetest.register_craft {
   172    183   			type = 'fuel';
   173    184   			recipe = powder;
   174    185   			burntime = metal.fuel;
   175    186   		}
   176    187   	end
   177    188   	if metal.mix then
   178         -		sorcery.data.register.alloy(sorcery.lib.tbl.merge(metal.mix, {
          189  +		sorcery.register.alloys.link(sorcery.lib.tbl.merge(metal.mix, {
   179    190   			output = name;
   180    191   			cooktime = metal.cooktime or 10;
   181    192   		}))
   182    193   	end
   183    194   	if metal.sinter then
   184    195   		local powders = {}
   185    196   		for _,m in pairs(metal.sinter) do
   186    197   			powders[#powders+1] = 'sorcery:powder_' .. m
   187    198   		end
   188    199   		local repl = {}
   189    200   		if metal.sinter_catalyst then
   190    201   			for _,m in pairs(metal.sinter_catalyst) do
   191    202   				powders[#powders+1] = m
   192         -				if sorcery.data.infusion_leftovers[m] then
   193         -					repl[#repl+1] = {m, sorcery.data.infusion_leftovers[m]}
          203  +				if sorcery.register.residue.db[m] then
          204  +					repl[#repl+1] = {m, sorcery.register.residue.db[m]}
   194    205   				end
   195    206   			end
   196    207   		end
   197    208   
   198    209   		minetest.register_craft {
   199    210   			type = 'shapeless';
   200    211   			output = powder .. ' ' .. tostring(#powders);
   201    212   			recipe = powders;
   202    213   			replacements = repl;
   203    214   		};
   204    215   	end
   205         -end
          216  +end)