allow adding new dialogs with the target_dialog dropdown

This commit is contained in:
Sokomine 2021-05-01 14:11:10 +02:00
parent 5ed1b1e2dc
commit 9a0dc0a1fe

View File

@ -1769,11 +1769,15 @@ yl_speak_up.edit_mode_apply_changes = function(pname, fields)
end
-- detect changes to d_id_<o_id>: target dialog for option <o_id>
-- TODO: this may also point to a new dialog
for k, v in pairs(dialog.n_dialogs[ d_id ].d_options) do
if( fields[ "d_id_"..k ] and v.o_results) then
for kr, vr in pairs(v.o_results) do
if( vr.r_type == "dialog" and vr.r_value and vr.r_value ~= fields[ "d_id_"..k ]) then
-- this may also point to a new dialog
if(fields[ "d_id_"..k ] == yl_speak_up.text_new_dialog_id) then
-- create a new dialog and show it as new target dialog - but do not display this dialog directly (the player may follow the -> button)
fields[ "d_id_"..k ] = yl_speak_up.add_new_dialog(dialog, pname)
end
-- store that there have been changes to this npc
table.insert(yl_speak_up.npc_was_changed[ yl_speak_up.edit_mode[pname] ],
"Dialog "..d_id..": The target dialog for option "..tostring(k).." was changed from "..tostring(vr.r_value).." to "..tostring(fields[ "d_id_"..k])..".")
@ -1783,6 +1787,11 @@ yl_speak_up.edit_mode_apply_changes = function(pname, fields)
end
-- this might be the first option
elseif( fields["d_id_"..k ]) then
-- this may also point to a new dialog
if(fields[ "d_id_"..k ] == yl_speak_up.text_new_dialog_id) then
-- create a new dialog and show it as new target dialog - but do not display this dialog directly (the player may follow the -> button)
fields[ "d_id_"..k ] = yl_speak_up.add_new_dialog(dialog, pname)
end
-- store that a new option has been added to this dialog
table.insert(yl_speak_up.npc_was_changed[ yl_speak_up.edit_mode[pname] ],
"Dialog "..d_id..": The target dialog for option "..tostring(k).." was changed from -default- to "..tostring(fields[ "d_id_"..k])..".")