o_random is part of a dialog - not of an option

This commit is contained in:
Sokomine 2025-01-03 22:25:53 +01:00
parent 16df2f9155
commit 6370396fea
2 changed files with 20 additions and 25 deletions

View File

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

View File

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