fix server crash bug - thanks @leo_rockway

This commit is contained in:
Brett O'Donnell 2012-10-05 12:21:48 +09:30
parent 79e602f67e
commit 022f3c97cf

View File

@ -46,7 +46,7 @@ minetest.register_entity("particles:particle", {
minetest.register_on_dignode(function(pos, oldnode, digger) minetest.register_on_dignode(function(pos, oldnode, digger)
local node = minetest.registered_nodes[oldnode.name] local node = minetest.registered_nodes[oldnode.name]
-- if the no_particles group is set dont add particles -- if the no_particles group is set dont add particles
if node == nil or node.groups.no_particles then if not node or node.groups.no_particles or not digger then
return return
end end
-- try to get the textures from the dig_result instead of the digged node -- try to get the textures from the dig_result instead of the digged node
@ -72,10 +72,10 @@ minetest.register_on_dignode(function(pos, oldnode, digger)
local dx = (math.random(0,10)-5)/10 local dx = (math.random(0,10)-5)/10
local dy = (math.random(0,10)-5)/10 local dy = (math.random(0,10)-5)/10
local dz = (math.random(0,10)-5)/10 local dz = (math.random(0,10)-5)/10
-- spawn at random position in the node -- spawn at random position in the node
local obj = minetest.env:add_entity({x=pos.x+dx, y=pos.y+dy, z=pos.z+dz}, "particles:particle") local obj = minetest.env:add_entity({x=pos.x+dx, y=pos.y+dy, z=pos.z+dz}, "particles:particle")
-- set the textures -- set the textures
local textures = {} local textures = {}
local max = 1 local max = 1
@ -165,4 +165,4 @@ minetest.register_abm({
}) })
-- log that we started -- log that we started
minetest.log("action", "[MOD]"..minetest.get_current_modname().." -- loaded from "..minetest.get_modpath(minetest.get_current_modname())) minetest.log("action", "[MOD]"..minetest.get_current_modname().." -- loaded from "..minetest.get_modpath(minetest.get_current_modname()))