diff --git a/export_to_ink.lua b/export_to_ink.lua index a519e1b..c2fdf7c 100644 --- a/export_to_ink.lua +++ b/export_to_ink.lua @@ -13,10 +13,15 @@ local use_d_name = true -- in order to be able to deal with multiple NPC in ink, we use the NPC id n_id -- plus the dialog id d_id as a name prefix; o_id, a_id and r_id are appended -- as needed -yl_speak_up.export_to_ink.print_knot_name = function(lines, knot_name, use_prefix) +yl_speak_up.export_to_ink.print_knot_name = function(lines, knot_name, use_prefix, dialog_names) + if(knot_name and dialog_names[knot_name]) then + knot_name = dialog_names[knot_name] + end + knot_name = use_prefix..tostring(knot_name or "ERROR") table.insert(lines, "\n\n=== ") - table.insert(lines, use_prefix..tostring(knot_name or "ERROR")) + table.insert(lines, knot_name) table.insert(lines, " ===") + return knot_name end @@ -133,12 +138,8 @@ end -- this prints the dialog as a knot - but without choices (those are added to the lines table later) -- d: dialog -yl_speak_up.export_to_ink.print_dialog_knot = function(lines, use_prefix, d_id, d) - local knot_name = tostring(d_id) - if(use_d_name) then - knot_name = (d.d_name or knot_name) - end - ink_export.print_knot_name(lines, knot_name, use_prefix) +yl_speak_up.export_to_ink.print_dialog_knot = function(lines, use_prefix, d_id, d, dialog_names) + local knot_name = ink_export.print_knot_name(lines, d_id, use_prefix, dialog_names) -- many characters at the start of a line have a special meaning; -- hopefully they will not be obstrusive later on; @@ -160,8 +161,8 @@ end -- a action yl_speak_up.export_to_ink.print_action_knot = function(lines, use_prefix, d_id, o_id, start_dialog, a, alternate_text_on_success, next_target, dialog_names) - local knot_name = tostring(d_id).."_"..tostring(o_id).."_"..tostring(a.a_id) - ink_export.print_knot_name(lines, knot_name, use_prefix) + local action_prefix = use_prefix.."action_"..tostring(a.a_id).."_"..tostring(o_id).."_" + local knot_name = ink_export.print_knot_name(lines, d_id, action_prefix, dialog_names) table.insert(lines, "\n:action: ") table.insert(lines, a.a_id) @@ -179,7 +180,7 @@ yl_speak_up.export_to_ink.print_action_knot = function(lines, use_prefix, d_id, ink_export.print_choice(lines, "Back", use_prefix, start_dialog, nil, tostring(d_id), false, nil, nil, nil, dialog_names) - return knot_name + return string.sub(knot_name, string.len(use_prefix)+1) end @@ -192,8 +193,8 @@ end yl_speak_up.export_to_ink.print_effect_knot = function(lines, use_prefix, d_id, o_id, start_dialog, r, r_prev, alternate_text_on_success, next_target, dialog_names) - local knot_name = tostring(d_id).."_"..tostring(o_id).."_"..tostring(r.r_id) - ink_export.print_knot_name(lines, knot_name, use_prefix) + local effect_prefix = use_prefix.."effect_"..tostring(r.r_id).."_"..tostring(o_id).."_" + local knot_name = ink_export.print_knot_name(lines, d_id, effect_prefix, dialog_names) table.insert(lines, "\n:effect: ") table.insert(lines, r.r_id) @@ -214,8 +215,7 @@ yl_speak_up.export_to_ink.print_effect_knot = function(lines, use_prefix, d_id, ink_export.print_choice(lines, "Effect failed", use_prefix, start_dialog, r.alternate_text, r.r_value, false, nil, nil, nil, dialog_names) - - return knot_name + return string.sub(knot_name, string.len(use_prefix)+1) end @@ -435,7 +435,7 @@ yl_speak_up.export_to_ink_language = function(dialog, n_id) local tmp2 = {} local d = dialog.n_dialogs[d_id] -- print the dialog knot, but without choices (those we add in the following loop) - local this_knot_name = ink_export.print_dialog_knot(tmp, use_prefix, d_id, d) + local this_knot_name = ink_export.print_dialog_knot(tmp, use_prefix, d_id, d, dialog_names) -- iterate over all options local sorted_o_list = yl_speak_up.get_sorted_options(dialog.n_dialogs[d_id].d_options or {}, "o_sort")