made save_dialog accessible

This commit is contained in:
Sokomine 2021-05-29 19:15:45 +02:00
parent 4ab240df52
commit 3184c89506

View File

@ -147,7 +147,7 @@ end
--###
-- we can't really log changes here in this function because we don't know *what* has been changed
local function save_dialog(n_id, dialog)
yl_speak_up.save_dialog = function(n_id, dialog)
if type(n_id) ~= "string" or type(dialog) ~= "table" then
return false
end
@ -329,7 +329,7 @@ local function delete_dialog(n_id, d_id)
dialog.n_dialogs[d_id] = nil
save_dialog(n_id, dialog)
yl_speak_up.save_dialog(n_id, dialog)
end
local function delete_option(n_id, d_id, o_id)
@ -344,7 +344,7 @@ local function delete_option(n_id, d_id, o_id)
dialog.n_dialogs[d_id].d_options[o_id] = nil
save_dialog(n_id, dialog)
yl_speak_up.save_dialog(n_id, dialog)
end
@ -1938,7 +1938,7 @@ yl_speak_up.input_optiondialog = function(player, formname, fields)
if fields and fields.button_save and fields.n_id and fields.d_id then
local temp_dialog = options_to_dialog(pname)
save_dialog(n_id, temp_dialog)
yl_speak_up.save_dialog(n_id, temp_dialog)
-- TODO: a better change detection would be good - because name, description and owner can change here
yl_speak_up.log_change(pname, n_id,
"(staff) Saved dialog "..tostring(fields.d_id)..".")
@ -2008,7 +2008,7 @@ yl_speak_up.input_setdialog = function(player, formname, fields)
-- Button Save: Save the settings, but do not exit
if fields.button_save and fields.d_id then
local dialog = fields_to_dialog(pname, fields)
save_dialog(n_id, dialog)
yl_speak_up.save_dialog(n_id, dialog)
-- TODO: a better change detection would be great (name, description, owner can be changed as well)
yl_speak_up.log_change(pname, n_id,
"(staff) Saved dialog "..tostring(fields.d_id)..".")
@ -2143,7 +2143,7 @@ yl_speak_up.save_changes_and_switch_to_other_dialog = function(player, fields, t
-- save changes and continue on to the next dialog
elseif(edit_mode and fields.save_dialog_changes) then
-- actually save the dialog (the one the NPC currently has)
save_dialog(n_id, yl_speak_up.speak_to[pname].dialog)
yl_speak_up.save_dialog(n_id, yl_speak_up.speak_to[pname].dialog)
-- log all the changes
for i, c in ipairs(yl_speak_up.npc_was_changed[ n_id ]) do
yl_speak_up.log_change(pname, n_id, c)
@ -2180,7 +2180,7 @@ yl_speak_up.save_changes_and_switch_to_other_dialog = function(player, fields, t
need_to_save = true
end
if(need_to_save) then
save_dialog(n_id, dialog)
yl_speak_up.save_dialog(n_id, dialog)
end
end
@ -2867,7 +2867,7 @@ yl_speak_up.input_talk = function(player, formname, fields)
f.npc_owner = yl_speak_up.npc_owner[ n_id ]
-- create and save the first dialog for this npc
local dialog = fields_to_dialog(pname, f)
save_dialog(n_id, dialog)
yl_speak_up.save_dialog(n_id, dialog)
yl_speak_up.speak_to[pname].dialog = dialog
yl_speak_up.log_change(pname, n_id,
@ -2879,7 +2879,7 @@ yl_speak_up.input_talk = function(player, formname, fields)
dialog = yl_speak_up.speak_to[pname].dialog
dialog.n_npc = fields.n_npc
dialog.n_description = fields.n_description
save_dialog(n_id, dialog)
yl_speak_up.save_dialog(n_id, dialog)
yl_speak_up.log_change(pname, n_id,
"Name and/or description changed. "..