mirror of
https://gitea.your-land.de/Sokomine/yl_speak_up.git
synced 2025-06-28 18:18:03 +02:00
allow to toggle between successful and unsuccessful action in edit options menu
This commit is contained in:
parent
61bd16f3f2
commit
a43cef9290
@ -19,6 +19,18 @@ yl_speak_up.input_edit_option_dialog = function(player, formname, fields)
|
|||||||
local n_dialog = dialog.n_dialogs[d_id]
|
local n_dialog = dialog.n_dialogs[d_id]
|
||||||
local d_option = n_dialog.d_options[o_id]
|
local d_option = n_dialog.d_options[o_id]
|
||||||
|
|
||||||
|
if(fields.button_show_if_action_failed) then
|
||||||
|
yl_speak_up.show_fs(player, "edit_option_dialog",
|
||||||
|
{n_id = n_id, d_id = d_id, o_id = o_id,
|
||||||
|
caller="show_if_action_failed"})
|
||||||
|
return
|
||||||
|
elseif(fields.button_show_if_action_succeeded) then
|
||||||
|
yl_speak_up.show_fs(player, "edit_option_dialog",
|
||||||
|
{n_id = n_id, d_id = d_id, o_id = o_id,
|
||||||
|
caller="show_if_action_succeeded"})
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
-- this meny is specific to an option for a dialog; if no dialog is selected, we really
|
-- this meny is specific to an option for a dialog; if no dialog is selected, we really
|
||||||
-- can't know what to do
|
-- can't know what to do
|
||||||
if(not(o_id) and d_id) then
|
if(not(o_id) and d_id) then
|
||||||
@ -105,7 +117,7 @@ end
|
|||||||
|
|
||||||
|
|
||||||
-- edit options (not via staff but via the "I am your owner" dialog)
|
-- edit options (not via staff but via the "I am your owner" dialog)
|
||||||
yl_speak_up.get_fs_edit_option_dialog = function(player, n_id, d_id, o_id)
|
yl_speak_up.get_fs_edit_option_dialog = function(player, n_id, d_id, o_id, caller)
|
||||||
-- n_id, d_id and o_id have already been checked when this function is called
|
-- n_id, d_id and o_id have already been checked when this function is called
|
||||||
local pname = player:get_player_name()
|
local pname = player:get_player_name()
|
||||||
local dialog = yl_speak_up.speak_to[pname].dialog
|
local dialog = yl_speak_up.speak_to[pname].dialog
|
||||||
@ -151,6 +163,7 @@ yl_speak_up.get_fs_edit_option_dialog = function(player, n_id, d_id, o_id)
|
|||||||
local list_of_actions = ""
|
local list_of_actions = ""
|
||||||
local actions = d_option.actions
|
local actions = d_option.actions
|
||||||
local count_actions = 0
|
local count_actions = 0
|
||||||
|
local action_data = nil
|
||||||
if(actions) then
|
if(actions) then
|
||||||
local sorted_key_list = yl_speak_up.sort_keys(actions)
|
local sorted_key_list = yl_speak_up.sort_keys(actions)
|
||||||
for i, k in ipairs(sorted_key_list) do
|
for i, k in ipairs(sorted_key_list) do
|
||||||
@ -161,6 +174,7 @@ yl_speak_up.get_fs_edit_option_dialog = function(player, n_id, d_id, o_id)
|
|||||||
minetest.formspec_escape(
|
minetest.formspec_escape(
|
||||||
yl_speak_up.show_action(v))..","
|
yl_speak_up.show_action(v))..","
|
||||||
count_actions = count_actions + 1
|
count_actions = count_actions + 1
|
||||||
|
action_data = v
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if(count_actions < yl_speak_up.max_actions) then
|
if(count_actions < yl_speak_up.max_actions) then
|
||||||
@ -278,6 +292,65 @@ yl_speak_up.get_fs_edit_option_dialog = function(player, n_id, d_id, o_id)
|
|||||||
button_add = ""
|
button_add = ""
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local action_text = "label[0.2,12.1;"..
|
||||||
|
"If the player completed the above action successfully, "..
|
||||||
|
"apply the following (Ef)fects:]"..
|
||||||
|
"button[17.0,11.7;4.0,0.7;button_show_if_action_failed;Show if it failed]"..
|
||||||
|
"tooltip[button_show_if_action_failed;Click here to see what will happen "..
|
||||||
|
"if the player\nfailed to execute the action successfully.]"
|
||||||
|
if(count_actions == 0) then
|
||||||
|
action_text = "label[0.2,12.1;"..
|
||||||
|
"There is no (A)ction defined. Directly apply the following (Ef)fects:]"
|
||||||
|
end
|
||||||
|
if(caller == "show_if_action_failed") then
|
||||||
|
action_text = "label[0.2,12.1;"..
|
||||||
|
"If the player *failed* to complete the above action correctly,]"..
|
||||||
|
"button[17.0,11.7;4.0,0.7;button_show_if_action_succeeded;Show if successful]"..
|
||||||
|
"tooltip[button_show_if_action_succeeded;Click here to see what will happen "..
|
||||||
|
"if the player\nexecuted the action successfully.]"
|
||||||
|
if(action_data and action_data.a_on_failure
|
||||||
|
and dialog.n_dialogs and dialog.n_dialogs[ action_data.a_on_failure]) then
|
||||||
|
action_text = action_text..
|
||||||
|
-- ..and what the NPC will reply to that answer
|
||||||
|
"label[0.2,15.1;..the NPC will react to this failed action with the "..
|
||||||
|
"following dialog \""..tostring(action_data.a_on_failure).."\":]"..
|
||||||
|
"hypertext[1.2,15.5;19.6,2.5;d_text_next;<global background=#776666>"..
|
||||||
|
"<normal>"..minetest.formspec_escape(tostring(
|
||||||
|
dialog.n_dialogs[ action_data.a_on_failure ].d_text))..
|
||||||
|
"\n</normal>]"..
|
||||||
|
"tooltip[1.2,16.8;21.0,2.5;This is what the NPC will say next when "..
|
||||||
|
"the player has failed to complete the action.]"
|
||||||
|
else
|
||||||
|
action_text = action_text..
|
||||||
|
"label[0.2,15.1;..go back to the initial dialog.]"
|
||||||
|
end
|
||||||
|
else
|
||||||
|
action_text = action_text..
|
||||||
|
-- list of effects
|
||||||
|
"tablecolumns[text;color,span=1;text;text]"..
|
||||||
|
"table[1.2,12.4;19.6,2.0;table_of_effects;"..
|
||||||
|
list_of_effects..";0]"..
|
||||||
|
"tooltip[1.2,12.4;19.6,2.0;"..
|
||||||
|
"*All* (Ef)fects are executed after the action (if there is\n"..
|
||||||
|
"one defined in this option) has been completed successfully\n"..
|
||||||
|
"by the player. If there is no action defined, then the\n"..
|
||||||
|
"(Ef)fects will always be executed when this option here is\n"..
|
||||||
|
"selected.\n"..
|
||||||
|
"Please click on an (Ef)fect in order to edit or delete it!]"..
|
||||||
|
-- allow to change the target dialog via a dropdown menu
|
||||||
|
"dropdown[12.5,14.7;7.5,0.7;d_id_"..minetest.formspec_escape(o_id)..";"..
|
||||||
|
dialog_list..";"..dialog_selected..",]"..
|
||||||
|
"tooltip[12.5,14.7;7.5,0.7;Select the target dialog with which the NPC shall react "..
|
||||||
|
"to this answer. Currently, dialog "..minetest.formspec_escape(target_dialog)..
|
||||||
|
" is beeing displayed.;#FFFFFF;#000000]"..
|
||||||
|
-- ..and what the NPC will reply to that answer
|
||||||
|
"label[0.2,15.1;The NPC will react to this answer with the following dialog:]"..
|
||||||
|
"hypertext[1.2,15.5;19.6,2.5;d_text_next;<global background=#777766><normal>"..
|
||||||
|
minetest.formspec_escape(next_text) .. "\n</normal>]"..
|
||||||
|
"tooltip[1.2,16.8;21.0,2.5;This is what the NPC will say next when the player has "..
|
||||||
|
"selected this answer here.]"
|
||||||
|
end
|
||||||
|
|
||||||
-- build up the formspec
|
-- build up the formspec
|
||||||
local formspec = ""..
|
local formspec = ""..
|
||||||
"formspec_version[3]"..
|
"formspec_version[3]"..
|
||||||
@ -293,8 +366,8 @@ yl_speak_up.get_fs_edit_option_dialog = function(player, n_id, d_id, o_id)
|
|||||||
-- the text the NPC says
|
-- the text the NPC says
|
||||||
"label[0.2,0.6;NPC says "..
|
"label[0.2,0.6;NPC says "..
|
||||||
minetest.formspec_escape("[dialog \""..tostring(d_id).."\"]:").."]"..
|
minetest.formspec_escape("[dialog \""..tostring(d_id).."\"]:").."]"..
|
||||||
"hypertext[1.2,1.2;19.6,2.5;d_text;<global background=#777766><normal><normal>"..
|
"hypertext[1.2,1.2;19.6,2.5;d_text;<global background=#777766><normal>"..
|
||||||
minetest.formspec_escape(n_dialog.d_text) .. "\n</normal></global>]"..
|
minetest.formspec_escape(n_dialog.d_text) .. "\n</normal>]"..
|
||||||
"tooltip[1.2,1.2;19.6,3.0;This is what the NPC says to the player.]"..
|
"tooltip[1.2,1.2;19.6,3.0;This is what the NPC says to the player.]"..
|
||||||
-- list the preconditions
|
-- list the preconditions
|
||||||
"label[0.2,4.2;If all of the following pre(C)onditions are fulfilled:]"..
|
"label[0.2,4.2;If all of the following pre(C)onditions are fulfilled:]"..
|
||||||
@ -332,31 +405,9 @@ yl_speak_up.get_fs_edit_option_dialog = function(player, n_id, d_id, o_id)
|
|||||||
"tablecolumns[text;color,span=1;text;text]"..
|
"tablecolumns[text;color,span=1;text;text]"..
|
||||||
"table[1.2,10.9;19.6,0.7;table_of_actions;"..
|
"table[1.2,10.9;19.6,0.7;table_of_actions;"..
|
||||||
list_of_actions..";0]"..
|
list_of_actions..";0]"..
|
||||||
-- list of effects
|
-- list effects and target dialog for successful - and target dialog for unsuccessful
|
||||||
"label[0.2,12.1;If the player completed the above action successfully, "..
|
-- actions (including a toggle button)
|
||||||
"apply the following (Ef)fects:]"..
|
action_text..
|
||||||
"tablecolumns[text;color,span=1;text;text]"..
|
|
||||||
"table[1.2,12.4;19.6,2.0;table_of_effects;"..
|
|
||||||
list_of_effects..";0]"..
|
|
||||||
"tooltip[1.2,12.4;19.6,2.0;"..
|
|
||||||
"*All* (Ef)fects are executed after the action (if there is\n"..
|
|
||||||
"one defined in this option) has been completed successfully\n"..
|
|
||||||
"by the player. If there is no action defined, then the\n"..
|
|
||||||
"(Ef)fects will always be executed when this option here is\n"..
|
|
||||||
"selected.\n"..
|
|
||||||
"Please click on an (Ef)fect in order to edit or delete it!]"..
|
|
||||||
-- allow to change the target dialog via a dropdown menu
|
|
||||||
"dropdown[13.3,14.7;7.5,0.7;d_id_"..minetest.formspec_escape(o_id)..";"..
|
|
||||||
dialog_list..";"..dialog_selected..",]"..
|
|
||||||
"tooltip[13.3,14.7;7.5,0.7;Select the target dialog with which the NPC shall react "..
|
|
||||||
"to this answer. Currently, dialog "..minetest.formspec_escape(target_dialog)..
|
|
||||||
" is beeing displayed.;#FFFFFF;#000000]"..
|
|
||||||
-- ..and what the NPC will reply to that answer
|
|
||||||
"label[0.2,15.1;The NPC will react to this answer with the following dialog:]"..
|
|
||||||
"hypertext[1.2,15.5;19.6,2.5;d_text_next;<global background=#777766><normal>"..
|
|
||||||
minetest.formspec_escape(next_text) .. "\n</normal></global>]"..
|
|
||||||
"tooltip[1.2,16.8;21.0,2.5;This is what the NPC will say next when the player has "..
|
|
||||||
"selected this answer here.]"..
|
|
||||||
-- button: delete
|
-- button: delete
|
||||||
"button[0.2,18.7;2.0,0.9;del_option;Delete]"..
|
"button[0.2,18.7;2.0,0.9;del_option;Delete]"..
|
||||||
"tooltip[del_option;Delete this option/answer.]"..
|
"tooltip[del_option;Delete this option/answer.]"..
|
||||||
|
@ -203,7 +203,8 @@ yl_speak_up.show_fs = function(player, fs_name, param)
|
|||||||
end
|
end
|
||||||
yl_speak_up.speak_to[pname].o_id = param.o_id
|
yl_speak_up.speak_to[pname].o_id = param.o_id
|
||||||
minetest.show_formspec(pname, "yl_speak_up:edit_option_dialog",
|
minetest.show_formspec(pname, "yl_speak_up:edit_option_dialog",
|
||||||
yl_speak_up.get_fs_edit_option_dialog(player, param.n_id, param.d_id, param.o_id))
|
yl_speak_up.get_fs_edit_option_dialog(player, param.n_id, param.d_id, param.o_id,
|
||||||
|
param.caller))
|
||||||
|
|
||||||
elseif(fs_name == "talk") then
|
elseif(fs_name == "talk") then
|
||||||
if(not(param)) then
|
if(not(param)) then
|
||||||
|
Loading…
Reference in New Issue
Block a user