181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
...
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
|
return true
end;
tree_is_live = function(pos, checklight) -- VERY EXPENSIVE FUNCTION
-- this is going to require some explanation.
--
-- for various purposes, we want to be able to tell the difference between
-- a tree that has grown naturally from the grown vs. a couple of trunk nodes
-- that the player has jammed together, even if she's built her own counterfeit
-- tree. unfortunately, mtg provides no easy way to do this. the only
-- difference between a cluster of trunk blocks and a real tree is that the
-- real tree will have a specific kind of leaves attached with their param2
-- set to 1 so that they can be distinguished for the purpose of leaf cleaning.
-- so to check a tree's state, we need to amass its whole potential body, and if
-- there are legitimate leaves connected, then we identify it as a legit tree.
................................................................................
for _,p in pairs(n) do
local sum = vector.add(pos, p)
local n = minetest.get_node(sum)
if n.name == 'ignore' then
minetest.load_area(sum)
n = minetest.get_node(sum)
end
fn(sum, n)
end
end;
amass = amass;
force = force;
|
|
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
...
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
|
return true
end;
tree_is_live = function(pos, checklight) -- VERY EXPENSIVE FUNCTION
-- this is going to require some explanation.
--
-- for various purposes, we want to be able to tell the difference between
-- a tree that has grown naturally from the ground vs. a couple of trunk nodes
-- that the player has jammed together, even if she's built her own counterfeit
-- tree. unfortunately, mtg provides no easy way to do this. the only
-- difference between a cluster of trunk blocks and a real tree is that the
-- real tree will have a specific kind of leaves attached with their param2
-- set to 1 so that they can be distinguished for the purpose of leaf cleaning.
-- so to check a tree's state, we need to amass its whole potential body, and if
-- there are legitimate leaves connected, then we identify it as a legit tree.
................................................................................
for _,p in pairs(n) do
local sum = vector.add(pos, p)
local n = minetest.get_node(sum)
if n.name == 'ignore' then
minetest.load_area(sum)
n = minetest.get_node(sum)
end
if fn(sum, n) == false then break end
end
end;
amass = amass;
force = force;
|