Damage player's equipment on death.
This commit is contained in:
parent
f02a5c4d50
commit
d234d95a7a
@ -1023,3 +1023,36 @@ end)
|
|||||||
minetest.register_on_punchplayer(function(player, hitter, time_from_last_punch, tool_capabilities, dir, damage)
|
minetest.register_on_punchplayer(function(player, hitter, time_from_last_punch, tool_capabilities, dir, damage)
|
||||||
mod.damage_armor(player, damage)
|
mod.damage_armor(player, damage)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
|
||||||
|
if not minetest.get_modpath('bones') then
|
||||||
|
print(mod_name..': Player gear will suffer when the player dies.')
|
||||||
|
|
||||||
|
minetest.register_on_dieplayer(function(player, reason)
|
||||||
|
if not player then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
local pinv = player:get_inventory()
|
||||||
|
if not pinv then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
local wear = 20000
|
||||||
|
local main_size = pinv:get_size('main')
|
||||||
|
for i = 1, main_size do
|
||||||
|
local st = pinv:get_stack('main', i)
|
||||||
|
local name = st:get_name()
|
||||||
|
|
||||||
|
if minetest.registered_tools[name] then
|
||||||
|
local ow = st:get_wear()
|
||||||
|
st:add_wear(wear)
|
||||||
|
pinv:set_stack('main', i, st)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
mod.damage_armor(player, 199)
|
||||||
|
mod.set_armor(player)
|
||||||
|
mod.set_armor_textures(player)
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user