Add 'invisibility' mod.

This commit is contained in:
AntumDeluge 2016-09-06 09:27:41 -07:00
parent f100ef5d13
commit bc9994dfa5
9 changed files with 241 additions and 0 deletions

View File

@ -78,6 +78,7 @@ The game includes the mods from the default [minetest_game](https://github.com/m
* player_visuals/
* 3d_armor ([3d_armor modpack][3d_armor]) ([LGPL / WTFPL / CC-BY-SA][lic.3d_armor]) -- version: [0.4.4-41-456c84e Git][ver.3d_armor]
* [character_creator][] ([WTFPL / CC-BY-SA][lic.character_creator]) -- version: [5e8fec2 Git][ver.character_creator]
* [invisibility][] ([MIT][lic.invisibility]) -- version: [bf4156b Git][ver.invisibility]
* [playeranim][] ([WFTLPL][lic.playeranim.1]) / [BSD][lic.playeranim.2]) - version [f1c542e Git][ver.playeranim]
* [wardrobe][] ([WTFPL][lic.wardrobe]) -- version: [1.1-2-c48b011 Git][ver.wardrobe]
* wieldview ([3d_armor modpack][3d_armor]) ([LGPL / WTFPL / CC-BY-SA][lic.3d_armor]) -- version: [0.4.4-41-456c84e Git][ver.3d_armor]
@ -221,6 +222,7 @@ The game includes the mods from the default [minetest_game](https://github.com/m
[hudmap]: https://github.com/stujones11/hudmap
[ilights]: https://forum.minetest.net/viewtopic.php?t=12200
[intllib]: https://forum.minetest.net/viewtopic.php?t=4929
[invisibility]: https://forum.minetest.net/viewtopic.php?t=14846
[invisible]: https://forum.minetest.net/viewtopic.php?t=14399
[inventory_plus]: https://forum.minetest.net/viewtopic.php?t=3100
[jukebox]: https://forum.minetest.net/viewtopic.php?t=13505
@ -307,6 +309,7 @@ The game includes the mods from the default [minetest_game](https://github.com/m
[lic.creeper]: mods/mobs_aggressive/creeper/LICENSE.md
[lic.homedecor]: mods/homedecor_modpack/LICENSE
[lic.ilights]: mods/lighting/ilights/init.lua
[lic.invisibility]: mods/player_visuals/invisibility/license.txt
[lic.jukebox]: mods/furniture/jukebox/README.txt
[lic.mdoors.1]: mods/mydoors/mdoors/README.txt
[lic.mdoors.2]: doc/modpacks/mydoors/licence.txt
@ -328,6 +331,7 @@ The game includes the mods from the default [minetest_game](https://github.com/m
[ver.creeper]: https://github.com/Rui-Minetest/creeper/tree/036666e
[ver.homedecor]: https://github.com/minetest-mods/homedecor_modpack/tree/02a4d14
[ver.ilights]: https://github.com/minetest-mods/ilights/tree/d5f6900
[ver.invisibility]: https://github.com/tenplus1/invisibility/tree/bf4156b
[ver.jukebox]: https://github.com/minetest-mods/jukebox/tree/e6a507f
[ver.mobs_monster]: https://github.com/tenplus1/mobs_monster/tree/91cbcf7
[ver.playeranim]: https://github.com/minetest-mods/playeranim/tree/f1c542e

View File

@ -0,0 +1,16 @@
Invisibility Potion by TenPlus1
This mod lets you craft an invisibility potion using 1x Nyan Cat Rainbow and 1x Glass Bottle.
Use potion to hide yourself AND nametag (0.4.14 dev only) for 5 minutes.
Server admin can use the '/vanish <name>' command to hide/unhide players or themselves by leaving it blank.
Forum Page: https://forum.minetest.net/viewtopic.php?f=9&t=14846
Changelog:
- 0.1 - Initial Upload
- 0.2 - Added error checking and a 10 second warning before becoming visible
- 0.3 - Potions can now be stacked

View File

@ -0,0 +1,2 @@
default
vessels

View File

@ -0,0 +1,196 @@
invisibility = {}
local effect_time = 300 -- 5 minutes
-- reset player invisibility if they go offline
minetest.register_on_leaveplayer(function(player)
local name = player:get_player_name()
if invisibility[name] then
invisibility[name] = nil
end
end)
-- invisibility potion
minetest.register_node("invisibility:potion", {
description = "Invisibility Potion",
drawtype = "plantlike",
tiles = {"invisibility_potion.png"},
inventory_image = "invisibility_potion.png",
wield_image = "invisibility_potion.png",
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}
},
groups = {vessel = 1, dig_immediate = 3, attached_node = 1},
sounds = default.node_sound_glass_defaults(),
on_use = function(itemstack, user)
local pos = user:getpos()
local name = user:get_player_name()
-- are we already invisible?
if invisibility[name] then
minetest.chat_send_player(name,
">>> You are already invisible!")
return itemstack
end
-- make player invisible
invisible(user, true)
-- play sound
minetest.sound_play("pop", {
pos = pos,
gain = 1.0,
max_hear_distance = 5
})
-- display 10 second warning
minetest.after(effect_time - 10, function()
if invisibility[name]
and user:getpos() then
minetest.chat_send_player(name,
">>> You have 10 seconds before invisibility wears off!")
end
end)
-- make player visible 5 minutes later
minetest.after(effect_time, function()
if invisibility[name]
and user:getpos() then
-- show aready hidden player
invisible(user, nil)
-- play sound
minetest.sound_play("pop", {
pos = pos,
gain = 1.0,
max_hear_distance = 5
})
end
end)
-- take potion, return empty bottle (and rest of potion stack)
if not minetest.setting_getbool("creative_mode") then
local item_count = user:get_wielded_item():get_count()
local inv = user:get_inventory()
local giving_back = "vessels:glass_bottle"
if inv and item_count > 1 then
if inv:room_for_item("main", {name = "vessels:glass_bottle"}) then
inv:add_item("main", {name = "vessels:glass_bottle"})
else
pos.y = pos.y + 1
minetest.add_item(pos, {name = "vessels:glass_bottle"})
end
giving_back = "invisibility:potion " .. tostring(item_count - 1)
end
return ItemStack(giving_back)
end
end,
})
-- craft recipe
minetest.register_craft( {
output = "invisibility:potion",
type = "shapeless",
recipe = {"default:nyancat_rainbow", "vessels:glass_bottle"},
})
-- invisibility function
invisible = function(player, toggle)
if not player then return false end
local name = player:get_player_name()
invisibility[name] = toggle
local prop
if toggle == true then
-- hide player and name tag
prop = {
visual_size = {x = 0, y = 0},
collisionbox = {0, 0, 0, 0, 0, 0}
}
player:set_nametag_attributes({
color = {a = 0, r = 255, g = 255, b = 255}
})
else
-- show player and tag
prop = {
visual_size = {x = 1, y = 1},
collisionbox = {-0.35, -1, -0.35, 0.35, 1, 0.35}
}
player:set_nametag_attributes({
color = {a = 255, r = 255, g = 255, b = 255}
})
end
player:set_properties(prop)
end
-- vanish command (admin only)
minetest.register_chatcommand("vanish", {
params = "<name>",
description = "Make player invisible",
privs = {server = true},
func = function(name, param)
-- player online
if param ~= ""
and minetest.get_player_by_name(param) then
name = param
-- player not online
elseif param ~= "" then
return false, "Player " .. param .. " is not online!"
end
local player = minetest.get_player_by_name(name)
-- hide / show player
if invisibility[name] then
invisible(player, nil)
else
invisible(player, true)
end
end
})

View File

@ -0,0 +1,21 @@
The MIT License (MIT)
Copyright (c) 2016 TenPlus1
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

Binary file not shown.

After

Width:  |  Height:  |  Size: 25 KiB

View File

@ -0,0 +1,2 @@
Pop sound from www.freesfx.co.uk

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 167 B