From a7288bb2b97810ac69a8c8ea3766679abf3030bf Mon Sep 17 00:00:00 2001 From: Sokomine Date: Sun, 20 Jun 2021 16:32:10 +0200 Subject: [PATCH] save the inventory of the NPC after npc_gives/npc_wants --- fs_edit_actions.lua | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/fs_edit_actions.lua b/fs_edit_actions.lua index 7d1d5ba..3dd0c15 100644 --- a/fs_edit_actions.lua +++ b/fs_edit_actions.lua @@ -397,6 +397,8 @@ yl_speak_up.action_quest_item_take_back = function(player) -- where to put it or even giving it back and letting the quest fail. if(npc_inv:room_for_item("npc_main", stack)) then npc_inv:add_item("npc_main", stack) + -- save the inventory of the NPC + yl_speak_up.save_npc_inventory(n_id) end -- the NPC has accepted the item trade_inv:set_stack("npc_wants", 1, ItemStack()) @@ -425,6 +427,9 @@ yl_speak_up.input_fs_action_npc_gives = function(player, formname, fields) -- is the npc_gives inv empty? then all went as expected. -- (it does not really matter which button the player pressed in this case) if(trade_inv:is_empty("npc_gives")) then + -- the NPC has given the item to the player; save the NPCs inventory + local n_id = yl_speak_up.speak_to[pname].n_id + yl_speak_up.save_npc_inventory(n_id) -- the action was a success; the NPC managed to give the item to the player yl_speak_up.execute_next_action(player, a_id, true) return