From 543c767dd56f75a4a68d7d3a2108f7b1625bb0f6 Mon Sep 17 00:00:00 2001 From: Sokomine Date: Sun, 5 Jan 2025 11:31:30 +0100 Subject: [PATCH] added update_start_dialog for ink import --- fs/fs_export.lua | 2 +- functions_dialogs.lua | 21 +++++++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/fs/fs_export.lua b/fs/fs_export.lua index ee7728d..8e4c675 100644 --- a/fs/fs_export.lua +++ b/fs/fs_export.lua @@ -230,7 +230,7 @@ yl_speak_up.get_fs_export = function(player, param) end return table.concat({"size[20,20]label[4,0.5;Export of NPC ", minetest.formspec_escape(n_id or "- ? -"), - "dialog data in .json format]", + " dialog data in .json format]", "button[17.8,0.2;2.0,0.9;back;Back]", "button[15.4,0.2;2.0,0.9;import;Import]", "tooltip[import;WARNING: This is highly experimental and requires the \"privs\" priv.\n".. diff --git a/functions_dialogs.lua b/functions_dialogs.lua index 8eaeac1..f686506 100644 --- a/functions_dialogs.lua +++ b/functions_dialogs.lua @@ -264,6 +264,27 @@ yl_speak_up.update_dialog_options_completed = function(log, dialog, d_id) end +-- make sure only one dialog has d_sort set to 0 (and is thus the start dialog) +yl_speak_up.update_start_dialog = function(log, dialog, start_dialog_name) + local start_d_id = yl_speak_up.d_name_to_d_id(dialog, start_dialog_name) + if(not(start_d_id)) then + return + end + for d_id, d in pairs(dialog.n_dialogs) do + if(d_id == start_d_id) then + if(not(d.d_sort) or d.d_sort ~= 0) then + table.insert(log, "Setting start dialog to "..tostring(start_dialog_name)..".") + end + d.d_sort = 0 + -- the start dialog certainly is *a* start dialog (with the buttons) + d.is_a_start_dialog = true + elseif(not(d.d_sort) or d.d_sort == 0) then + -- all other dialogs are not *the* start dialog + d.d_sort = 1 + end + end +end + -- add a new option/answer to dialog d_id with option_text (or default "") -- option_text (optional) the text that shall be shown as option/answer