add invisible mod with russian

This commit is contained in:
Aleksandr Avdeev 2024-05-14 23:07:45 +03:00
parent 42fa264c3d
commit e89d576e36
6 changed files with 99 additions and 0 deletions

9
invisible/README.md Normal file
View File

@ -0,0 +1,9 @@
Licenses: code: LGPL-2.1, media: CC BY-SA-4.0
Version: 4
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

81
invisible/init.lua Normal file
View File

@ -0,0 +1,81 @@
local S = minetest.get_translator("invisible")
minetest.register_alias("i", "invisible:tool")
invisible = { time = 0, armor = minetest.get_modpath("3d_armor")}
minetest.register_privilege("invisible", {
description = S("Allows the player to become invisible."),
give_to_singleplayer = false,
})
invisible.toggle=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].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},
pointable=false,
})
minetest.chat_send_player(name, S("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,
pointable=true,
})
invisible[name]=nil
if invisible.armor then
armor:set_player_armor(user)
armor:update_inventory(user)
end
minetest.chat_send_player(name, S("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 = S("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.toggle(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.toggle(player)
end
end
end)

View File

@ -0,0 +1,6 @@
# textdomain: invisible
Allows the player to become invisible.=Позволяет игроку стать невидимкой.
invisible on=режим невидимки включен
invisible off=режим невидимки выключен
invisible=невидимка

3
invisible/mod.conf Normal file
View File

@ -0,0 +1,3 @@
name=invisible
description=Hide nametag while sneaking, or invisible with the invisible privilege
optional_depends=3d_armor

BIN
invisible/screenshot.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 39 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 143 B