forked from MineClone5/MineClone5
Update Fork #9
|
@ -1,56 +1,57 @@
|
||||||
local random = math.random
|
local random = math.random
|
||||||
|
|
||||||
local ipairs = ipairs
|
local ipairs = ipairs
|
||||||
|
|
||||||
mcl_death_drop = {}
|
mcl_death_drop = {}
|
||||||
|
|
||||||
mcl_death_drop.registered_dropped_lists = {}
|
mcl_death_drop.registered_dropped_lists = {}
|
||||||
|
|
||||||
function mcl_death_drop.register_dropped_list(inv, listname, drop)
|
function mcl_death_drop.register_dropped_list(inv, listname, drop)
|
||||||
table.insert(mcl_death_drop.registered_dropped_lists, {inv = inv, listname = listname, drop = drop})
|
table.insert(mcl_death_drop.registered_dropped_lists, {inv = inv, listname = listname, drop = drop})
|
||||||
end
|
end
|
||||||
|
|
||||||
mcl_death_drop.register_dropped_list("PLAYER", "main", true)
|
mcl_death_drop.register_dropped_list("PLAYER", "main", true)
|
||||||
mcl_death_drop.register_dropped_list("PLAYER", "craft", true)
|
mcl_death_drop.register_dropped_list("PLAYER", "craft", true)
|
||||||
mcl_death_drop.register_dropped_list("PLAYER", "armor", true)
|
mcl_death_drop.register_dropped_list("PLAYER", "armor", true)
|
||||||
|
mcl_death_drop.register_dropped_list("PLAYER", "offhand", true)
|
||||||
minetest.register_on_dieplayer(function(player)
|
|
||||||
local keep = minetest.settings:get_bool("mcl_keepInventory", false)
|
minetest.register_on_dieplayer(function(player)
|
||||||
if keep == false then
|
local keep = minetest.settings:get_bool("mcl_keepInventory", false)
|
||||||
-- Drop inventory, crafting grid and armor
|
if keep == false then
|
||||||
local playerinv = player:get_inventory()
|
-- Drop inventory, crafting grid and armor
|
||||||
local pos = player:get_pos()
|
local playerinv = player:get_inventory()
|
||||||
-- No item drop if in deep void
|
local pos = player:get_pos()
|
||||||
local _, void_deadly = mcl_worlds.is_in_void(pos)
|
-- No item drop if in deep void
|
||||||
|
local _, void_deadly = mcl_worlds.is_in_void(pos)
|
||||||
for l=1,#mcl_death_drop.registered_dropped_lists do
|
|
||||||
local inv = mcl_death_drop.registered_dropped_lists[l].inv
|
for l=1,#mcl_death_drop.registered_dropped_lists do
|
||||||
if inv == "PLAYER" then
|
local inv = mcl_death_drop.registered_dropped_lists[l].inv
|
||||||
inv = playerinv
|
if inv == "PLAYER" then
|
||||||
elseif type(inv) == "function" then
|
inv = playerinv
|
||||||
inv = inv(player)
|
elseif type(inv) == "function" then
|
||||||
end
|
inv = inv(player)
|
||||||
local listname = mcl_death_drop.registered_dropped_lists[l].listname
|
end
|
||||||
local drop = mcl_death_drop.registered_dropped_lists[l].drop
|
local listname = mcl_death_drop.registered_dropped_lists[l].listname
|
||||||
if inv then
|
local drop = mcl_death_drop.registered_dropped_lists[l].drop
|
||||||
for i, stack in ipairs(inv:get_list(listname)) do
|
if inv then
|
||||||
local x = random(0, 9)/3
|
for i, stack in ipairs(inv:get_list(listname)) do
|
||||||
local z = random(0, 9)/3
|
local x = random(0, 9)/3
|
||||||
pos.x = pos.x + x
|
local z = random(0, 9)/3
|
||||||
pos.z = pos.z + z
|
pos.x = pos.x + x
|
||||||
if not void_deadly and drop and not mcl_enchanting.has_enchantment(stack, "curse_of_vanishing") then
|
pos.z = pos.z + z
|
||||||
local def = minetest.registered_items[stack:get_name()]
|
if not void_deadly and drop and not mcl_enchanting.has_enchantment(stack, "curse_of_vanishing") then
|
||||||
if def and def.on_drop then
|
local def = minetest.registered_items[stack:get_name()]
|
||||||
stack = def.on_drop(stack, player, pos)
|
if def and def.on_drop then
|
||||||
end
|
stack = def.on_drop(stack, player, pos)
|
||||||
minetest.add_item(pos, stack)
|
end
|
||||||
end
|
minetest.add_item(pos, stack)
|
||||||
pos.x = pos.x - x
|
end
|
||||||
pos.z = pos.z - z
|
pos.x = pos.x - x
|
||||||
end
|
pos.z = pos.z - z
|
||||||
inv:set_list(listname, {})
|
end
|
||||||
end
|
inv:set_list(listname, {})
|
||||||
end
|
end
|
||||||
mcl_armor.update(player)
|
end
|
||||||
end
|
mcl_armor.update(player)
|
||||||
end)
|
end
|
||||||
|
end)
|
||||||
|
|
Loading…
Reference in New Issue