just moved a function inside exec_actions.lua

This commit is contained in:
Sokomine 2022-08-07 20:55:57 +02:00
parent 77c05631eb
commit 49c2c49d6d

View File

@ -578,61 +578,6 @@ yl_speak_up.input_fs_action_npc_wants = function(player, formname, fields)
end
-- action of the type "evaluate"
yl_speak_up.input_fs_action_evaluate = function(player, formname, fields)
-- TODO: handle custom functions
-- back from error_msg? then show the formspec again
if(fields.back_from_error_msg) then
yl_speak_up.show_fs(player, "action_evaluate", nil)
return
end
local pname = player:get_player_name()
local a_id = yl_speak_up.speak_to[pname].a_id
if(fields.back_to_talk) then
-- the action was aborted
yl_speak_up.execute_next_action(player, a_id, nil)
return
end
if(fields.failed_action) then
-- the action failed
yl_speak_up.execute_next_action(player, a_id, false)
return
end
if(fields.finished_action) then
-- the action was a success
yl_speak_up.execute_next_action(player, a_id, true)
return
end
-- else show a message to the player that he ought to decide
yl_speak_up.show_fs(player, "msg", {
input_to = "yl_speak_up:action_evaluate",
formspec = "size[7,1.5]"..
"label[0.2,-0.2;"..
"Please click on one of the offered options\nor select \"Back to talk\"!]"..
"button[2,1.0;1.5,0.9;back_from_error_msg;Back]"})
end
yl_speak_up.get_fs_action_npc_wants = function(player, param)
local pname = player:get_player_name()
local dialog = yl_speak_up.speak_to[pname].dialog
return "size[8.5,8]"..
"list[current_player;main;0.2,3.85;8,1;]"..
"list[current_player;main;0.2,5.08;8,3;8]"..
"button[0.2,0.0;2.0,0.9;back_to_talk;Back to talk]"..
"button[4.75,1.6;1.5,0.9;finished_action;Done]"..
"tooltip[back_to_talk;Click here if you don't know what item the\n"..
"NPC wants or don't have the desired item.]"..
"tooltip[finished_action;Click here once you have placed the item in\n"..
"the waiting slot.]"..
"label[1.5,0.7;"..minetest.formspec_escape(dialog.n_npc or "- ? -")..
" expects something from you:]"..
"list[detached:yl_speak_up_player_"..pname..";npc_wants;3.25,1.5;1,1;]" ..
"label[1.5,2.7;Insert the right item and click on \"Done\" to proceed.]"
end
yl_speak_up.input_fs_action_text_input = function(player, formname, fields)
-- back from error_msg? then show the formspec again
if(fields.back_from_error_msg) then
@ -729,6 +674,61 @@ yl_speak_up.get_fs_action_text_input = function(player, param)
--]]
end
-- action of the type "evaluate"
yl_speak_up.input_fs_action_evaluate = function(player, formname, fields)
-- TODO: handle custom functions
-- back from error_msg? then show the formspec again
if(fields.back_from_error_msg) then
yl_speak_up.show_fs(player, "action_evaluate", nil)
return
end
local pname = player:get_player_name()
local a_id = yl_speak_up.speak_to[pname].a_id
if(fields.back_to_talk) then
-- the action was aborted
yl_speak_up.execute_next_action(player, a_id, nil)
return
end
if(fields.failed_action) then
-- the action failed
yl_speak_up.execute_next_action(player, a_id, false)
return
end
if(fields.finished_action) then
-- the action was a success
yl_speak_up.execute_next_action(player, a_id, true)
return
end
-- else show a message to the player that he ought to decide
yl_speak_up.show_fs(player, "msg", {
input_to = "yl_speak_up:action_evaluate",
formspec = "size[7,1.5]"..
"label[0.2,-0.2;"..
"Please click on one of the offered options\nor select \"Back to talk\"!]"..
"button[2,1.0;1.5,0.9;back_from_error_msg;Back]"})
end
yl_speak_up.get_fs_action_npc_wants = function(player, param)
local pname = player:get_player_name()
local dialog = yl_speak_up.speak_to[pname].dialog
return "size[8.5,8]"..
"list[current_player;main;0.2,3.85;8,1;]"..
"list[current_player;main;0.2,5.08;8,3;8]"..
"button[0.2,0.0;2.0,0.9;back_to_talk;Back to talk]"..
"button[4.75,1.6;1.5,0.9;finished_action;Done]"..
"tooltip[back_to_talk;Click here if you don't know what item the\n"..
"NPC wants or don't have the desired item.]"..
"tooltip[finished_action;Click here once you have placed the item in\n"..
"the waiting slot.]"..
"label[1.5,0.7;"..minetest.formspec_escape(dialog.n_npc or "- ? -")..
" expects something from you:]"..
"list[detached:yl_speak_up_player_"..pname..";npc_wants;3.25,1.5;1,1;]" ..
"label[1.5,2.7;Insert the right item and click on \"Done\" to proceed.]"
end
yl_speak_up.get_fs_action_evaluate = function(player, param)
local pname = player:get_player_name()
local dialog = yl_speak_up.speak_to[pname].dialog