1
0
mirror of https://github.com/minetest-mods/3d_armor.git synced 2024-12-26 18:50:40 +01:00

add armor breakage alerts

something I've wanted for a while...
This commit is contained in:
OgelGames 2019-12-28 23:13:41 +11:00
parent fccd4d8b15
commit f3ad7ec6f1

View File

@ -99,11 +99,20 @@ armor.formspec = armor.formspec..
if armor.config.fire_protect then if armor.config.fire_protect then
armor.formspec = armor.formspec.."label[5,2;"..F(S("Fire"))..": armor_attr_fire]" armor.formspec = armor.formspec.."label[5,2;"..F(S("Fire"))..": armor_attr_fire]"
end end
armor:register_on_damage(function(player, index, stack)
local name = player:get_player_name()
local def = stack:get_definition()
if name and def and def.description and stack:get_wear() > 60100 then
minetest.chat_send_player(name, S("Your @1 is almost broken!", def.description))
minetest.sound_play("default_tool_breaks", {to_player = name, gain = 2.0})
end
end)
armor:register_on_destroy(function(player, index, stack) armor:register_on_destroy(function(player, index, stack)
local name = player:get_player_name() local name = player:get_player_name()
local def = stack:get_definition() local def = stack:get_definition()
if name and def and def.description then if name and def and def.description then
minetest.chat_send_player(name, S("Your @1 got destroyed!", def.description)) minetest.chat_send_player(name, S("Your @1 got destroyed!", def.description))
minetest.sound_play("default_tool_breaks", {to_player = name, gain = 2.0})
end end
end) end)