give formspecs some love

This commit is contained in:
tour 2024-01-03 22:55:44 +01:00
parent 95f114b294
commit ff88a1670e
3 changed files with 25 additions and 10 deletions

View File

@ -1,17 +1,24 @@
chat_formspec.predefined = {
replant_farm = {
fs = "",
replacements = {
}
fs = [[
set_focus[answer]
field[0.3,6.4;10.7,0.8;answer;Your answer;]
button_exit[11.3,6.4;3,0.8;submit;submit]
button[11.3,0.3;3,0.8;chat_help;How to chat?]
label[0.4,0.7;We tried to contact you via chat already\, but you did not respond]
textarea[0.4,1.6;13.8,4.2;;;%s]
button[11.3,4.5;3,0.8;replant_help;how to replant?]
]],
replacement = [[The public farm is meant for all players. Therefore it is needed that everyone replants \
what he takes. Please do so too! Otherwise we will unfortunately have to resort to other means.]]
},
default = {
fs = [[
field[1.1,6.8;10.7,0.8;answer;Your answer;]
button_exit[12.1,6.8;3,0.8;submit;submit]
button[12.1,0.7;3,0.8;chat_help;How to chat?]
label[1.2,1.1;We tried to contact you via chat already\, but you did not respond]
textarea[1.2,2;13.8,4.2;;;%s]
field[0.3,6.4;10.7,0.8;answer;Your answer;]
button_exit[11.3,6.4;3,0.8;submit;submit]
button[11.3,0.3;3,0.8;chat_help;How to chat?]
label[0.4,0.7;We tried to contact you via chat already\, but you did not respond]
textarea[0.4,1.6;13.8,4.2;;;%s]
]],
replacement = [[You have shown behavior about which we have some questions for reasons of moderation.\
It would be nice if you could answer them. Otherwise we will unfortunately have to resort to other means.]]

View File

@ -19,6 +19,7 @@ chat_formspec.selection_fs = create_selection_formspec()
chat_formspec.create_new = [[
formspec_version[6]
size[16,12]
set_focus[c_fs]
textarea[1,0.5;13.7,2.4;;;to create formspecs
https://luk3yx.gitlab.io/minetest-formspec-editor/
@ -31,6 +32,7 @@ If you are not sure wheter it looks correct\, consider sending it to yourself]
button_exit[0.8,10.5;3,0.8;cancel;Cancel]
field[7.8,10.5;3,0.8;target;send to player;]
field_close_on_enter[target;false]
button_exit[11.7,10.5;3,0.8;send;Send]
]]
@ -38,12 +40,16 @@ chat_formspec.predefined_template = [[
formspec_version[6]
size[16,12]
box[0.8,0.4;14.6,7.7;gray]
container[0.8,0.4]
%s
container_end[]
set_focus[target]
button[1,10.8;3,0.8;back;Back]
button[12.4,10.7;3,0.9;send;Send]
textarea[0.8,8.6;14.6,1.8;change_text_field;change default text;%s]
button[4.7,10.8;3,0.8;change_text;change text]
field[8.8,10.9;3,0.8;target;send to player;]
field_close_on_enter[target;false]
]]
function chat_formspec.get_predefined_template(id, replacement)
@ -58,8 +64,9 @@ end
function chat_formspec.create_targest_fs(id, replacement)
if not chat_formspec.predefined[id] then return end -- in case someone hacks their client and sends an invalid id in their fs submission
local fs = [[formspec_version[1]
local fs = [[formspec_version[2]
size[14.6,7.7]
set_focus[answer]
]]
local predefined = chat_formspec.predefined[id].fs
local replacement = replacement or chat_formspec.predefined[id].replacement

View File

@ -6,3 +6,4 @@ create formspecs how to replant / how to chat
add a licence
colorize answers / maybe even play a notification sound to provent the message getting lost in the chat flow
translation
test with a (target) client having formspec_version 1 (older than 10/2019) (I expect every sender to not have a super outdated client)