From cfb673993f23ded5cd805e486cf9cd1a9310e846 Mon Sep 17 00:00:00 2001 From: Sokomine Date: Fri, 22 Mar 2024 17:15:13 +0100 Subject: [PATCH] added yl_speak_up.get_dialog_list_for_export --- export_to_ink.lua | 2 +- fs/fs_export.lua | 36 ++++++++++++++++++++++++------------ 2 files changed, 25 insertions(+), 13 deletions(-) diff --git a/export_to_ink.lua b/export_to_ink.lua index dd4df19..b00e027 100644 --- a/export_to_ink.lua +++ b/export_to_ink.lua @@ -400,7 +400,7 @@ yl_speak_up.export_to_ink_language = function(dialog, n_id) local vars_used = ink_export.print_variables_used(tmp, dialog, n_id, pname) - local sorted_d_list = yl_speak_up.sort_keys(dialog.n_dialogs or {}, true) + local sorted_d_list = yl_speak_up.get_dialog_list_for_export(dialog) -- make use of dialog names if wanted local dialog_names = {} diff --git a/fs/fs_export.lua b/fs/fs_export.lua index 00b4867..c6719a8 100644 --- a/fs/fs_export.lua +++ b/fs/fs_export.lua @@ -1,3 +1,24 @@ +-- helper function that is also used by export_to_ink.lua +-- returns a sorted dialog list without special or generic dialogs +yl_speak_up.get_dialog_list_for_export = function(dialog) + local liste = {} + if(not(dialog) or not(dialog.n_dialogs)) then + return liste + end + -- sort the list of dialogs by d_id + local liste_sorted = yl_speak_up.sort_keys(dialog.n_dialogs or {}, true) + for _, d_id in ipairs(liste_sorted) do + -- only normal dialogs - no d_trade, d_got_item, d_dynamic etc; + if(not(yl_speak_up.is_special_dialog(d_id)) + -- also no generic dialogs (they do not come from this NPC) + and not(dialog.n_dialogs[d_id].is_generic)) then + table.insert(liste, d_id) + end + end + return liste +end + + yl_speak_up.input_export = function(player, formname, fields) if(fields and fields.back) then return yl_speak_up.show_fs(player, "talk") @@ -181,19 +202,10 @@ yl_speak_up.get_fs_export = function(player, param) "this mod here. It only covers the raw dialogs. If a dialog line starts with ".. "\":\", \">\" or \"=\", a \" \" is added before that letter because such a ".. "line start would not be allowed in \"simple_dialogs\"." + + local d_liste = yl_speak_up.get_dialog_list_for_export(dialog) + local tmp = {} - local d_liste = {} - if(dialog.n_dialogs) then - for d_id, v in pairs(dialog.n_dialogs) do - -- only normal dialogs - no d_trade, d_got_item, d_dynamic etc; - if(not(yl_speak_up.is_special_dialog(d_id)) - -- also no generic dialogs (they do not come from this NPC) - and not(v.is_generic)) then - table.insert(d_liste, d_id) - end - end - end - table.sort(d_liste) for i, d_id in ipairs(d_liste) do table.insert(tmp, "===") -- TODO: use labels here when available