add invisibility.invisible global api function.

This commit is contained in:
tenplus1 2024-11-09 07:53:41 +00:00
parent e52fd6483f
commit 5a784901f0
3 changed files with 16 additions and 9 deletions

9
api.txt Normal file
View File

@ -0,0 +1,9 @@
Toggling Invisibility
---------------------
Any 3rd party mods can use the invisibility.invisible function to hide a player, but only
the potion itself adds a timer to the function with a 10 second warning before becoming
visible once again e.g.
invisibility.invisible(player, [true for invisible, false for visible])

View File

@ -24,7 +24,7 @@ end
-- invisibility function
local function invisible(player, toggle)
function invisibility.invisible(player, toggle)
if not player then return false end
@ -63,10 +63,7 @@ minetest.register_node("invisibility:potion", {
paramtype = "light",
is_ground_content = false,
walkable = false,
selection_box = {
type = "fixed",
fixed = {-0.25, -0.5, -0.25, 0.25, 0.3, 0.25}
},
selection_box = {type = "fixed", fixed = {-0.25, -0.5, -0.25, 0.25, 0.3, 0.25}},
groups = {vessel = 1, dig_immediate = 3, attached_node = 1},
sounds = default.node_sound_glass_defaults(),
@ -84,7 +81,7 @@ minetest.register_node("invisibility:potion", {
end
-- make player invisible
invisible(user, true)
invisibility.invisible(user, true)
-- play sound
minetest.sound_play("pop", {
@ -106,7 +103,7 @@ minetest.register_node("invisibility:potion", {
if invisibility[name] and user:get_pos() then
-- show hidden player
invisible(user, nil)
invisibility.invisible(user, nil)
-- play sound
minetest.sound_play("pop", {
@ -179,9 +176,9 @@ minetest.register_chatcommand("vanish", {
-- hide / show player
if invisibility[name] then
invisible(player, nil)
invisibility.invisible(player, nil)
else
invisible(player, true)
invisibility.invisible(player, true)
end
end
})

View File

@ -1,4 +1,5 @@
name = invisibility
description = Craft a potion to make yourself invisible.
depends = default
optional_depends = flowers, vessels
min_minetest_version = 5.0