From d49f2086695e8de382744c59957ea45f7f7b7c90 Mon Sep 17 00:00:00 2001 From: Vitaliy Olkhin Date: Mon, 13 Jan 2025 14:29:39 +0500 Subject: [PATCH] Added a button for the unified inventory. Updated the password entry form interface. --- init.lua | 31 +++++++++++++++++++++++------ locale/site_connect.ru.tr | 3 +++ mod.conf | 1 + textures/site_connect_password.png | Bin 0 -> 997 bytes 4 files changed, 29 insertions(+), 6 deletions(-) create mode 100644 textures/site_connect_password.png diff --git a/init.lua b/init.lua index 605e687..f0ba9d2 100644 --- a/init.lua +++ b/init.lua @@ -17,16 +17,18 @@ label[0.5,3.4;Сообщение] local function get_formspec_main(name) local formspec = { "size[8,5]", - "label[0.2,0.4;".. S("Attention! The site is under development.") .."]", - "label[0.2,1;" .. S("Enter your password to log in to the site") .. "]", + --"label[0.2,0.4;".. S("Attention! The site is under development.") .."]", + "label[0.2,0.4;" .. S("Enter your password to log in to the site") .. "]", + --"...", "field[0.5,2.2;5,0.8;pass;".. S("Password") ..";]", - "button[4.3,3.4;3,0.8;save;".. S("Save") .."]", + "button[4.3,3.0;3,0.8;save;".. S("Save") .."]", + "button_url[0.2,4.5;4,0;url;"..S("Go to the authorization page")..";https://apocalypse.texnoblog.uz/authorization]", } if pass[name] == 'empty' then - table.insert(formspec, 'label[0.2,3.4;'.. S("The password field must not be empty.") ..']') + table.insert(formspec, 'label[0.2,3.0;'.. S("The password field must not be empty.") ..']') end if pass[name] == 'success' then - table.insert(formspec, 'label[0.2,3.4;'.. S("Password saved") ..']') + table.insert(formspec, 'label[0.2,3.0;'.. S("Password saved") ..']') end return table.concat(formspec, "") @@ -43,6 +45,11 @@ minetest.register_chatcommand("set_site_pass", { minetest.register_on_player_receive_fields(function(player, formname, fields) local name = player:get_player_name() + if fields.set_site_pass_ui then + minetest.show_formspec(name, "site_connect:set_password", get_formspec_main(name)) + return true + end + if formname ~= "site_connect:set_password" then return end @@ -62,4 +69,16 @@ minetest.register_on_player_receive_fields(function(player, formname, fields) minetest.show_formspec(name, "site_connect:set_password", get_formspec_main(name)) --minetest.chat_send_all(sha256(fields.pass)) end -end) \ No newline at end of file +end) + +if minetest.global_exists("unified_inventory") then + unified_inventory.register_button("set_site_pass_ui", { + type = "image", + image = "site_connect_password.png", + tooltip = S("Set a password for the site"), + hide_lite = true, + condition = function(player) + return minetest.check_player_privs(player:get_player_name(), {interact=true}) + end, + }) +end \ No newline at end of file diff --git a/locale/site_connect.ru.tr b/locale/site_connect.ru.tr index ebf8447..6baed64 100644 --- a/locale/site_connect.ru.tr +++ b/locale/site_connect.ru.tr @@ -1,4 +1,5 @@ # textdomain: site_connect + Attention! The site is under development.=Внимание! Сайт в процессе разработки. Enter your password to log in to the site=Введите пароль для авторизации на сайте Password=Пароль @@ -6,3 +7,5 @@ Save=Сохранить The password field must not be empty.=Поле пароля не должно быть пустым Password saved=Пароль сохранен Setting up an authorization password for the site=Установка авторизационного пароля на сайт +Set a password for the site=Установить пароль для сайта +Go to the authorization page=Перейти на страницу авторизации \ No newline at end of file diff --git a/mod.conf b/mod.conf index 04a6033..3e653f5 100644 --- a/mod.conf +++ b/mod.conf @@ -3,3 +3,4 @@ description = Allows you to interact with the site via sql min_minetest_version = 5.7 title = Site Connect author = VinAdmin +optional_depends = unified_inventory diff --git a/textures/site_connect_password.png b/textures/site_connect_password.png new file mode 100644 index 0000000000000000000000000000000000000000..4a759c6fd145f25e519f4401f1924a2684507925 GIT binary patch literal 997 zcmV z%TE(Q9LHx%TV5)}M1uvQBnXxYeeCu{w}k>N8ZMkjOf;By^%1~>G0}^9;AVmctUOvI zfDsW*JgI+ydJ(*EP>Bx^X?RHjg4FNSSzSs=TWE}lO!CR@&dl%k`|dn`GlcAvf2q{e zRHkfFuXMYesb;f~V>0n4c%FX%zJL`l35LK)K@f8A-Ai+f-7rltCjdOJ)FOa2)GKqv!}fN1t?|q+Y9dTxK$R5kOqhS zvOsgd2T@*3i4O18^c&2}g!Pw~+cIIl_25)}ef@C`Ln^@GTju;5xM;UqceB3>J4c^% zS`QXkzjqL5+44eU&K2|<&Kf|FIev-1E|CY93fhX;@P}CchA6%jas9cxBOEn?S?2h; z#bVCK&~6x3v}tHN>qq-HMh2(8V+l}2s$>FYz#4c84n*2{y;U59<)Q5v>o+48AO)vC z7)!vq;0A+%V~Z>R?tv>{zu9b7OIWRzR8h2NSgmF{0$0HR=%#kmzOK&8#T7itkRAeU zEXh0ukHAB4KY~G)mJT>jZ3e*loxI4u?I38iED(Y-Z4G z*CP9FlD)S?w9D*G3XdnwJV28S+kVu+8{TkKOL`Y}<=-6HlY46{i+d7Mkb#vf(zlWw zHX2yY<~pbLTAO@oP5Xx|GO(IShC&&#owa4DcP6Tcf5wNvE>M6Vtq^c7)Aw1U?3ld3b$)GCbO#I2<_73DFB+Y7 zk^p~YrI=VAkO>$S^u;=^XD*NQENDP3>0e4CJ@bXB-N9nlnQN-_+aHS%w21UAtI1uo zQ+gM3`Le@w3Pyh|W@BP`z~Qh-d0+yZ#e9mtF&RZ(e?$}v+6vr~Dh0h3-^Gq_{hxkL zUf|C&`^549U4+O3YL*A+R+