properly split option names for ink import

This commit is contained in:
Sokomine 2025-01-02 00:43:16 +01:00
parent 8570fea8ba
commit 06507880b6

View File

@ -337,26 +337,31 @@ yl_speak_up.update_dialog_option = function(log, dialog, dialog_name, option_nam
local o_id = option_name
local mode = 0
local text_when_prerequisites_not_met = ""
if( o_id and yl_speak_up.string_starts_with(o_id, "new_")) then
local parts = string.split(o_id, "_")
if(not(parts) or not(parts[1]) or not(parts[2])) then
table.insert(log, log_str.."FAILED to create unknown option \""..tostring(o_id).."\".")
return nil
elseif(o_id and parts[1] == "new_") then
-- we are asked to create a *new* option
o_id = nil
elseif(o_id and yl_speak_up.string_starts_with(o_id, "automaticly_")) then
elseif(o_id and parts[1] == "automaticly_") then
-- this option will be automaticly selected if its preconditions are true
mode = 1
option_name = string.sub(o_id, string.find(o_id, "automaticly_") + 1)
option_name = parts[2]
o_id = option_name
elseif(o_id and yl_speak_up.string_starts_with(o_id, "randomly_")) then
elseif(o_id and parts[1] == "randomly_") then
-- this option will be randomly selected if its preconditions are true;
-- (that means all other options of this dialog will have to be randomly as well;
-- something which cannot be done here as there is no guarantee that all options
-- *exist* at this point)
mode = 2
option_name = string.sub(o_id, string.find(o_id, "randomly_") + 1)
option_name = parts[2]
o_id = option_name
elseif(o_id and yl_speak_up.string_starts_with(o_id, "grey_out_")) then
elseif(o_id and parts[1] == "grey_") then
-- this sets o_text_when_prerequisites_not_met
mode = 3
option_name = string.sub(o_id, string.find(o_id, "grey_out_") + 1)
-- strip the out_ part as well
option_name = string.sub(parts[2], 5)
o_id = option_name
-- in this case we don't want to change the old text - just the greyed out one
-- (we keep option_text in case the option needs to be created)
@ -376,7 +381,8 @@ yl_speak_up.update_dialog_option = function(log, dialog, dialog_name, option_nam
next_id = string.sub(o_id, 3)
if(next_id == "" or not(tonumber(next_id))) then
next_id = nil
table.insert(log, log_str.."FAILED to create new option.")
table.insert(log, log_str.."FAILED to create new option \""..tostring(o_id).."\".")
return
end
end
-- pname is nil - thus no logging here