diff --git a/api.txt b/api.txt new file mode 100644 index 0000000..8e5c175 --- /dev/null +++ b/api.txt @@ -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]) diff --git a/init.lua b/init.lua index 855fb31..57776e8 100644 --- a/init.lua +++ b/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 }) diff --git a/mod.conf b/mod.conf index 4e44c2b..37fb043 100644 --- a/mod.conf +++ b/mod.conf @@ -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