Added a button for the unified inventory. Updated the password entry form interface.

This commit is contained in:
Vitaliy Olkhin 2025-01-13 14:29:39 +05:00
parent c0866ad612
commit d49f208669
4 changed files with 29 additions and 6 deletions

View File

@ -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") .. "]",
--"<action name=apocalypse.texnoblog.uz url=https://apocalypse.texnoblog.uz>...</action>",
"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
@ -63,3 +70,15 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
--minetest.chat_send_all(sha256(fields.pass))
end
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

View File

@ -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=Перейти на страницу авторизации

View File

@ -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

Binary file not shown.

After

Width:  |  Height:  |  Size: 997 B