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