First, I tried using add_luaentity like so:
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
- Code: Select all
minetest.env:add_luaentity(new_p, "leaf_decay:sapling")
That solicited the following error:
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
- Code: Select all
minetest.env:add_luaentity(new_p, "leaf_decay:sapling")
Any ideas as to why that happened, and how I should fix it? The entity referenced is declared earlier in the code.
The second problem is that the following code doesn't work as expected:
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
- Code: Select all
DISTANCE = 3
found_tree = 1
for x=-DISTANCE,DISTANCE do
for y=-DISTANCE,DISTANCE do
for z=-DISTANCE,DISTANCE do
local test_p = {pos.x+x, pos.y+y, pos.z+z}
local test_node = minetest.env:get_node(test_p)
if test_node.name == "default:tree" or test_node.name == "default:jungletree" then
found_tree = 2
break
end
end
if found_tree == 2 then break end
end
if found_tree == 2 then break end
end
if found_tree == 1 then
minetest.env:remove_node(pos)
end
The leaves are *always* removed, even if there is a tree near them. So, what am I doing wrong here?
Thanks a bunch, guys.