Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local defs = {}
- minetest.after(0.01, function()
- for name, def in pairs(minetest.registered_items) do
- if def.can_dig then
- defs[name] = {}
- defs[name].can_dig = def.can_dig
- defs[name].on_metadata_inventory_take = def.on_metadata_inventory_take
- def.can_dig = function (pos,player)
- local node = minetest.get_node(pos)
- local meta = minetest.get_meta(pos)
- local owner = meta:get_string("owner")
- local def = defs[node.name]
- local inv = meta:get_inventory()
- local is_empty = true
- for inv_name in pairs(meta:to_table()["inventory"]) do
- if not inv:is_empty(inv_name) then is_empty = false end
- end
- if owner ~= "" and owner ~= player:get_player_name() then
- return defs[name].can_dig (pos,player)
- end
- for inv_name in pairs(meta:to_table()["inventory"]) do
- if not inv:is_empty(inv_name) then
- local size = inv:get_size(inv_name)
- for i = 1, size do
- local item = inv:get_stack(inv_name, i)
- if item ~= nil then
- minetest.add_item({x = pos.x + math.random() * 2 - 1, y = pos.y+math.random() * 2, z = pos.z + math.random() * 2 - 1}, item)
- inv:set_stack(inv_name, i, "")
- end
- end
- end
- end
- return defs[name].can_dig (pos,player)
- end
- end
- end
- end
- )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement