Differences From
Artifact [9824222a51]:
7 7 }
8 8 local log = sorcery.logger('tree')
9 9 local L = sorcery.lib
10 10
11 11 sorcery.register.trees.foreach('sorcery:treesetup', {}, function(id, t)
12 12 -- generates sap and hooks handlers appropriately
13 13 if t.node then
14 - local def = minetest.registered_nodes[t.node]
15 - local nextfn = def.on_place
16 - minetest.override_item(t.node, { on_place = function(stack, who, pointed, ...)
17 - if nextfn then nextfn(stack, who, pointed, ...) end
18 - if who ~= nil and pointed.type == 'node' then
19 - -- local pos = pointed.above
20 - -- local _, counts = minetest.find_nodes_in_area(
21 - -- vector.offset(pos, -1,-1,-1),
22 - -- vector.offset(pos, 1, 1, 1),
23 - -- t.leaves or 'group:leaves', false)
24 - -- if counts[next(counts)] > 0 then
25 - local n = minetest.get_node(pointed.above)
26 - n.param1 = 1
27 - minetest.swap_node(pointed.above, n)
28 - -- end
14 + local nodes = t.node
15 + if type(nodes) == 'string' then nodes = {nodes} end
16 + for _, node in pairs(nodes) do
17 + local def = minetest.registered_nodes[node]
18 + if def then
19 + local nextfn = def.on_place
20 + minetest.override_item(node, { on_place = function(stack, who, pointed, ...)
21 + if nextfn then nextfn(stack, who, pointed, ...) end
22 + if who ~= nil and pointed.type == 'node' then
23 + -- local pos = pointed.above
24 + -- local _, counts = minetest.find_nodes_in_area(
25 + -- vector.offset(pos, -1,-1,-1),
26 + -- vector.offset(pos, 1, 1, 1),
27 + -- t.leaves or 'group:leaves', false)
28 + -- if counts[next(counts)] > 0 then
29 + local n = minetest.get_node(pointed.above)
30 + n.param1 = 1
31 + minetest.swap_node(pointed.above, n)
32 + -- end
33 + end
34 + end })
29 35 end
30 - end })
36 + end
31 37 end
32 38
33 39 if t.sap == false then return end
34 40 if not t.sapliq then
35 41 t.sapliq = string.format('sorcery:sap_%s', id)
36 42 local sapdesc = t.sap or (t.desc .. ' Tree Sap')
37 43 sorcery.liquid.register {
................................................................................
56 62 name = what
57 63 else
58 64 pos = what
59 65 name = sorcery.lib.node.force(what).name
60 66 end
61 67
62 68 for tn, def in pairs(sorcery.data.trees) do
63 - if def.node == name then
69 + if L.tbl.strmatch(def.node, name) then
64 70 return {
65 71 tree = tn;
66 72 def = def;
67 73 pos = pos;
68 74 node = name;
69 75 }
70 76 end