sorcery  Diff

Differences From Artifact [c145d6a94a]:

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

To Artifact [0187673a26]:

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

    79     79   	minetest.get_node_timer(pos):start(constants.mill_refresh)
    80     80   end
    81     81   local mill_fits_in_slot = function(slot,item)
    82     82   	if slot == 'grinder' then
    83     83   		if minetest.get_item_group(item:get_name(), 'sorcery_mill_grindhead')~=0 
    84     84   			then return 1 end
    85     85   	elseif slot == 'input' then
    86         -		local metal = sorcery.data.metallookup[item:get_name()]
    87         -		local mat = sorcery.matreg.lookup[item:get_name()]
    88         -		local comp = sorcery.data.compat.grindables[item:get_name()]
    89         -		if metal or (mat and mat.metal) or comp then
           86  +		if sorcery.itemclass.get(item,'grindable') then
    90     87   			return item:get_count()
    91         -		else
    92         -			mat = item:get_definition()._sorcery and
    93         -			      item:get_definition()._sorcery.material
    94         -			if mat and mat.grindvalue then
    95         -				return item:get_count() 
    96         -			end
    97     88   		end
           89  +		-- local metal = sorcery.data.metallookup[item:get_name()]
           90  +		-- local mat = sorcery.matreg.lookup[item:get_name()]
           91  +		-- local comp = sorcery.data.compat.grindables[item:get_name()]
           92  +		-- if metal or (mat and mat.metal) or comp then
           93  +		-- 	return item:get_count()
           94  +		-- else
           95  +		-- 	mat = item:get_definition()._sorcery and
           96  +		-- 	      item:get_definition()._sorcery.material
           97  +		-- 	if mat and mat.metal or mat.powder then
           98  +		-- 		return item:get_count() 
           99  +		-- 	end
          100  +		-- end
    98    101   	end
    99    102   	return 0
   100    103   end
   101    104   local matprops = function(item)
   102    105   	local metal = sorcery.data.metallookup[item:get_name()]
          106  +	local props = item:get_definition()._sorcery
   103    107   	if not metal then
   104    108   		-- allow grinding of armor and tools back to their
   105    109   		-- original components
   106    110   		local mat = sorcery.matreg.lookup[item:get_name()]
   107    111   		if mat and mat.metal then
   108    112   			metal = mat
          113  +		elseif props and props.material and props.material.metal then
          114  +			metal = props.material
   109    115   		end
   110    116   	end
   111         -	local mp = (item:get_definition()._sorcery and
   112         -		item:get_definition()._sorcery.material)
          117  +	local mp = (props and props.material)
   113    118   		or sorcery.data.compat.grindables[item:get_name()]
   114    119   		or {}
   115    120   
   116    121   	if metal then mp = {
   117    122   		hardness = mp.hardness or metal.data.hardness;
   118    123   		grindvalue = ((mp.grindvalue or metal.value) or (metal and constants.metal_grindvalue));
   119    124   		powder = mp.powder or metal.data.parts.powder;
   120    125   		grindcost = mp.grindcost or constants.metal_grindcost; -- invariant for metal
   121    126   	} end
   122    127   
          128  +	mp.hardness   = mp.hardness   or constants.default_hardness;
   123    129   	mp.torque     = constants.grind_torque_factor * mp.hardness
   124    130   	mp.grindvalue = mp.grindvalue or constants.default_grindvalue
   125    131   	mp.grindcost  = mp.grindcost  or constants.default_grindcost
   126         -	mp.hardness   = mp.hardness   or constants.default_hardness;
   127    132   
   128    133   	if item:get_wear() ~= 0 then
   129    134   		-- prevent cheating by recovering metal from items before they
   130    135   		-- are destroyed
   131    136   		local wearfac = (item:get_wear() / 65535)
   132    137   		mp.grindvalue = math.max(1,math.ceil(mp.grindvalue * wearfac))
   133    138   		mp.hardness = math.max(1,math.ceil(mp.grindcost * wearfac))
................................................................................
   281    286   				local speedboost = math.max(0.05,((grindpower - mp.hardness)/constants.grind_range) * grinders)
   282    287   				reqtime = mp.grindvalue * mp.hardness * constants.grind_factor * (1-speedboost)
   283    288   				if elapsed >= reqtime then
   284    289   					item:take_item(mp.grindcost)
   285    290   					inv:set_stack('input',1,item)
   286    291   					local pw = ItemStack{
   287    292   						name=mp.powder;
   288         -						count=mp.grindvalue;
          293  +						count=math.floor(mp.grindvalue);
   289    294   					}
   290    295   					if inv:room_for_item('output',pw) then
   291    296   						inv:add_item('output',pw)
   292    297   					else
   293    298   						minetest.add_item(pos,pw)
   294    299   					end
   295    300   					elapsed = 0