2015-10-04 22:40:36 +02:00
|
|
|
--
|
|
|
|
-- Drop items on die mod
|
|
|
|
-- By Kaadmy, for Pixture
|
|
|
|
--
|
|
|
|
|
2017-05-17 18:24:18 +02:00
|
|
|
drop_items_on_die = {}
|
|
|
|
|
|
|
|
drop_items_on_die.registered_listnames = {}
|
|
|
|
|
2017-06-27 21:13:30 +02:00
|
|
|
local enable_drop = minetest.settings:get_bool("drop_items_on_die") or false
|
2015-10-04 22:40:36 +02:00
|
|
|
|
2017-05-17 18:24:18 +02:00
|
|
|
function drop_items_on_die.register_listname(listname)
|
|
|
|
table.insert(drop_items_on_die.registered_listnames, listname)
|
|
|
|
end
|
|
|
|
|
2015-10-04 22:40:36 +02:00
|
|
|
local function on_die(player)
|
2019-03-20 15:04:20 +01:00
|
|
|
local pos = player:get_pos()
|
2015-10-04 22:40:36 +02:00
|
|
|
|
|
|
|
local inv = player:get_inventory()
|
|
|
|
|
2017-05-17 18:24:18 +02:00
|
|
|
for _, listname in ipairs(drop_items_on_die.registered_listnames) do
|
|
|
|
for i = 1, inv:get_size(listname) do
|
|
|
|
local item = inv:get_stack(listname, i)
|
|
|
|
|
2017-07-02 22:28:17 +02:00
|
|
|
item_drop.drop_item(pos, item)
|
2017-05-17 18:24:18 +02:00
|
|
|
|
|
|
|
item:clear()
|
|
|
|
|
|
|
|
inv:set_stack(listname, i, item)
|
|
|
|
end
|
2015-10-04 22:40:36 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
if enable_drop then
|
2017-05-12 04:29:55 +02:00
|
|
|
minetest.register_on_dieplayer(on_die)
|
2017-05-17 18:24:18 +02:00
|
|
|
|
|
|
|
drop_items_on_die.register_listname("main")
|
2015-10-04 22:40:36 +02:00
|
|
|
end
|
|
|
|
|
2017-05-17 18:24:18 +02:00
|
|
|
default.log("mod:drop_items_on_die", "loaded")
|