log add_trade_simple in npc_was_changed as an exception without having to resort to edit_mode directly

This commit is contained in:
Sokomine 2024-02-09 06:20:18 +01:00
parent 0f6962e0a8
commit 1cc4f2e742

View File

@ -195,10 +195,14 @@ yl_speak_up.input_add_trade_simple = function(player, formname, fields, input_to
elseif(trade_id ~= "new" and (not(d_id) or not(o_id))) then
error_msg = "Internal error. o_id was not set."
else
-- record this as a change, but do not save do disk yet
table.insert(yl_speak_up.npc_was_changed[ n_id ],
"Dialog "..d_id..": Trade "..tostring(trade_id).." added to option "..
tostring(o_id)..".")
-- would be too complicated to handle exceptions; this is for edit_mode:
if(yl_speak_up.npc_was_changed
and yl_speak_up.npc_was_changed[n_id]) then
-- record this as a change, but do not save do disk yet
table.insert(yl_speak_up.npc_was_changed[ n_id ],
"Dialog "..d_id..": Trade "..tostring(trade_id)..
" added to option "..tostring(o_id)..".")
end
-- add this new trade - complete with information to which dialog and
-- to which option the trade belongs
dialog.trades[ trade_id ] = {pay={ps},buy={bs}, d_id = d_id, o_id = o_id}
@ -229,10 +233,14 @@ yl_speak_up.input_add_trade_simple = function(player, formname, fields, input_to
-- delete this result (if it exists)
-- get the necessary dialog data
local dialog = yl_speak_up.speak_to[pname].dialog
-- record this as a change
table.insert(yl_speak_up.npc_was_changed[ n_id ],
"Dialog "..d_id..": Trade "..tostring(trade_id).." deleted from option "..
tostring(o_id)..".")
-- would be too complicated to handle exceptions; this is for edit_mode:
if(yl_speak_up.npc_was_changed
and yl_speak_up.npc_was_changed[n_id]) then
-- record this as a change
table.insert(yl_speak_up.npc_was_changed[ n_id ],
"Dialog "..d_id..": Trade "..tostring(trade_id)..
" deleted from option "..tostring(o_id)..".")
end
if(not(dialog.trades)) then
dialog.trades = {}
end