less spammy logs for update_dialog*

This commit is contained in:
Sokomine 2025-01-03 21:51:36 +01:00
parent 829683f750
commit 31434e69ce

View File

@ -157,6 +157,7 @@ yl_speak_up.update_dialog = function(log, dialog, dialog_name, dialog_text)
if(dialog_name and dialog_name ~= d_id) then
log_str = log_str.." ["..tostring(dialog_name).."]: "
end
local is_new = false
if(not(d_id)) then
-- 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
@ -169,7 +170,8 @@ yl_speak_up.update_dialog = function(log, dialog, dialog_name, dialog_text)
end
-- we got a new name for the log
log_str = "New dialog "..tostring(d_id).." ["..tostring(dialog_name).."]: "
table.insert(log, log_str.."Successfully created dialog.")
is_new = true
table.insert(log, log_str.."Created successfully.")
elseif(dialog.n_dialogs[d_id].d_text ~= dialog_text) then
-- else update the text
@ -183,8 +185,11 @@ yl_speak_up.update_dialog = function(log, dialog, dialog_name, dialog_text)
if(d_id ~= dialog_name
and (not(dialog.n_dialogs[d_id].d_name)
or(dialog.n_dialogs[d_id].d_name ~= dialog_name))) then
table.insert(log, log_str.."Changed dialog name from \""..
tostring(dialog.n_dialogs[d_id].d_name).."\" to \""..tostring(dialog_name).."\".")
if(not(is_new)) then
-- log only if it's not a new dialog
table.insert(log, log_str.."Changed dialog name from \""..
tostring(dialog.n_dialogs[d_id].d_name).."\" to \""..tostring(dialog_name).."\".")
end
-- actually change the dialog name
dialog.n_dialogs[d_id].d_name = dialog_name
end
@ -353,6 +358,7 @@ yl_speak_up.update_dialog_option = function(log, dialog, dialog_name, option_nam
log_str = log_str.." ["..tostring(dialog_name).."]"
end
log_str = log_str..", option <"..tostring(option_name)..">: "
local is_new = false
-- translate the name of the target_dialog if needed
if(target_dialog and not(yl_speak_up.is_special_dialog(target_dialog))) then
@ -410,7 +416,7 @@ yl_speak_up.update_dialog_option = function(log, dialog, dialog_name, option_nam
if(not(o_id)) then
return nil
end
table.insert(log, log_str.."Successfully created new option \""..tostring(o_id).."\".")
is_new = true
end
-- abbreviate that
@ -455,9 +461,15 @@ yl_speak_up.update_dialog_option = function(log, dialog, dialog_name, option_nam
-- we found the right result/effect that holds the (current) target_dialog
if(r and r.r_type and r.r_type == "dialog") then
if(not(r.r_value) or r.r_value ~= target_dialog) then
table.insert(log, log_str.."Changed target dialog from \""..
tostring(r.r_value).."\" to \""..tostring(target_dialog)..
"\" for option \""..tostring(o_id).."\".")
if(is_new) then
table.insert(log, log_str.."Successfully created new option \""..
tostring(o_id).."\" with target dialog \""..
tostring(target_dialog).."\".")
else
table.insert(log, log_str.."Changed target dialog from \""..
tostring(r.r_value).."\" to \""..tostring(target_dialog)..
"\" for option \""..tostring(o_id).."\".")
end
-- actually change the target dialog
r_found = true
r.r_value = target_dialog