From 6370396feab2b004eac85d3288f866f3a1cc67f1 Mon Sep 17 00:00:00 2001 From: Sokomine Date: Fri, 3 Jan 2025 22:25:53 +0100 Subject: [PATCH] o_random is part of a dialog - not of an option --- export_to_ink.lua | 8 ++++---- functions_dialogs.lua | 37 ++++++++++++++++--------------------- 2 files changed, 20 insertions(+), 25 deletions(-) diff --git a/export_to_ink.lua b/export_to_ink.lua index 6b7b6af..efd5115 100644 --- a/export_to_ink.lua +++ b/export_to_ink.lua @@ -510,12 +510,12 @@ yl_speak_up.export_to_ink_language = function(dialog, n_id) -- what remains is to print the option/choice itself local o_text = o_data.o_text_when_prerequisites_met local o_prefix = "" - if( o_data.o_autoanswer) then - o_text = "[Automaticly selected if preconditions are met]" - o_prefix = "automaticly_" - elseif(o_data.o_random) then + if(d.o_random) then o_text = "[One of these options is randomly selected]" o_prefix = "randomly_" + elseif(o_data.o_autoanswer) then + o_text = "[Automaticly selected if preconditions are met]" + o_prefix = "automaticly_" end ink_export.print_choice(tmp, o_text, use_prefix, start_dialog, diff --git a/functions_dialogs.lua b/functions_dialogs.lua index 23850f7..77cb17e 100644 --- a/functions_dialogs.lua +++ b/functions_dialogs.lua @@ -334,16 +334,13 @@ end -- If option_name starts with.. -- new_ create a new option (discard the rest of option_name) -- automaticly_ set o_autoanswer --- randomly_ set o_random +-- randomly_ set o_random *for the dialog* -- grey_out_ set o_text_when_prerequisites_not_met -- ..and take what remains as option_name. -- (useful for import from ink and likewise functionality) -- -- TODO: these notes need to be taken care of in the calling function -- Note: The calling function may need to adjust o_sort according to its needs. --- Note: The calling function also needs to take care to set *all* dialog options to --- *randomly selected* if at least *one* is set to this value. This cannot be done --- here as the other dialog options may not even be definied here yet. -- Note: Preconditions, actions and effects are not handled here (apart from the "dialog" -- effect/result for the redirection to the target dialog) yl_speak_up.update_dialog_option = function(log, dialog, dialog_name, option_name, @@ -499,27 +496,25 @@ yl_speak_up.update_dialog_option = function(log, dialog, dialog_name, option_nam end end + -- "randomly selected" applies to the *dialog* - it is set there and not in the individual option + local d_data = dialog.n_dialogs[d_id] + -- is this option selected randomly? + if( mode == 2 and not(d_data.o_random)) then + d_data.o_random = 1 + table.insert(log, log_str.."Changed DIALOG \""..tostring(o_id).."\" to RANDOMLY SELECTED.") + elseif(mode ~= 2 and d_data.o_random) then + d_data.o_random = nil + table.insert(log, log_str.."Changed DIALOG \""..tostring(o_id).."\" to RANDOMLY SELECTED.") + end + -- is this option selected automaticly if all preconditions are met? - if( mode == 1 and not(o_data.o_autoanswer)) then + if(mode == 1 and not(o_data.o_autoanswer)) then o_data.o_autoanswer = 1 table.insert(log, log_str.."Changed option \""..tostring(o_id).."\" to AUTOMATICLY SELECTED.") - -- actually update the text - -- is this option selected randomly? - elseif(mode == 2 and not(o_data.o_random)) then - o_data.o_random = 1 - table.insert(log, log_str.."Changed option \""..tostring(o_id).."\" to RANDOMLY SELECTED.") - else -- mode is 0 - that means everything is normal for this option - if(o_data.o_autoanswer) then - o_data.o_autoanswer = nil - table.insert(log, log_str.."Removed AUTOMATICLY SELECTED from option \"".. - tostring(o_id).."\".") - end - if(o_data.o_random) then - o_data.o_random = nil - table.insert(log, log_str.."Removed RANDOMLY SELECTED from option \"".. - tostring(o_id).."\".") - end + elseif(o_data.o_autoanswer) then + o_data.o_autoanswer = nil + table.insert(log, log_str.."Removed AUTOMATICLY SELECTED from option \""..tostring(o_id).."\".") end -- the visit_only_once option is handled without logging as it might create too many