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
|
-- invisibility function
|
||||||
|
|
||||||
local function invisible(player, toggle)
|
function invisibility.invisible(player, toggle)
|
||||||
|
|
||||||
if not player then return false end
|
if not player then return false end
|
||||||
|
|
||||||
@ -63,10 +63,7 @@ minetest.register_node("invisibility:potion", {
|
|||||||
paramtype = "light",
|
paramtype = "light",
|
||||||
is_ground_content = false,
|
is_ground_content = false,
|
||||||
walkable = false,
|
walkable = false,
|
||||||
selection_box = {
|
selection_box = {type = "fixed", fixed = {-0.25, -0.5, -0.25, 0.25, 0.3, 0.25}},
|
||||||
type = "fixed",
|
|
||||||
fixed = {-0.25, -0.5, -0.25, 0.25, 0.3, 0.25}
|
|
||||||
},
|
|
||||||
groups = {vessel = 1, dig_immediate = 3, attached_node = 1},
|
groups = {vessel = 1, dig_immediate = 3, attached_node = 1},
|
||||||
sounds = default.node_sound_glass_defaults(),
|
sounds = default.node_sound_glass_defaults(),
|
||||||
|
|
||||||
@ -84,7 +81,7 @@ minetest.register_node("invisibility:potion", {
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- make player invisible
|
-- make player invisible
|
||||||
invisible(user, true)
|
invisibility.invisible(user, true)
|
||||||
|
|
||||||
-- play sound
|
-- play sound
|
||||||
minetest.sound_play("pop", {
|
minetest.sound_play("pop", {
|
||||||
@ -106,7 +103,7 @@ minetest.register_node("invisibility:potion", {
|
|||||||
if invisibility[name] and user:get_pos() then
|
if invisibility[name] and user:get_pos() then
|
||||||
|
|
||||||
-- show hidden player
|
-- show hidden player
|
||||||
invisible(user, nil)
|
invisibility.invisible(user, nil)
|
||||||
|
|
||||||
-- play sound
|
-- play sound
|
||||||
minetest.sound_play("pop", {
|
minetest.sound_play("pop", {
|
||||||
@ -179,9 +176,9 @@ minetest.register_chatcommand("vanish", {
|
|||||||
-- hide / show player
|
-- hide / show player
|
||||||
if invisibility[name] then
|
if invisibility[name] then
|
||||||
|
|
||||||
invisible(player, nil)
|
invisibility.invisible(player, nil)
|
||||||
else
|
else
|
||||||
invisible(player, true)
|
invisibility.invisible(player, true)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
})
|
})
|
||||||
|
1
mod.conf
1
mod.conf
@ -1,4 +1,5 @@
|
|||||||
name = invisibility
|
name = invisibility
|
||||||
description = Craft a potion to make yourself invisible.
|
description = Craft a potion to make yourself invisible.
|
||||||
depends = default
|
depends = default
|
||||||
|
optional_depends = flowers, vessels
|
||||||
min_minetest_version = 5.0
|
min_minetest_version = 5.0
|
||||||
|
Loading…
x
Reference in New Issue
Block a user