Merge from TenPlus1, packaged by Wuzzy
From https://forum.minetest.net/viewtopic.php?p=157958#p150768 https://forum.minetest.net/viewtopic.php?p=157958#p157958master
parent
baa86a27c8
commit
74f79b060e
|
@ -1 +0,0 @@
|
|||
default
|
|
@ -0,0 +1 @@
|
|||
With this mod, players will drop all their items in their inventory on the ground when they die.
|
54
init.lua
54
init.lua
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue