moved yl_speak_up.get_start_dialog_id into functions_dialog

This commit is contained in:
Sokomine 2025-01-01 23:00:38 +01:00
parent e5183813d7
commit 40314125a8
2 changed files with 21 additions and 20 deletions

View File

@ -8,26 +8,6 @@ yl_speak_up.stop_talking = function(pname)
end
-- helper function for
-- yl_speak_up.get_fs_talkdialog and
-- yl_speak_up.check_and_add_as_generic_dialog
-- find the dialog with d_sort == 0 or lowest number
yl_speak_up.get_start_dialog_id = function(dialog)
if(not(dialog) or not(dialog.n_dialogs)) then
return nil
end
-- Find the dialog with d_sort = 0 or alternatively with the lowest number
local lowest_sort = nil
local d_id = nil
for k, v in pairs(dialog.n_dialogs) do
local nr = tonumber(v.d_sort)
if(not(lowest_sort) or (nr and nr >= 0 and nr < lowest_sort)) then
lowest_sort = nr
d_id = k
end
end
return d_id
end
-- count visits to this dialog - but *not* for generic dialogs as those are just linked and not

View File

@ -58,6 +58,27 @@ yl_speak_up.sanitize_sort = function(options, value)
end
-- helper function for
-- yl_speak_up.get_fs_talkdialog and
-- yl_speak_up.check_and_add_as_generic_dialog
-- find the dialog with d_sort == 0 or lowest number
yl_speak_up.get_start_dialog_id = function(dialog)
if(not(dialog) or not(dialog.n_dialogs)) then
return nil
end
-- Find the dialog with d_sort = 0 or alternatively with the lowest number
local lowest_sort = nil
local d_id = nil
for k, v in pairs(dialog.n_dialogs) do
local nr = tonumber(v.d_sort)
if(not(lowest_sort) or (nr and nr >= 0 and nr < lowest_sort)) then
lowest_sort = nr
d_id = k
end
end
return d_id
end
--###
--Formspecs