57 lines
1.8 KiB
Lua
57 lines
1.8 KiB
Lua
local function create_selection_formspec()
|
|
local fs = [[
|
|
formspec_version[6]
|
|
size[16,12]
|
|
dropdown[2.6,2.8;5.9;select;%s;0;true]
|
|
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]
|
|
|
|
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[0.8,10.5;3,0.8;back;Back]
|
|
field[7.8,10.5;3,0.8;target;send to player;]
|
|
button[11.7,10.5;3,0.8;send;Send]
|
|
]]
|
|
|
|
chat_formspec.predefined_template = [[
|
|
formspec_version[6]
|
|
size[16,12]
|
|
box[0.8,0.4;14.6,7.7;gray]
|
|
%s
|
|
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;change default text;default text]
|
|
button[4.7,10.8;3,0.8;change_text;change text]
|
|
field[8.8,10.9;3,0.8;target;send to player;]
|
|
]]
|
|
|
|
function chat_formspec.get_predefined_template(id, replacement)
|
|
local predefined = chat_formspec.predefined[id].fs
|
|
local replacement = replacement or chat_formspec.predefined[id].replacement
|
|
|
|
predefined = string.format(predefined, replacement)
|
|
local fs = string.format(chat_formspec.predefined_template, predefined)
|
|
return fs
|
|
end
|