try to perserve d_<nr> dialog names in update_dialog

This commit is contained in:
Sokomine 2025-01-04 18:14:48 +01:00
parent 0d76f7492a
commit 000978ef50

View File

@ -165,9 +165,15 @@ yl_speak_up.update_dialog = function(log, dialog, dialog_name, dialog_text)
end
local is_new = false
if(not(d_id)) then
local next_id = nil
-- if dialog_name matches the d_<nr> pattern but d_<nr> does not exist,
-- then try to create *that* dialog
if(dialog_name and string.sub(dialog_name, 1, 2) == "d_") then
next_id = tonumber(string.sub(dialog_name, 3))
end
-- pname is nil - thus no logging and no adding of a back to start option
-- next_id is also nil - so just add a new dialog
d_id = yl_speak_up.add_new_dialog(dialog, nil, nil, dialog_text)
-- next_id is also usually nil - so just add a new dialog
d_id = yl_speak_up.add_new_dialog(dialog, nil, next_id, dialog_text)
if(not(d_id)) then
-- the creation may have failed (i.e. dialog not beeing a dialog,
-- or too many dialogs in dialog already)