forked from MineClone5/MineClone5
Drop crafting grid and armor on death
This commit is contained in:
parent
e3751d0931
commit
787568e5d6
|
@ -2,16 +2,19 @@
|
|||
minetest.register_on_dieplayer(function(player)
|
||||
local inv = player:get_inventory()
|
||||
local pos = player:getpos()
|
||||
for i,stack in ipairs(inv:get_list("main")) do
|
||||
local x = math.random(0, 9)/3
|
||||
local z = math.random(0, 9)/3
|
||||
pos.x = pos.x + x
|
||||
pos.z = pos.z + z
|
||||
minetest.add_item(pos, stack)
|
||||
stack:clear()
|
||||
inv:set_stack("main", i, stack)
|
||||
pos.x = pos.x - x
|
||||
pos.z = pos.z - z
|
||||
local lists = { "main", "craft", "armor" }
|
||||
for l=1,#lists do
|
||||
for i,stack in ipairs(inv:get_list(lists[l])) do
|
||||
local x = math.random(0, 9)/3
|
||||
local z = math.random(0, 9)/3
|
||||
pos.x = pos.x + x
|
||||
pos.z = pos.z + z
|
||||
minetest.add_item(pos, stack)
|
||||
stack:clear()
|
||||
inv:set_stack(lists[l], i, stack)
|
||||
pos.x = pos.x - x
|
||||
pos.z = pos.z - z
|
||||
end
|
||||
end
|
||||
end)
|
||||
--end
|
||||
|
|
Loading…
Reference in New Issue