add invisibility.invisible global api function.
This commit is contained in:
parent
e52fd6483f
commit
5a784901f0
9
api.txt
Normal file
9
api.txt
Normal 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])
|
15
init.lua
15
init.lua
@ -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
|
||||
})
|
||||
|
Loading…
x
Reference in New Issue
Block a user