118 lines
3.8 KiB
Lua
118 lines
3.8 KiB
Lua
function chat_formspec.easy_syntax_to_formspec(context)
|
|
local fs_def = string.split(context.easy_syntax, "#", false, -1, false)
|
|
|
|
local target_template = [[button[11.3,0.3;3,0.8;chat_help;How to chat?]
|
|
label[0.4,0.7;I (%s) tried to contact you via chat already\, but you did not respond]
|
|
textarea[0.4,1.6;13.8,4.2;;;%s]
|
|
]]
|
|
local fs = string.format(target_template, context.sender, fs_def[1])
|
|
|
|
if #fs_def == 1 then -- there were no answer-options provided, so we will create a input field
|
|
fs = fs .. [[
|
|
field[0.3,6.4;10.7,0.8;answer;Your answer;]
|
|
button_exit[11.3,6.4;3,0.8;submit;submit]
|
|
]]
|
|
elseif #fs_def == 2 then
|
|
fs = fs .. string.format("button_exit[5.5,6.4;3,0.8;answer;%s]", fs_def[2])
|
|
else
|
|
for i = 2, #fs_def do
|
|
fs = fs .. string.format("button_exit[%f,6.4;3,0.8;answer;%s]",
|
|
0.3 + (i-2) * 11 / (#fs_def - 2), fs_def[i])
|
|
end
|
|
end
|
|
return fs
|
|
end
|
|
|
|
|
|
function chat_formspec.create_sender_template()
|
|
local dropdown_items = ""
|
|
for name, _ in pairs(chat_formspec.preset) do
|
|
dropdown_items = dropdown_items .. name .. ","
|
|
end
|
|
dropdown_items = string.sub(dropdown_items, 0, -2)
|
|
local 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]
|
|
dropdown[1,10.8;3;select;]] .. dropdown_items .. [[;1;false]
|
|
button[12.4,10.7;3,0.9;send;Send]
|
|
textarea[0.8,8.6;14.6,1.8;easy_syntax;change formspec;%s]
|
|
button[4.7,10.8;3,0.8;update;update]
|
|
field[8.8,10.9;3,0.8;target;send to player;%s]
|
|
field_close_on_enter[target;false]
|
|
]]
|
|
return template
|
|
end
|
|
|
|
chat_formspec.sender_template = chat_formspec.create_sender_template()
|
|
|
|
function chat_formspec.create_sender_fs(context)
|
|
local target_fs = chat_formspec.easy_syntax_to_formspec(context)
|
|
local fs = string.format(chat_formspec.sender_template, target_fs, context.easy_syntax, context.target)
|
|
return fs
|
|
end
|
|
|
|
|
|
function chat_formspec.create_target_fs(context)
|
|
local fs = [[formspec_version[2]
|
|
size[14.6,7.7]
|
|
set_focus[answer]
|
|
]]
|
|
fs = fs .. chat_formspec.easy_syntax_to_formspec(context)
|
|
return fs
|
|
end
|
|
|
|
chat_formspec.misc_fs = {}
|
|
chat_formspec.misc_fs.platform_select = [[
|
|
formspec_version[2]
|
|
size[9,4]
|
|
|
|
label[2.3,1;Do you play on Touchscreen or on PC]
|
|
button[1,2;3,0.8;PC;PC]
|
|
button[5,2;3,0.8;touch;Touchscreen]
|
|
]]
|
|
|
|
chat_formspec.misc_fs.chat_PC = [[
|
|
formspec_version[2]
|
|
size[12,9.5]
|
|
|
|
label[4.5,0.8;How to chat on PC?]
|
|
label[4.5,0.8;________________]
|
|
|
|
textarea[0.5,1.35;11,6;;;1) close all pop-ups inside minetest by pressing 'ESC'
|
|
2) Press your 'T' or 'F10' key
|
|
3) 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
|
|
4) send your Text by pressing 'Enter'
|
|
|
|
In case you can't see the chat, try pressing 'F2' to show / hide the chat]
|
|
|
|
button[4.5,8;3,0.8;ok;OK]
|
|
]]
|
|
|
|
chat_formspec.misc_fs.chat_touch = [[
|
|
formspec_version[2]
|
|
size[12,9.5]
|
|
style_type[*;noclip=true]
|
|
|
|
label[4.5,0.8;How to chat on mobile?]
|
|
label[4.5,0.8;___________________]
|
|
|
|
label[0.5,1.35;1) Close all pop-ups inside Minetest by tapping outside of them]
|
|
label[0.5,1.85;2) Press the following buttons:]
|
|
image[0.5,2.35;0.75,1;rare_controls.png]
|
|
image[3,2.35;1,1;chat_btn.png]
|
|
label[0.5,3.85;3) Write the text you want to send in the public Chat]
|
|
label[0.5,4.35;4) Confirm by pressing 'Enter']
|
|
|
|
label[0.5,5;In case you can't see the chat, try pressing the following buttons:]
|
|
image[0.5,5.5;1,1;gear_icon.png]
|
|
image[3,5.5;1,1;chat_show_btn.png]
|
|
|
|
button[4.5,8;3,0.8;ok;OK]
|
|
]] |