minermoder27 2014-10-20 18:18:27 +13:00
parent baa86a27c8
commit 74f79b060e
3 changed files with 23 additions and 33 deletions

View File

@ -1 +0,0 @@
default

1
description.txt Normal file
View File

@ -0,0 +1 @@
With this mod, players will drop all their items in their inventory on the ground when they die.

View File

@ -1,53 +1,43 @@
local drop = function(pos, itemstack)
local it = itemstack:take_item(itemstack:get_count())
local obj = core.add_item(pos, it)
if obj then
obj:setvelocity({x=math.random(-1,1), y=5, z=math.random(-1,1)})
local drop = function(pos, istack)
--for i=1, istack:get_count() do
local obj = minetest.env:add_item(pos, istack:get_name() .. " " .. istack:get_count())
if obj ~= nil then
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=5, z=1/z})
-- FIXME this doesnt work for deactiveted objects
if minetest.setting_get("remove_items") and tonumber(minetest.setting_get("remove_items")) then
minetest.after(tonumber(minetest.setting_get("remove_items")), function(obj)
obj:remove()
end, obj)
end
end
--end
local remi = minetest.setting_get("remove_items")
if remi and remi == "true" then
obj:remove()
end
end
return itemstack
end
minetest.register_on_dieplayer(function(player)
if minetest.setting_getbool("creative_mode") then
return
end
local pos = player:getpos()
pos.x = math.floor(pos.x+0.5)
pos.y = math.floor(pos.y+0.5)
pos.z = math.floor(pos.z+0.5)
local param2 = minetest.dir_to_facedir(player:get_look_dir())
pos.y = math.floor(pos.y + 0.5)
minetest.chat_send_player(player:get_player_name(), 'at '..math.floor(pos.x)..','..math.floor(pos.y)..','..math.floor(pos.z))
local player_inv = player:get_inventory()
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
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
end)