forked from Mineclonia/Mineclonia
Fix armor destroy bugs on death
This commit is contained in:
parent
7b16b74903
commit
3fb5ce8ab0
|
@ -16,7 +16,8 @@ ARMOR_FIRE_NODES = {
|
||||||
{"mcl_fire:eternal_fire", 3, 4},
|
{"mcl_fire:eternal_fire", 3, 4},
|
||||||
}
|
}
|
||||||
|
|
||||||
ARMOR_DROP = true
|
-- Armor drop/destroy disabled. Armor dropping is handled in mcl_death
|
||||||
|
ARMOR_DROP = false
|
||||||
ARMOR_DESTROY = false
|
ARMOR_DESTROY = false
|
||||||
ARMOR_HEAL_MULTIPLIER = 0
|
ARMOR_HEAL_MULTIPLIER = 0
|
||||||
ARMOR_RADIATION_MULTIPLIER = 0
|
ARMOR_RADIATION_MULTIPLIER = 0
|
||||||
|
|
|
@ -1,22 +1,37 @@
|
||||||
minetest.register_on_dieplayer(function(player)
|
minetest.register_on_dieplayer(function(player)
|
||||||
local keep = minetest.setting_getbool("mcl_keepInventory") or false
|
local keep = minetest.setting_getbool("mcl_keepInventory") or false
|
||||||
if keep == false then
|
if keep == false then
|
||||||
|
-- Drop inventory, crafting grid and armor
|
||||||
local inv = player:get_inventory()
|
local inv = player:get_inventory()
|
||||||
local pos = player:getpos()
|
local pos = player:getpos()
|
||||||
local lists = { "main", "craft", "armor" }
|
local name, player_armor_inv, armor_armor_inv, pos = armor:get_valid_player(player, "[on_dieplayer]")
|
||||||
|
local lists = {
|
||||||
|
{ inv = inv, listname = "main", drop = true },
|
||||||
|
{ inv = inv, listname = "craft", drop = true },
|
||||||
|
{ inv = player_armor_inv, listname = "armor", drop = true },
|
||||||
|
{ inv = armor_armor_inv, listname = "armor", drop = false },
|
||||||
|
}
|
||||||
for l=1,#lists do
|
for l=1,#lists do
|
||||||
for i,stack in ipairs(inv:get_list(lists[l])) do
|
local inv = lists[l].inv
|
||||||
|
local listname = lists[l].listname
|
||||||
|
local drop = lists[l].drop
|
||||||
|
if inv ~= nil then
|
||||||
|
for i, stack in ipairs(inv:get_list(listname)) do
|
||||||
local x = math.random(0, 9)/3
|
local x = math.random(0, 9)/3
|
||||||
local z = math.random(0, 9)/3
|
local z = math.random(0, 9)/3
|
||||||
pos.x = pos.x + x
|
pos.x = pos.x + x
|
||||||
pos.z = pos.z + z
|
pos.z = pos.z + z
|
||||||
|
if drop then
|
||||||
minetest.add_item(pos, stack)
|
minetest.add_item(pos, stack)
|
||||||
|
end
|
||||||
stack:clear()
|
stack:clear()
|
||||||
inv:set_stack(lists[l], i, stack)
|
inv:set_stack(listname, i, stack)
|
||||||
pos.x = pos.x - x
|
pos.x = pos.x - x
|
||||||
pos.z = pos.z - z
|
pos.z = pos.z - z
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
armor:set_player_armor(player)
|
||||||
armor:update_inventory(player)
|
armor:update_inventory(player)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue