capturetheflag/mods/pvp/dropondie/init.lua

49 lines
1.1 KiB
Lua
Raw Normal View History

local blacklist_drop = {}
2015-07-16 17:44:01 +00:00
2015-12-08 01:20:36 +00:00
local function drop(pos, itemstack)
2015-07-16 17:44:01 +00:00
local it = itemstack:take_item(itemstack:get_count())
2015-12-08 01:20:36 +00:00
local sname = it:get_name()
for _, item in pairs(blacklist_drop) do
if sname == item then
minetest.log("info", "Not dropping " .. item)
2015-12-08 01:20:36 +00:00
return
end
end
local obj = minetest.add_item(pos, it)
2015-07-16 17:44:01 +00:00
if obj then
obj:set_velocity({x=math.random(-1,1), y=5, z=math.random(-1,1)})
2015-07-16 17:44:01 +00:00
local remi = minetest.settings:get("remove_items")
2015-12-07 23:00:32 +00:00
if minetest.is_yes(remi) then
obj:remove()
end
2015-07-16 17:44:01 +00:00
end
return itemstack
end
local function drop_list(pos, inv, list)
for i = 1, inv:get_size(list) do
drop(pos, inv:get_stack(list, i))
inv:set_stack(list, i, nil)
2015-07-16 17:44:01 +00:00
end
end
2015-07-16 17:44:01 +00:00
local function drop_all(player)
local pos = player:get_pos()
2015-07-16 17:44:01 +00:00
pos.y = math.floor(pos.y + 0.5)
local inv = player:get_inventory()
for _, item in pairs(give_initial_stuff.get_stuff()) do
inv:remove_item("main", ItemStack(item))
2015-07-16 17:44:01 +00:00
end
drop_list(pos, inv, "main")
drop_list(pos, inv, "craft")
2015-12-08 01:20:36 +00:00
end
2015-07-16 17:44:01 +00:00
2015-12-08 01:20:36 +00:00
minetest.register_on_dieplayer(drop_all)
minetest.register_on_leaveplayer(drop_all)