display and evaluate preconditions of type block_inv
This commit is contained in:
parent
a39d308ebc
commit
f5ceb9b04c
@ -205,18 +205,31 @@ yl_speak_up.show_precondition = function(p, pname)
|
||||
if(nr and check_trade[ nr ]) then
|
||||
return check_trade[ nr ]
|
||||
end
|
||||
elseif(p.p_type == "player_inv" or p.p_type == "npc_inv") then
|
||||
elseif(p.p_type == "player_inv" or p.p_type == "npc_inv" or p.p_type == "block_inv") then
|
||||
local who = "The player"
|
||||
local what = "\""..tostring(p.p_itemstack).."\" in his inventory."
|
||||
if(p.p_type == "npc_inv") then
|
||||
who = "The NPC"
|
||||
elseif(p.p_type == "block_inv") then
|
||||
if(not(p.p_pos) or type(p.p_pos) ~= "table"
|
||||
or not(p.p_pos.x) or not(p.p_pos.y) or not(p.p_pos.z)) then
|
||||
return "ERROR: p.p_pos is "..minetest.serialize(p.p_pos)
|
||||
end
|
||||
who = "The block at "..minetest.pos_to_string(p.p_pos)
|
||||
what = "\""..tostring(p.p_itemstack).."\" in inventory list \""..
|
||||
tostring(p.p_inv_list_name).."\"."
|
||||
end
|
||||
if(p.p_value == "inv_contains") then
|
||||
return who.." has \""..tostring(p.p_itemstack).."\" in his inventory."
|
||||
return who.." has "..what
|
||||
elseif(p.p_value == "inv_does_not_contain") then
|
||||
return who.." does not have \""..tostring(p.p_itemstack).."\" in his inventory."
|
||||
return who.." does not have "..what
|
||||
elseif(p.p_value == "has_room_for") then
|
||||
return who.." has room for \""..tostring(p.p_itemstack).."\" in his inventory."
|
||||
return who.." has room for "..what
|
||||
elseif(p.p_value == "inv_is_empty") then
|
||||
if(p.p_type == "block_inv") then
|
||||
return who.." has an empty inventory list \""..
|
||||
tostring(p.p_inv_list_name).."\"."
|
||||
end
|
||||
return who.." has an empty inventory."
|
||||
end
|
||||
elseif(p.p_type == "custom") then
|
||||
@ -478,16 +491,30 @@ yl_speak_up.eval_precondition = function(player, n_id, p, other_options_true_or_
|
||||
return not(player_inv:contains_item("main", trade.pay[1]))
|
||||
end
|
||||
return false
|
||||
elseif(p.p_type == "player_inv" or p.p_type == "npc_inv") then
|
||||
elseif(p.p_type == "player_inv" or p.p_type == "npc_inv" or p.p_type == "block_inv") then
|
||||
local inv = nil
|
||||
local inv_name = "main"
|
||||
-- determine the right inventory
|
||||
if(p.p_type == "player_inv") then
|
||||
inv = player:get_inventory()
|
||||
else
|
||||
elseif(p.p_type == "npc_inv") then
|
||||
inv = minetest.get_inventory({type="detached",
|
||||
name="yl_speak_up_npc_"..tostring(n_id)})
|
||||
inv_name = "npc_main"
|
||||
elseif(p.p_type == "block_inv") then
|
||||
if(not(p.p_pos) or type(p.p_pos) ~= "table"
|
||||
or not(p.p_pos.x) or not(p.p_pos.y) or not(p.p_pos.z)) then
|
||||
return false
|
||||
end
|
||||
local meta = minetest.get_meta(p.p_pos)
|
||||
if(not(meta)) then
|
||||
return false
|
||||
end
|
||||
inv = meta:get_inventory()
|
||||
if(not(inv)) then
|
||||
return false
|
||||
end
|
||||
inv_name = p.p_inv_list_name
|
||||
end
|
||||
if( p.p_itemstack and p.p_value == "inv_contains") then
|
||||
return inv:contains_item(inv_name, p.p_itemstack)
|
||||
|
Loading…
Reference in New Issue
Block a user