sorcery  Diff

Differences From Artifact [993e34739f]:

To Artifact [22986aed9f]:


   300    300   	groups = {
   301    301   		sorcery_magitech = 1;
   302    302   		sorcery_tech_component = 1;
   303    303   	};
   304    304   })
   305    305   
   306    306   
   307         -local regtech = function(id, desc, groups, recipe, qty, replacements)
          307  +local regtech = function(id, desc, groups, recipe, qty, replacements, props)
   308    308   	minetest.register_craftitem('sorcery:' .. id,{
   309    309   		description = desc;
   310    310   		inventory_image = 'sorcery_'..id..'.png';
   311    311   		groups = sorcery.lib.tbl.merge({
   312    312   			sorcery_magitech = 1;
   313    313   			sorcery_tech_component = 1;
   314    314   		}, groups or {});
          315  +		_sorcery = props;
   315    316   	})
   316    317   	if recipe then
   317    318   		minetest.register_craft {
   318    319   			output = string.format('sorcery:%s %u', id, qty or 1);
   319    320   			recipe = recipe;
   320    321   			replacements = replacements;
   321    322   		}
................................................................................
   322    323   	end
   323    324   end
   324    325   
   325    326   local regcore = function(core,name)
   326    327   	regtech('core_'..core, name .. ' Core', {sorcery_magitech_core = 1})
   327    328   end
   328    329   
          330  +local mprop = function(metal, amt)
          331  +	local gc, gv
          332  +	amt = amt or 1
          333  +	if math.floor(amt) ~= amt then
          334  +		if amt < 1 then
          335  +			gc = math.floor(1 / amt)
          336  +		else
          337  +			local n = 0
          338  +			for i = 2,10 do
          339  +				if math.floor(amt * i) == amt * i then
          340  +					n = i
          341  +					break
          342  +				end
          343  +			end
          344  +			if n == 0 then error "can't determine metal value for item" end
          345  +			gc = i
          346  +			gv = amt * i
          347  +		end
          348  +	else
          349  +		gc = 1
          350  +		gv = amt
          351  +	end
          352  +	return { material = {
          353  +		metal = true; id = metal;
          354  +		data = sorcery.data.metals[metal];
          355  +		grindcost = gc;
          356  +		grindvalue = gv;
          357  +		value = amt;
          358  +	}}
          359  +end
   329    360   
   330    361   regtech('field_emitter', 'Field Emitter', {metal = 1})
   331    362   regtech('leyline_stabilizer', 'Leyline Stabilizer', {metal = 1})
   332    363   regtech('beam_generator', 'Beam Generator', {metal = 1})
   333    364   regtech('inversion_matrix', 'Inversion Matrix', {metal = 1})
   334    365   regtech('inverter_coil', 'Inverter Coil', {metal = 1})
   335    366   regtech('suppression_matrix', 'Suppression Matrix', {metal = 1})
................................................................................
   336    367   regtech('tuning_disc', 'Tuning Disc', {metal = 1})
   337    368   	-- used in constructing devices that are subject to attunement wand
   338    369   regtech('gravity_manipulator', 'Gravity Manipulator', {metal = 1})
   339    370   regtech('valve','Valve', {metal = 1}, {
   340    371   	{'','default:bronze_ingot',''};
   341    372   	{'basic_materials:plastic_sheet','basic_materials:steel_bar','basic_materials:plastic_sheet'};
   342    373   	{'','default:bronze_ingot',''};
   343         -},3)
          374  +},3,nil, mprop('bronze',2*4,1,2*4))
   344    375   regtech('pipe','Pipe', {metal = 1}, {
   345    376   	{ingot('aluminum'),'',ingot('aluminum')};
   346    377   	{ingot('aluminum'),'',ingot('aluminum')};
   347    378   	{ingot('aluminum'),'',ingot('aluminum')};
   348         -}, 6)
          379  +}, 6, nil, mprop('aluminum', 4))
   349    380   
   350    381   minetest.register_craft {
   351    382   	output = 'sorcery:trough';
   352    383   	recipe = {
   353    384   		{ingot('aluminum'),'',ingot('aluminum')};
   354    385   		{ingot('aluminum'),'',ingot('aluminum')};
   355    386   		{ingot('aluminum'),ingot('aluminum'),ingot('aluminum')};