From f32aa4c37dd77494209ff7501085b69293b84e76 Mon Sep 17 00:00:00 2001 From: AiTechEye <40591179+AiTechEye@users.noreply.github.com> Date: Tue, 24 Jul 2018 16:09:35 +0200 Subject: [PATCH] Add files via upload --- depends.txt | 1 + init.lua | 81 ++++++++++++++++++++++++++++++++++++ readme.txt | 8 ++++ textures/invisible_skin.png | Bin 0 -> 143 bytes 4 files changed, 90 insertions(+) create mode 100644 depends.txt create mode 100644 init.lua create mode 100644 readme.txt create mode 100644 textures/invisible_skin.png diff --git a/depends.txt b/depends.txt new file mode 100644 index 0000000..7be6dbb --- /dev/null +++ b/depends.txt @@ -0,0 +1 @@ +3d_armor? \ No newline at end of file diff --git a/init.lua b/init.lua new file mode 100644 index 0000000..2f354ef --- /dev/null +++ b/init.lua @@ -0,0 +1,81 @@ +minetest.register_alias("i", "invisible:tool") + +invisible={time=0,armor=minetest.get_modpath("3d_armor")} +minetest.register_privilege("invisible", { + description = "Be invisible", + give_to_singleplayer= false, +}) + +invisible.toogle=function(user,sneak) + local name=user:get_player_name() + if minetest.check_player_privs(user:get_player_name(), {invisible=true}) then + if not invisible[name] then + user:set_nametag_attributes({color = {a = 0, r = 255, g = 255, b = 255}}) + invisible[name]={} + invisible[name].tool=sneak + invisible[name].collisionbox=user:get_properties().collisionbox + invisible[name].visual_size=user:get_properties().visual_size + invisible[name].textures=user:get_properties().textures + user:set_properties({ + visual = "mesh", + textures={"invisible_skin.png"}, + visual_size = {x=0, y=0}, + collisionbox = {0,0,0, 0,0,0}, + }) + minetest.chat_send_player(name, "invisible on") + else + user:set_nametag_attributes({color = {a = 255, r = 255, g = 255, b = 255}}) + user:set_properties({ + visual = "mesh", + textures=invisible[name].textures, + visual_size = invisible[name].visual_size, + collisionbox=invisible[name].collisionbox + }) + invisible[name]=nil + + if invisible.armor then + armor:set_player_armor(user) + armor:update_inventory(user) + end + + + minetest.chat_send_player(name, "invisible off") + end + else + + if not invisible[name] then + invisible[name]={} + user:set_nametag_attributes({color = {a = 0, r = 255, g = 255, b = 255}}) + else + user:set_nametag_attributes({color = {a = 255, r = 255, g = 255, b = 255}}) + invisible[name]=nil + end + end +end + +minetest.register_tool("invisible:tool", { + description = "invisible", + inventory_image = "default_stick.png", + groups = {not_in_creative_inventory=1}, + on_use = function(itemstack, user, pointed_thing) + if minetest.check_player_privs(user:get_player_name(), {invisible=true}) then + invisible.toogle(user,true) + else + itemstack:replace(nil) + end + return itemstack + end +}) + +minetest.register_globalstep(function(dtime) + invisible.time=invisible.time+dtime + if invisible.time<0.5 then return end + invisible.time=0 + for _, player in pairs(minetest.get_connected_players()) do + local name=player:get_player_name() + local sneak=player:get_player_control().sneak + if (sneak and not invisible[name]) or (sneak==false and invisible[name] and not invisible[name].tool) then + invisible.toogle(player) + end + end +end) \ No newline at end of file diff --git a/readme.txt b/readme.txt new file mode 100644 index 0000000..6b198ee --- /dev/null +++ b/readme.txt @@ -0,0 +1,8 @@ +Licenses: CC0 +Version: 3 + +Hides players nametag when they are sneaking, or invisible if you have the invisible privilege. + +Give yourself the invisible stick, to toggle your invisible on/off + +/giveme i \ No newline at end of file diff --git a/textures/invisible_skin.png b/textures/invisible_skin.png new file mode 100644 index 0000000000000000000000000000000000000000..e28e0d4f71d45f059ea64b7738c27579d86dad6a GIT binary patch literal 143 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`Y)RhkE)4%caKYZ?lYt_f1s;*b z3=DinK$vl=HlH+5kiEpy*OmPN3#W*-)FIXI>p&qHPZ!4!i_^(}{{OdUR&D5PbTY^~ hu!3L-H(U**CVI9f9f?JYD@<);T3K0RVn;CNTg2 literal 0 HcmV?d00001