Skip to content

Commit 4645818

Browse files
committed
Add HUD
1 parent f952a30 commit 4645818

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Invisibility Command [invis]
44
- Download: https://github.com/octacian/minetest-mod-invis/archive/master.zip
55
- Forum: https://forum.minetest.net/viewtopic.php?f=9&t=17389
66

7-
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).
7+
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.
88

99
__Usage:__
1010
- `/vanish`: Toggle invisibility for yourself

init.lua

+14
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
invis = {}
44
local invisible = {}
5+
local huds = {}
56

67
-- [function] Get visible
78
function invis.get(name)
@@ -32,6 +33,14 @@ function invis.toggle(player, toggle)
3233
color = {a = 0, r = 255, g = 255, b = 255},
3334
})
3435
msg = "now invisible"
36+
37+
-- Add HUD
38+
huds[name] = player:hud_add({
39+
hud_elem_type = "text",
40+
position = {x = 0.5, y = 0.85},
41+
text = "You are invisible to other players",
42+
number = 0x00BC00
43+
})
3544
else
3645
-- Show player and nametag
3746
prop = {
@@ -42,6 +51,11 @@ function invis.toggle(player, toggle)
4251
color = {a = 255, r = 255, g = 255, b = 255},
4352
})
4453
msg = "no longer invisible"
54+
55+
-- Remove HUD
56+
if huds[name] then
57+
player:hud_remove(huds[name])
58+
end
4559
end
4660

4761
-- Update properties

0 commit comments

Comments
 (0)