commit cb63ef3a8aab3714d81d286c6eeafa9d90fa9d66 Author: TenPlus1 Date: Tue Jun 7 16:38:50 2016 +0100 Initial upload diff --git a/README.md b/README.md new file mode 100644 index 0000000..6bf04fe --- /dev/null +++ b/README.md @@ -0,0 +1,13 @@ + +Invisibility Potion by TenPlus1 + +This mod lets you craft an invisibility potion using 1x Nyan Cat 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 ' command to hide/unhide players or themselves by leaving it blank. + + +Changelog: + + - 0.1 - Initial Upload diff --git a/depends.txt b/depends.txt new file mode 100644 index 0000000..d6b786c --- /dev/null +++ b/depends.txt @@ -0,0 +1,2 @@ +default +vessels diff --git a/init.lua b/init.lua new file mode 100644 index 0000000..7f93b1b --- /dev/null +++ b/init.lua @@ -0,0 +1,129 @@ + +invisibility = {} + +-- 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", + stack_max = 1, + 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() + + -- hide player + invisible(user) + + minetest.sound_play("pop", { + pos = pos, + gain = 1.0, + max_hear_distance = 5 + }) + + -- show again 5 minutes later + minetest.after(300, function() + + invisible(user) + + minetest.sound_play("pop", { + pps = pos, + gain = 1.0, + max_hear_distance = 5 + }) + end) + + -- take item + if not minetest.setting_getbool("creative_mode") then + + itemstack:take_item() + + return {name="vessels:glass_bottle"} -- itemstack + end + + end, +}) + +minetest.register_craft( { + output = "invisibility:potion", + type = "shapeless", + recipe = {"default:nyancat", "vessels:glass_bottle"}, +}) + +-- invisibility function + +invisible = function(player) + + if not player then return false end + + local name = player:get_player_name() + + invisibility[name] = not invisibility[name] + + local prop + + if invisibility[name] 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 = "", + 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 + + -- hide player entered (default to player using command if blank) + invisible( minetest.get_player_by_name(name) ) + + end +}) diff --git a/license.txt b/license.txt new file mode 100644 index 0000000..5d30c14 --- /dev/null +++ b/license.txt @@ -0,0 +1,14 @@ + + DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE + Version 2, December 2004 + + Copyright (C) 2004 Sam Hocevar + + Everyone is permitted to copy and distribute verbatim or modified + copies of this license document, and changing it is allowed as long + as the name is changed. + + DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. You just DO WHAT THE FUCK YOU WANT TO. \ No newline at end of file diff --git a/screenshot.png b/screenshot.png new file mode 100644 index 0000000..419eb4c Binary files /dev/null and b/screenshot.png differ diff --git a/sounds/license.txt b/sounds/license.txt new file mode 100644 index 0000000..3cf2882 --- /dev/null +++ b/sounds/license.txt @@ -0,0 +1,2 @@ + +Pop sound from www.freesfx.co.uk diff --git a/sounds/pop.ogg b/sounds/pop.ogg new file mode 100644 index 0000000..7bbad92 Binary files /dev/null and b/sounds/pop.ogg differ diff --git a/textures/invisibility_potion.png b/textures/invisibility_potion.png new file mode 100644 index 0000000..09c137e Binary files /dev/null and b/textures/invisibility_potion.png differ