update_dialog_option now can update d_trade and d_got_item dialogs (to a degree)

This commit is contained in:
Sokomine 2025-01-05 20:29:47 +01:00
parent 133a8ccf8d
commit 7c801291f9

View File

@ -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)