sorcery  Diff

Differences From Artifact [eb69eaaf9d]:

To Artifact [451ab2dcbd]:


     1      1   local log = sorcery.logger('tap')
     2      2   local sap_interval = 60;
            3  +local L=sorcery.lib
     3      4   
     4      5   local function tapdrip(liq, pos)
     5      6   	return sorcery.vfx.drip(liq, vector.offset(pos, 0, -0.3, 0), math.random(5,12), sap_interval, 2)
     6      7   end
     7      8   
     8      9   minetest.register_node('sorcery:tap',{
     9     10   	description = 'Tap';
................................................................................
    35     36   		if vector.subtract(where.under,where.above).y ~= 0 then return end
    36     37   
    37     38   		minetest.set_node(where.above, {
    38     39   			name = 'sorcery:tap';
    39     40   			param2 = minetest.dir_to_wallmounted(vector.subtract(where.under,where.above))
    40     41   		})
    41     42   		
    42         -		if sorcery.lib.node.tree_is_live(where.under) then
           43  +		if L.node.tree_is_live(where.under) then
    43     44   			-- start dripping immediately to indicate the tree is alive
    44     45   			tapdrip(tree.def.sapliq, where.above)
    45     46   		end
    46     47   
    47     48   		stack:take_item(1)
    48     49   		return stack
    49     50   	end;
................................................................................
    86     87   			abm_cache_time = now
    87     88   		end
    88     89   		local tpos = vector.add(pos,minetest.wallmounted_to_dir(node.param2))
    89     90   		local tnode = minetest.get_node(tpos)
    90     91   		if tnode.name == 'air' then return end --pathological case
    91     92   		local tree
    92     93   		for id,t in pairs(sorcery.data.trees) do
    93         -			if t.node == tnode.name then
           94  +			if L.tbl.strmatch(t.node, tnode.name) then
    94     95   				tree = t
    95     96   				goto found
    96     97   			end
    97     98   		end do
    98     99   			return
    99    100   		end ::found::
   100    101   
................................................................................
   105    106   			live = true
   106    107   			local c = abm_cache.treehash[tposhash]
   107    108   			-- mass_leaves = c.mass_leaves
   108    109   			mass_trunk = c.mass_trunk
   109    110   			prevalidate = true
   110    111   		else
   111    112   			local tbody
   112         -			live, tbody = sorcery.lib.node.tree_is_live(tpos)
          113  +			live, tbody = L.node.tree_is_live(tpos)
   113    114   			if live then
   114    115   				should_cache = tbody.nodes[tbody.trunk]
   115    116   				-- mass_leaves = #(tbody.nodes[tbody.leaves])
   116    117   				mass_trunk = #(tbody.nodes[tbody.trunk]) * 12
   117    118   				topnode = tbody.topnode
   118    119   			end
   119    120   		end
................................................................................
   140    141   		-- 	if minetest.get_natural_light(vector.offset(topnode,0,1,0), 0.5) < 13
   141    142   		-- 		then return false end
   142    143   		-- end
   143    144   		-- FIXME
   144    145   
   145    146   		for i=1,8 do
   146    147   			local at = vector.offset(pos, 0,-i,0)
   147         -			if sorcery.lib.node.is_air(at) then goto skip end
          148  +			if L.node.is_air(at) then goto skip end
   148    149   
   149    150   			local trough = minetest.get_node(at)
   150    151   			if minetest.get_item_group(trough.name, 'sorcery_trough') ~= 0 then
   151    152   				local n = minetest.registered_nodes[trough.name]
   152    153   				local l = sorcery.register.liquid.db[tree.sapliq]
   153    154   				local C = sorcery.liquid.constants
   154    155   				if n._sorcery and n._sorcery.container then