From f3ad7ec6f11ac0a1d9ae769da139374c48551b36 Mon Sep 17 00:00:00 2001 From: OgelGames Date: Sat, 28 Dec 2019 23:13:41 +1100 Subject: [PATCH] add armor breakage alerts something I've wanted for a while... --- 3d_armor/init.lua | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/3d_armor/init.lua b/3d_armor/init.lua index 863216e..3e9d2f9 100644 --- a/3d_armor/init.lua +++ b/3d_armor/init.lua @@ -99,11 +99,20 @@ armor.formspec = armor.formspec.. if armor.config.fire_protect then armor.formspec = armor.formspec.."label[5,2;"..F(S("Fire"))..": armor_attr_fire]" 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) local name = player:get_player_name() local def = stack:get_definition() if name and def and def.description then 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)