forked from Sokomine/yl_speak_up
34 lines
808 B
Lua
34 lines
808 B
Lua
|
|
yl_speak_up.stop_talking = function(pname)
|
|
if(not(pname)) then
|
|
return
|
|
end
|
|
yl_speak_up.edit_mode[pname] = nil
|
|
yl_speak_up.speak_to[pname] = nil
|
|
minetest.close_formspec(pname, "yl_speak_up:talk")
|
|
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
|
|
|
|
|