add particles to tree capitator

master
Juraj Vajda 2018-12-08 15:43:54 -05:00
parent 0e1673686b
commit d50eb4aa41
1 changed files with 32 additions and 0 deletions

32
api.lua
View File

@ -386,6 +386,38 @@ function obsidianmese.dig_up(pos, node, digger)
minetest.node_dig(np, nn, digger)
-- try to find a node texture
local def = minetest.registered_nodes[nn.name]
local texture = "default_dirt.png"
if def then
if def.tiles then
if #def.tiles > 0 then
if type(def.tiles[1]) == "string" then
texture = def.tiles[1]
end
end
end
end
-- add particles only when not too far
minetest.add_particlespawner({
amount = math.random(1, 3),
time = 0.5,
minpos = {x=np.x-0.7, y=np.y, z=np.z-0.7},
maxpos = {x=np.x+0.7, y=np.y+0.75, z=np.z+0.7},
minvel = {x = -0.5, y = -4, z = -0.5},
maxvel = {x = 0.5, y = -2, z = 0.5},
minacc = {x = -0.5, y = -4, z = -0.5},
maxacc = {x = 0.5, y = -2, z = 0.5},
minexptime = 0.5,
maxexptime = 1,
minsize = 0.5,
maxsize = 2,
collisiondetection = true,
texture = texture
})
if #branches_pos > 0 then
for i = 1, #branches_pos do
-- prevent infinite loop when node protected