Index: data/trees.lua ================================================================== --- data/trees.lua +++ data/trees.lua @@ -39,13 +39,16 @@ color = {217, 51, 22}; sapglow = 7; }; jungle = { desc = 'Jungle'; - node = 'default:jungletree'; + node = { + 'default:jungletree'; + 'moretrees:jungletree_trunk'; + }; sapling = 'default:junglesapling'; leaves = 'default:jungleleaves'; sap = 'Tropical Syrup'; color = {86, 39, 71}; imgvariant = 'dull'; }; } Index: lib/node.lua ================================================================== --- lib/node.lua +++ lib/node.lua @@ -213,11 +213,13 @@ local treetype = force(pos).name if minetest.get_item_group(treetype, 'tree') == 0 then -- sir this is not a tree return nil -- 無 end - local treedef = sorcery.lib.tbl.select(sorcery.data.trees, 'node', treetype) + local treedef = sorcery.lib.tbl.select(sorcery.data.trees, function(ent) + return sorcery.lib.tbl.strmatch(ent.node, treetype) + end) local leaftype = treedef and treedef.leaves or nil if not leaftype then return false end local uppermost, lowermost local found_leaves = false Index: lib/tbl.lua ================================================================== --- lib/tbl.lua +++ lib/tbl.lua @@ -202,10 +202,16 @@ fn.cond = function(exp, c) for i, v in ipairs(c) do if c[1](exp) then return c[2](exp) end end end + +fn.strmatch = function(tbl, str) + if tbl == str then return true end + if type(tbl) == 'string' then return false end + return fn.has(tbl, str) +end fn.select = function(tbl, prop, ...) local keycache local check if type(prop) == 'function' then check = prop Index: tap.lua ================================================================== --- tap.lua +++ tap.lua @@ -1,7 +1,8 @@ local log = sorcery.logger('tap') local sap_interval = 60; +local L=sorcery.lib local function tapdrip(liq, pos) return sorcery.vfx.drip(liq, vector.offset(pos, 0, -0.3, 0), math.random(5,12), sap_interval, 2) end @@ -37,11 +38,11 @@ minetest.set_node(where.above, { name = 'sorcery:tap'; param2 = minetest.dir_to_wallmounted(vector.subtract(where.under,where.above)) }) - if sorcery.lib.node.tree_is_live(where.under) then + if L.node.tree_is_live(where.under) then -- start dripping immediately to indicate the tree is alive tapdrip(tree.def.sapliq, where.above) end stack:take_item(1) @@ -88,11 +89,11 @@ local tpos = vector.add(pos,minetest.wallmounted_to_dir(node.param2)) local tnode = minetest.get_node(tpos) if tnode.name == 'air' then return end --pathological case local tree for id,t in pairs(sorcery.data.trees) do - if t.node == tnode.name then + if L.tbl.strmatch(t.node, tnode.name) then tree = t goto found end end do return @@ -107,11 +108,11 @@ -- mass_leaves = c.mass_leaves mass_trunk = c.mass_trunk prevalidate = true else local tbody - live, tbody = sorcery.lib.node.tree_is_live(tpos) + live, tbody = L.node.tree_is_live(tpos) if live then should_cache = tbody.nodes[tbody.trunk] -- mass_leaves = #(tbody.nodes[tbody.leaves]) mass_trunk = #(tbody.nodes[tbody.trunk]) * 12 topnode = tbody.topnode @@ -142,11 +143,11 @@ -- end -- FIXME for i=1,8 do local at = vector.offset(pos, 0,-i,0) - if sorcery.lib.node.is_air(at) then goto skip end + if L.node.is_air(at) then goto skip end local trough = minetest.get_node(at) if minetest.get_item_group(trough.name, 'sorcery_trough') ~= 0 then local n = minetest.registered_nodes[trough.name] local l = sorcery.register.liquid.db[tree.sapliq] Index: tree.lua ================================================================== --- tree.lua +++ tree.lua @@ -9,27 +9,33 @@ local L = sorcery.lib sorcery.register.trees.foreach('sorcery:treesetup', {}, function(id, t) -- generates sap and hooks handlers appropriately if t.node then - local def = minetest.registered_nodes[t.node] - local nextfn = def.on_place - minetest.override_item(t.node, { on_place = function(stack, who, pointed, ...) - if nextfn then nextfn(stack, who, pointed, ...) end - if who ~= nil and pointed.type == 'node' then - -- local pos = pointed.above - -- local _, counts = minetest.find_nodes_in_area( - -- vector.offset(pos, -1,-1,-1), - -- vector.offset(pos, 1, 1, 1), - -- t.leaves or 'group:leaves', false) - -- if counts[next(counts)] > 0 then - local n = minetest.get_node(pointed.above) - n.param1 = 1 - minetest.swap_node(pointed.above, n) - -- end + local nodes = t.node + if type(nodes) == 'string' then nodes = {nodes} end + for _, node in pairs(nodes) do + local def = minetest.registered_nodes[node] + if def then + local nextfn = def.on_place + minetest.override_item(node, { on_place = function(stack, who, pointed, ...) + if nextfn then nextfn(stack, who, pointed, ...) end + if who ~= nil and pointed.type == 'node' then + -- local pos = pointed.above + -- local _, counts = minetest.find_nodes_in_area( + -- vector.offset(pos, -1,-1,-1), + -- vector.offset(pos, 1, 1, 1), + -- t.leaves or 'group:leaves', false) + -- if counts[next(counts)] > 0 then + local n = minetest.get_node(pointed.above) + n.param1 = 1 + minetest.swap_node(pointed.above, n) + -- end + end + end }) end - end }) + end end if t.sap == false then return end if not t.sapliq then t.sapliq = string.format('sorcery:sap_%s', id) @@ -58,11 +64,11 @@ pos = what name = sorcery.lib.node.force(what).name end for tn, def in pairs(sorcery.data.trees) do - if def.node == name then + if L.tbl.strmatch(def.node, name) then return { tree = tn; def = def; pos = pos; node = name;