sorcery  Diff

Differences From Artifact [c9beb59240]:

  • File metallurgy-hot.lua — part of check-in [72eebac4bc] at 2020-09-26 18:49:51 on branch trunk — add writing stand for editing codexes; add scissors, ink, erasure fluid, pens; touch up codex UI; add many recipe notes; add craft divination type for crafttools; defuckulate fucktarded crafttool impl; enhance table library with missing features like lua's table.unpack; many bug fixes and enhancements; blood for the blood god (user: lexi, size: 13421) [annotate] [blame] [check-ins using]

To Artifact [52848574bf]:

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

   128    128   local find_recipe = function(inv)
   129    129   	local mix = {}
   130    130   	local count = 0
   131    131   	for i=1,inv:get_size('input') do
   132    132   		local m = inv:get_stack('input',i)
   133    133   		if m:is_empty() then goto skip end
   134    134   		local l = sorcery.data.metallookup[m:get_name()]
          135  +		if not l then
          136  +			local p = sorcery.lib.tbl.walk(m:get_definition()._sorcery,{'material'})
          137  +			if p.metal then l = p end
          138  +		end
   135    139   		if not l then return false end
   136    140   		mix[l.id] = (mix[l.id] or 0) + l.value
   137    141   		count = count + l.value
   138    142   	::skip::end
          143  +	count = math.floor(count)
   139    144   	-- everything is metal, we've finished summing it up.
   140    145   	-- let's see if the assembled items match the ratio
   141    146   	-- specified in any of the smelting recipes.
   142    147   	local matches = 0
   143         -	for _,rec in pairs(sorcery.data.alloys) do
          148  +	for _,rec in pairs(sorcery.register.alloys.db) do
   144    149   		local fac = nil
   145    150   		local meltpoint = 1
   146    151   		if rec.metals == nil then goto skip_recipe end
   147    152   		for metal, ratio in pairs(rec.metals) do
   148    153   			if mix[metal] and mix[metal] % ratio == 0 then
   149    154   				if fac then
   150    155   					if mix[metal] / ratio ~= fac then goto skip_recipe end
................................................................................
   208    213   		for i=1,inv:get_size('input') do
   209    214   			local s = inv:get_stack('input',i)
   210    215   			if s:is_empty() then goto skip end
   211    216   			s:take_item(1) inv:set_stack('input',i,s)
   212    217   		::skip::end
   213    218   
   214    219   		local outstack
   215         -		if count % fragments_per_ingot == 0 then
   216         -			outstack = ItemStack {
   217         -				name = sorcery.data.metals[recipe.output].ingot or 'sorcery:' .. recipe.output .. '_ingot';
   218         -				count = count / fragments_per_ingot;
   219         -			}
          220  +		if type(output) == 'table' then
          221  +			for v,item in pairs(output) do
          222  +				if count % v == 0 then
          223  +					outstack = ItemStack {
          224  +						name = item;
          225  +						count = count / v;
          226  +					}
          227  +				end
          228  +			end
   220    229   		else
   221         -			outstack = ItemStack {
   222         -				name = 'sorcery:fragment_' .. recipe.output;
   223         -				count = count;
   224         -			}
          230  +			if count % (fragments_per_ingot * 9) == 0 then
          231  +				outstack = ItemStack {
          232  +					name = sorcery.data.metals[recipe.output].parts.block;
          233  +					count = count / (fragments_per_ingot*9);
          234  +				}
          235  +			elseif count % fragments_per_ingot == 0 then
          236  +				outstack = ItemStack {
          237  +					name = sorcery.data.metals[recipe.output].parts.ingot;
          238  +					count = count / fragments_per_ingot;
          239  +				}
          240  +			else
          241  +				outstack = ItemStack {
          242  +					name = 'sorcery:fragment_' .. recipe.output;
          243  +					count = count;
          244  +				}
          245  +			end
   225    246   		end
   226    247   
   227    248   		local leftover = inv:add_item('output',outstack)
   228    249   		if not leftover:is_empty() then
   229    250   			minetest.add_item(pos, leftover)
   230    251   		end
   231    252   	end
................................................................................
   302    323   			drawtype = "mesh";
   303    324   			after_dig_node = sorcery.lib.node.purge_container;
   304    325   			mesh = 'sorcery-kiln-' .. state .. '.obj';
   305    326   			drop = id;
   306    327   			groups = {
   307    328   				cracky = (state == 'open' and 2) or nil;
   308    329   				sorcery_metallurgy = 1;
          330  +				not_in_creative_inventory = (state == open) and nil or 1;
   309    331   			};
   310    332   			sunlight_propagates = true;
   311    333   			paramtype1 = 'light';
   312    334   			paramtype2 = 'facedir';
   313    335   			selection_box = box[state];
   314    336   			collision_box = box[state];
   315    337   			tiles = tex[state];
................................................................................
   384    406   			_proto = kind;
   385    407   			description = desc;
   386    408   			drop = id;
   387    409   			after_dig_node = sorcery.lib.node.purge_container;
   388    410   			groups = {
   389    411   				cracky = (active and 2) or nil;
   390    412   				sorcery_metallurgy = 1;
          413  +				not_in_creative_inventory = active and 1 or nil;
   391    414   			};
   392    415   			paramtype2 = 'facedir';
   393    416   			light_source = (active and 9) or 0;
   394    417   			on_construct = function(pos)
   395    418   				local meta = minetest.get_meta(pos)
   396    419   				local inv = meta:get_inventory()
   397    420   				inv:set_size('input',kind.size)