starlit  Diff

Differences From Artifact [288b4b5859]:

To Artifact [d777bc86b5]:


     3      3   --  🄯 EUPL v1.2
     4      4   --  ? 
     5      5   
     6      6   -------------------------------
     7      7   -- basic suit nano abilities --
     8      8   -------------------------------
     9      9   local function shredder(prop)
    10         -	local function getItemsForFab(fab)
           10  +	local function fabToItemsAndCharges(fab)
    11     11   		local elt
    12     12   		if fab then
    13     13   			elt = fab:elementalize()
    14     14   		else
    15     15   			elt = {}
    16     16   		end
    17         -		local items = {}
           17  +		local items,charges = {},{}
    18     18   		if elt.element then
    19     19   			for k,v in pairs(elt.element) do
    20         -				local st = ItemStack {
    21         -					name = starlit.world.material.element.db[k].form.element;
    22         -					count = v;
    23         -				}
    24         -				table.insert(items, st)
           20  +				local forms =  starlit.world.material.element.db[k].form
           21  +				if forms.brick then
           22  +					local st = ItemStack {
           23  +						name = forms.brick;
           24  +						count = math.floor(v);
           25  +					}
           26  +					table.insert(items, st)
           27  +				else -- gas, liquid
           28  +					table.insert(charges, {id = k, mass = v})
           29  +				end
    25     30   			end
    26     31   		end
    27         -		return items
           32  +		print(dump(items))
           33  +		return items, charges
    28     34   	end
    29     35   
    30     36   	return function(user, ctx)
    31     37   		local function cleanup()
    32     38   			user.action.prog.shred = nil
    33     39   			if user.action.sfx.shred then
    34     40   				minetest.sound_fade(user.action.sfx.shred, 1, 0)
................................................................................
   101    107   					user:suitSound 'starlit-success'
   102    108   					if fab then
   103    109   						local vf = fab
   104    110   						if vary then
   105    111   							local rng = (starlit.world.seedbank+0xa891f62)[minetest.hash_node_position(what)]
   106    112   							vf = vf + vary(rng, {})
   107    113   						end
   108         -						local items = getItemsForFab(vf)
          114  +						local items, charges = fabToItemsAndCharges(vf)
   109    115   						for i, it in ipairs(items) do user:give(it) end
          116  +						-- TODO give gasses, liquids
   110    117   					end
   111    118   				else
   112    119   					user:suitSound 'starlit-error'
   113    120   				end
   114    121   				cleanup()
   115    122   			end
   116    123   		elseif ctx.how.state == 'halt' then