This repository has been archived on 2024-02-14. You can view files and clone it, but cannot push or open issues or pull requests.
chat_formspec/specs.lua

118 lines
4.0 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.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 ""
local sender = context.sender
predefined = string.format(predefined, sender, replacement)
local fs = string.format(chat_formspec.predefined_template, predefined, replacement, target)
return fs
end
function chat_formspec.create_target_fs(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 fs = [[formspec_version[2]
size[14.6,7.7]
set_focus[answer]
]]
local predefined = chat_formspec.predefined[context.id].fs
local replacement = context.replacement or chat_formspec.predefined[context.id].replacement
local sender = context.sender
predefined = string.format(predefined, sender, replacement)
fs = fs .. predefined
return fs
end
chat_formspec.misc_fs = {}
chat_formspec.misc_fs.chat_help = [[
formspec_version[2]
size[15,10]
label[6,0.8;How to chat?]
label[6,0.8;___________]
label[0.3,1.5;On a computer:]
label[0.3,1.6;____________]
textarea[3,1.35;15,4;;;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]
label[0.3,4.5;On mobile / tablet:]
label[0.3,4.6;______________]
textarea[3,4.345;15,7;;;1) Close all pop-ups inside Minetest by tapping outside of them
2) Press the following buttons:
=>
4) 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
5) send your Text by pressing 'Enter'
In case you can't see chat, try pressing the following buttons
=>]
image[3,5.05;0.5,0.75;rare_controls.png]
image[4,5;1,1;chat_btn.png]
image[3,8.05;1,1;gear_icon.png]
image[4.5,8.05;1,1;chat_show_btn.png]
button[6,9;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]
]]