offer text input field in general reply field

This commit is contained in:
Sokomine 2022-04-17 20:10:19 +02:00
parent 8d65f22bea
commit 8f3a788987

View File

@ -616,6 +616,10 @@ yl_speak_up.input_fs_action_text_input = function(player, formname, fields)
yl_speak_up.execute_next_action(player, a_id, success)
return
end
-- no scrolling desired
fields.button_up = nil
fields.button_down = nil
--[[ this is too disruptive; it's better to just let the player select a button
-- else show a message to the player
yl_speak_up.show_fs(player, "msg", {
input_to = "yl_speak_up:action_text_input",
@ -624,6 +628,7 @@ yl_speak_up.input_fs_action_text_input = function(player, formname, fields)
"Please answer the question and click on \"Send answer\"!\n"..
"If you don't know the answer, click on \"Back to talk\".]"..
"button[2,1.0;1.5,0.9;back_from_error_msg;Back]"})
--]]
end
@ -634,7 +639,42 @@ yl_speak_up.get_fs_action_text_input = function(player, param)
if(not(a)) then
return ""
end
return "size[12.0,4.5]"..
local alternate_text =
(a.a_question or "Your answer:").."\n\n"..
(dialog.n_npc or "- ? -").." looks expectantly at you.]"
local formspec = {}
table.insert(formspec, "label[0.7,1.8;Answer:]")
table.insert(formspec, "button[45,1.0;9,1.8;finished_action;Send this answer]")
-- show the actual text for the option
yl_speak_up.add_formspec_element_with_tooltip_if(formspec,
"field", "4.0,1.0;40,1.5",
"quest_answer",
";", --..minetest.formspec_escape("<your answer>"),
"Enter your answer here.",
true)
local h = 2.0
h = yl_speak_up.add_edit_button_fs_talkdialog(formspec, h,
"finished_action",
"Please enter your answer in the input field above and click here to "..
"send it.",
minetest.formspec_escape("[Send this answer]"),
true, nil, nil, pname_for_old_fs)
h = yl_speak_up.add_edit_button_fs_talkdialog(formspec, h,
"back_to_talk",
"If you don't know the answer or don't want to answer right now, "..
"choose this option to get back to the previous dialog.",
"I give up. Let's talk about something diffrent.",
true, nil, nil, pname_for_old_fs)
-- do not offer edit_mode in the trade formspec because it makes no sense there;
return yl_speak_up.show_fs_decorated(pname, nil, h, alternate_text, "",
table.concat(formspec, "\n"), nil)
--[[ old version with extra formspec
return --"size[12.0,4.5]"..
yl_speak_up.show_fs_simple_deco(12.0, 4.5)..
"button[0.2,0.0;2.0,0.9;back_to_talk;Back to talk]"..
"button[2.0,3.7;3.0,0.9;finished_action;Send answer]"..
@ -645,4 +685,5 @@ yl_speak_up.get_fs_action_text_input = function(player, param)
"field[1.6,2.2;10.0,0.6;quest_answer;;"..tostring(param or "").."]"..
"label[0.2,2.8;"..minetest.formspec_escape(
"["..(dialog.n_npc or "- ? -").." looks expectantly at you.]").."]"
--]]
end