From 7c801291f9816a634e7f21e930125cded8896e84 Mon Sep 17 00:00:00 2001 From: Sokomine Date: Sun, 5 Jan 2025 20:29:47 +0100 Subject: [PATCH] update_dialog_option now can update d_trade and d_got_item dialogs (to a degree) --- functions_dialogs.lua | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/functions_dialogs.lua b/functions_dialogs.lua index f686506..9d36bfa 100644 --- a/functions_dialogs.lua +++ b/functions_dialogs.lua @@ -157,7 +157,8 @@ yl_speak_up.update_dialog = function(log, dialog, dialog_name, dialog_text) if(dialog_name and yl_speak_up.is_special_dialog(dialog_name)) then -- d_trade, d_got_item, d_dynamic and d_end are not imported because they need to be handled diffrently table.insert(log, "Note: Not importing dialog \""..tostring(dialog_name).."\" because it is a special dialog.") - return nil + -- the options of thes special dialogs are still relevant + return dialog_name end -- does a dialog with name d_name already exist? local d_id = yl_speak_up.d_name_to_d_id(dialog, dialog_name) @@ -435,8 +436,20 @@ yl_speak_up.update_dialog_option = function(log, dialog, dialog_name, option_nam -- does the dialog we want to add to exist? local d_id = yl_speak_up.d_name_to_d_id(dialog, dialog_name) if(not(d_id)) then - -- the dialog does not exist - we cannot add an option to a nonexistant dialog - return nil + if(not(yl_speak_up.is_special_dialog(dialog_name))) then + -- the dialog does not exist - we cannot add an option to a nonexistant dialog + return nil + end + -- options for special dialogs have to start with "automaticly_" + local parts = string.split(option_name or "", "_") + if(not(parts) or not(parts[1]) or parts[1] ~= "automaticly_") then + option_name = "automaticly_"..table.concat(parts[2], "_") + end + -- for d_trade and d_got_item effects and preconditions are created WITH DEFAULT VALUES TODO + d_id = dialog_name + -- make sure the relevant dialog and fields exist + dialog.n_dialogs[d_id] = dialog.n_dialogs[d_id] or {} + dialog.n_dialogs[d_id].d_options = dialog.n_dialogs[d_id].d_options or {} end -- name the thing for logging purposes local log_str = "Dialog "..tostring(d_id)