117 lines
4.1 KiB
Lua
117 lines
4.1 KiB
Lua
local function create_selection_formspec()
|
|
local fs = [[
|
|
formspec_version[6]
|
|
size[16,12]
|
|
dropdown[2.6,2.8;5.9;select;%s;1;false]
|
|
button[9.5,2.8;3,0.8;template;use this template]
|
|
]]
|
|
|
|
local dropdown_items = ""
|
|
for name, _ in pairs(chat_formspec.predefined) do
|
|
dropdown_items = dropdown_items .. name .. ","
|
|
end
|
|
fs = string.format(fs, string.sub(dropdown_items, 1, -2))
|
|
return fs
|
|
end
|
|
|
|
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/
|
|
might be very useful.
|
|
Please make sure the field the player should answer with has the name "answer"]
|
|
|
|
textarea[0.8,3.4;14,5.4;c_fs;your custom formspec;]
|
|
textarea[0.8,8.9;13.7,1.1;;;There is no validation check done for this formspec.
|
|
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_close_on_enter[target;false]
|
|
field[7.8,10.5;3,0.8;target;send to player;%s]
|
|
button[11.7,10.5;3,0.8;send;Send]
|
|
]]
|
|
|
|
function chat_formspec.get_create_new(context)
|
|
local target = context.target or ""
|
|
return string.format(chat_formspec.create_new, target)
|
|
end
|
|
|
|
|
|
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;%s]
|
|
field_close_on_enter[target;false]
|
|
]]
|
|
|
|
function chat_formspec.get_predefined_template(context)
|
|
if not chat_formspec.predefined[context.id] then return end -- in case someone hacks their client and sends an invalid id in their fs submission
|
|
local predefined = chat_formspec.predefined[context.id].fs
|
|
local replacement = context.replacement or chat_formspec.predefined[context.id].replacement
|
|
local target = context.target or ""
|
|
|
|
predefined = string.format(predefined, replacement)
|
|
local fs = string.format(chat_formspec.predefined_template, predefined, replacement, target)
|
|
return fs
|
|
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[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
|
|
|
|
predefined = string.format(predefined, replacement)
|
|
fs = fs .. predefined
|
|
return fs
|
|
end
|
|
|
|
chat_formspec.misc_fs = {}
|
|
chat_formspec.misc_fs.chat_help = [[
|
|
formspec_version[2]
|
|
size[14,10]
|
|
label[5.5,0.8;How to chat?]
|
|
label[5.5,0.8;___________]
|
|
label[0.3,1.5;On a computer:]
|
|
label[0.3,1.6;____________]
|
|
textarea[3,1.5;10.4,2.4;;;1) Press your 'T' or 'F10' key
|
|
2) Write the text you want to send to the public chat
|
|
in case you do not want everyone to see you text, add a '/m playername' in front of you text.
|
|
only the player with the name you specified will see your text then
|
|
3) send your Text by pressing 'Enter']
|
|
label[0.3,4.3;On mobile / tablet:]
|
|
label[0.3,4.4;______________]
|
|
textarea[3.4,4.3;9.7,2.6;;;TODO: WRITE TEXT]
|
|
button[5.6,8.6;3,0.8;ok;OK]
|
|
]]
|
|
|
|
chat_formspec.misc_fs.replant_help = [[
|
|
formspec_version[2]
|
|
size[14,10]
|
|
label[5.5,0.8;How to replant?]
|
|
label[5.5,0.85;____________]
|
|
label[0.3,1.5;On a computer:]
|
|
label[0.3,1.6;____________]
|
|
textarea[3,1.5;10.4,2.4;;;TODO: Write Text]
|
|
label[0.3,4.3;On mobile / tablet:]
|
|
label[0.3,4.4;______________]
|
|
textarea[3.4,4.3;9.7,2.6;;;TODO: WRITE TEXT]
|
|
button[5.6,8.6;3,0.8;ok;OK]
|
|
]] |