forked from Sokomine/yl_speak_up
allow to close formspec when offering things to the npc via player_offers_item
This commit is contained in:
parent
d5ad680999
commit
c3e048504f
@ -28,6 +28,18 @@ yl_speak_up.input_player_offers_item = function(player, formname, fields)
|
||||
end
|
||||
local pname = player:get_player_name()
|
||||
local trade_inv = minetest.get_inventory({type="detached", name="yl_speak_up_player_"..pname})
|
||||
if(fields.quit) then
|
||||
-- return the items
|
||||
local player_inv = player:get_inventory()
|
||||
local stack = trade_inv:get_stack("npc_wants", 1)
|
||||
if( trade_inv and player_inv:room_for_item("main", stack)) then
|
||||
player_inv:add_item("main", stack)
|
||||
trade_inv:set_stack("npc_wants", 1, "")
|
||||
end
|
||||
-- sometimes players are desperate and just want to leave - allow them to do so
|
||||
yl_speak_up.stop_talking(pname)
|
||||
return
|
||||
end
|
||||
local error_msg = "Please insert the item for the npc and click on \"Give\"!\n"..
|
||||
"If you don't want to give anything, click on \"Back to talk\".]"
|
||||
-- is the npc_wants inv empty and the player pressed the back to talk button?
|
||||
|
@ -1,6 +1,9 @@
|
||||
-- This is the main talkdialog the NPC shows when right-clicked.
|
||||
|
||||
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")
|
||||
|
Loading…
Reference in New Issue
Block a user