added update_start_dialog for ink import

This commit is contained in:
Sokomine 2025-01-05 11:31:30 +01:00
parent 7ce56ca733
commit 543c767dd5
2 changed files with 22 additions and 1 deletions

View File

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

View File

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