2014-10-28 18:01:32 +01:00
|
|
|
local drop = function(pos, itemstack)
|
|
|
|
|
2014-10-29 00:36:51 +01:00
|
|
|
local it = itemstack:take_item(itemstack:get_count())
|
|
|
|
local obj = core.add_item(pos, it)
|
2014-10-28 18:01:32 +01:00
|
|
|
|
2014-10-29 00:36:51 +01:00
|
|
|
if obj then
|
2014-10-28 18:01:32 +01:00
|
|
|
|
2015-04-05 00:26:51 +02:00
|
|
|
obj:setvelocity({x=math.random(-2.5,2.5), y=7, z=math.random(-2.5,2.5)})
|
2014-10-28 18:01:32 +01:00
|
|
|
|
2014-10-29 00:36:51 +01:00
|
|
|
local remi = minetest.setting_get("remove_items")
|
2014-10-28 18:01:32 +01:00
|
|
|
|
2014-10-29 00:36:51 +01:00
|
|
|
if remi and remi == "true" then
|
|
|
|
obj:remove()
|
|
|
|
end
|
2014-10-28 18:01:32 +01:00
|
|
|
|
2014-10-29 00:36:51 +01:00
|
|
|
end
|
|
|
|
return itemstack
|
2014-10-28 18:01:32 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
minetest.register_on_dieplayer(function(player)
|
2014-10-29 00:36:51 +01:00
|
|
|
|
2014-10-28 18:01:32 +01:00
|
|
|
if minetest.setting_getbool("creative_mode") then
|
|
|
|
return
|
|
|
|
end
|
2014-10-29 00:36:51 +01:00
|
|
|
|
2014-10-28 18:01:32 +01:00
|
|
|
local pos = player:getpos()
|
|
|
|
pos.y = math.floor(pos.y + 0.5)
|
2014-10-29 00:36:51 +01:00
|
|
|
|
2014-10-28 18:01:32 +01:00
|
|
|
minetest.chat_send_player(player:get_player_name(), 'at '..math.floor(pos.x)..','..math.floor(pos.y)..','..math.floor(pos.z))
|
2014-10-29 00:36:51 +01:00
|
|
|
|
2014-10-28 18:01:32 +01:00
|
|
|
local player_inv = player:get_inventory()
|
2014-10-29 00:36:51 +01:00
|
|
|
|
2014-10-28 18:01:32 +01:00
|
|
|
for i=1,player_inv:get_size("main") do
|
|
|
|
drop(pos, player_inv:get_stack("main", i))
|
|
|
|
player_inv:set_stack("main", i, nil)
|
|
|
|
end
|
2014-10-29 00:36:51 +01:00
|
|
|
|
2014-10-28 18:01:32 +01:00
|
|
|
for i=1,player_inv:get_size("craft") do
|
|
|
|
drop(pos, player_inv:get_stack("craft", i))
|
|
|
|
player_inv:set_stack("craft", i, nil)
|
|
|
|
end
|
2014-10-28 22:26:44 +01:00
|
|
|
|
2014-10-29 00:36:51 +01:00
|
|
|
-- Drop unified_inventory bags and their contents
|
2014-10-28 22:26:44 +01:00
|
|
|
if minetest.get_modpath("unified_inventory") then
|
2015-06-10 17:14:58 +02:00
|
|
|
|
2014-10-29 00:36:51 +01:00
|
|
|
local bag_id = {"bag1", "bag2", "bag3", "bag4"}
|
2014-10-28 22:26:44 +01:00
|
|
|
local contents_id = ""
|
|
|
|
local n = 0
|
|
|
|
|
|
|
|
for n = 1, 4 do
|
2014-10-29 00:36:51 +01:00
|
|
|
if player_inv:get_size(bag_id[n]) ~= nil and player_inv:get_size(bag_id[n]) == 1 then
|
2014-10-28 22:26:44 +01:00
|
|
|
contents_id = bag_id[n].."contents"
|
|
|
|
-- Drop the contents of the bag (but keep the bag itself)
|
|
|
|
for i = 1, player_inv:get_size(contents_id) do
|
|
|
|
-- Drop a clone of this item's stack and remove the one from the inventory
|
|
|
|
drop(pos, player_inv:get_stack(contents_id, i))
|
|
|
|
player_inv:set_stack(contents_id, i, nil)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
2014-10-29 00:36:51 +01:00
|
|
|
end)
|