diff --git a/README.md b/README.md index bbeed99..a267d20 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ Invisibility Command [invis] - Download: https://github.com/octacian/minetest-mod-invis/archive/master.zip - Forum: https://forum.minetest.net/viewtopic.php?f=9&t=17389 -This extremely simple mod introduces a single command that allows you to make yourself or another player invisible (both the player itself and the nametag). +This extremely simple mod introduces a single command that allows you to make yourself or another player invisible (both the player itself and the nametag). While you are in vanish mod, a simple text HUD will be shown above the hotbar with a notice that you are currently invisible to other players. __Usage:__ - `/vanish`: Toggle invisibility for yourself diff --git a/init.lua b/init.lua index bd1fad1..6932714 100644 --- a/init.lua +++ b/init.lua @@ -2,6 +2,7 @@ invis = {} local invisible = {} +local huds = {} -- [function] Get visible function invis.get(name) @@ -32,6 +33,14 @@ function invis.toggle(player, toggle) color = {a = 0, r = 255, g = 255, b = 255}, }) msg = "now invisible" + + -- Add HUD + huds[name] = player:hud_add({ + hud_elem_type = "text", + position = {x = 0.5, y = 0.85}, + text = "You are invisible to other players", + number = 0x00BC00 + }) else -- Show player and nametag prop = { @@ -42,6 +51,11 @@ function invis.toggle(player, toggle) color = {a = 255, r = 255, g = 255, b = 255}, }) msg = "no longer invisible" + + -- Remove HUD + if huds[name] then + player:hud_remove(huds[name]) + end end -- Update properties