forked from your-land-mirror/yl_speak_up
give wrong items back or drop at the player's feet
This commit is contained in:
parent
c24cce74b1
commit
706f6d7436
@ -372,15 +372,26 @@ yl_speak_up.action_quest_item_take_back = function(player)
|
||||
if(not(a) or not(a.a_id) or not(a.a_value)) then
|
||||
return false
|
||||
end
|
||||
-- TODO: what to do with the item? it is something wrong...giving it back might be nice
|
||||
if(not(yl_speak_up.action_quest_item_check(player))) then
|
||||
return false
|
||||
end
|
||||
local pname = player:get_player_name()
|
||||
local n_id = yl_speak_up.speak_to[pname].n_id
|
||||
-- get the item that the NPC shall take back (or accept in npc_wants)
|
||||
local trade_inv = minetest.get_inventory({type="detached", name="yl_speak_up_player_"..pname})
|
||||
local stack = trade_inv:get_stack("npc_wants", 1)
|
||||
-- if it was the wrong item:
|
||||
if(not(yl_speak_up.action_quest_item_check(player))) then
|
||||
local player_inv = player:get_inventory()
|
||||
-- give the item back to the player
|
||||
local remaining = player_inv:add_item("main", stack)
|
||||
-- very unlikely - but in case the item did not fit back into the player's inv:
|
||||
if(remaining and not(remaining:is_empty())) then
|
||||
local p = player:get_pos()
|
||||
-- throw it at the player
|
||||
minetest.add_item({x=p.x, y=p.y+1, z=p.z}, stack)
|
||||
end
|
||||
-- remove it from the trade inv slot
|
||||
trade_inv:set_stack("npc_wants", 1, ItemStack())
|
||||
return false
|
||||
end
|
||||
-- we already checked that it is the correct item
|
||||
local meta = stack:get_meta()
|
||||
-- if given: set the item stack description
|
||||
|
Loading…
Reference in New Issue
Block a user