Dont use register_on_dignode anymore

This commit is contained in:
PilzAdam 2012-09-03 18:52:59 +02:00
parent e7ea85077f
commit 4aa8cdfdb2
1 changed files with 20 additions and 36 deletions

View File

@ -63,45 +63,29 @@ minetest.register_globalstep(function(dtime)
end) end)
function minetest.handle_node_drops(pos, drops, digger) function minetest.handle_node_drops(pos, drops, digger)
return for _,item in ipairs(drops) do
end local count, name
minetest.register_on_dignode(function(pos, oldnode, digger)
local drop = minetest.get_node_drops(oldnode.name, digger:get_wielded_item():get_name())
if drop == nil then
return
end
for _,item in ipairs(drop) do
if type(item) == "string" then if type(item) == "string" then
local obj = minetest.env:add_item(pos, item) count = 1
if obj ~= nil then name = item
obj:get_luaentity().collect = true
local x = math.random(1, 5)
if math.random(1,2) == 1 then
x = -x
end
local z = math.random(1, 5)
if math.random(1,2) == 1 then
z = -z
end
obj:setvelocity({x=1/x, y=obj:getvelocity().y, z=1/z})
end
else else
for i=1,item:get_count() do count = item:get_count()
local obj = minetest.env:add_item(pos, item:get_name()) name = item:get_name()
if obj ~= nil then end
obj:get_luaentity().collect = true for i=1,count do
local x = math.random(1, 5) local obj = minetest.env:add_item(pos, name)
if math.random(1,2) == 1 then if obj ~= nil then
x = -x obj:get_luaentity().collect = true
end local x = math.random(1, 5)
local z = math.random(1, 5) if math.random(1,2) == 1 then
if math.random(1,2) == 1 then x = -x
z = -z
end
obj:setvelocity({x=1/x, y=obj:getvelocity().y, z=1/z})
end end
local z = math.random(1, 5)
if math.random(1,2) == 1 then
z = -z
end
obj:setvelocity({x=1/x, y=obj:getvelocity().y, z=1/z})
end end
end end
end end
end) end