fixed bug with empty list in ipairs issue #8378
This commit is contained in:
parent
1b9df50376
commit
710c8e1928
@ -780,7 +780,7 @@ yl_speak_up.execute_effect = function(player, n_id, o_id, r)
|
||||
local npc_inv = minetest.get_inventory({type="detached",
|
||||
name="yl_speak_up_npc_"..tostring(n_id)})
|
||||
-- put the drops into the inventory of the NPC
|
||||
for i, d in ipairs(drop_list) do
|
||||
for i, d in ipairs(drop_list or {}) do
|
||||
local rest = npc_inv:add_item("npc_main", ItemStack(d))
|
||||
if(rest and not(rest:is_empty()) and rest:get_count()>0) then
|
||||
yl_speak_up.debug_msg(player, n_id, o_id, tostring(r.r_id)..
|
||||
@ -867,7 +867,7 @@ yl_speak_up.execute_effect = function(player, n_id, o_id, r)
|
||||
input.items = {}
|
||||
-- multiple slots in the craft grid may contain the same item
|
||||
local sum_up = {}
|
||||
for i, v in ipairs(r.r_craft_grid) do
|
||||
for i, v in ipairs(r.r_craft_grid or {}) do
|
||||
if(v and v ~= "") then
|
||||
local stack = ItemStack(v)
|
||||
-- store this for later crafting
|
||||
@ -913,7 +913,7 @@ yl_speak_up.execute_effect = function(player, n_id, o_id, r)
|
||||
yl_speak_up.debug_msg(player, n_id, o_id, tostring(r.r_id).." "..
|
||||
"Great: Crafting is possible!")
|
||||
-- actually consume the items required, return the ones in decremented_input
|
||||
for i, v in ipairs(r.r_craft_grid) do
|
||||
for i, v in ipairs(r.r_craft_grid or {}) do
|
||||
if(v and v ~= "") then
|
||||
npc_inv:remove_item("npc_main", ItemStack(v))
|
||||
end
|
||||
@ -925,7 +925,7 @@ yl_speak_up.execute_effect = function(player, n_id, o_id, r)
|
||||
end
|
||||
npc_inv:add_item("npc_main", output.item)
|
||||
-- add the decremented_inputs
|
||||
for k,v in pairs(decremented_input.items) do
|
||||
for k,v in pairs(decremented_input.items or {}) do
|
||||
if(k and not(v:is_empty())) then
|
||||
if(not(npc_inv:room_for_item("npc_main", v))) then
|
||||
yl_speak_up.debug_msg(player, n_id, o_id, tostring(r.r_id).." "..
|
||||
|
@ -74,7 +74,7 @@ yl_speak_up.eval_all_preconditions = function(player, prereq, o_id, other_option
|
||||
-- during this call, so we can cache them
|
||||
local properties = yl_speak_up.get_npc_properties(pname)
|
||||
|
||||
for k, p in pairs(prereq) do
|
||||
for k, p in pairs(prereq or {}) do
|
||||
yl_speak_up.debug_msg(player, n_id, o_id, "..checking "..
|
||||
tostring(p.p_id)..": "..yl_speak_up.show_precondition(p, pname))
|
||||
if(not(yl_speak_up.eval_precondition(player, n_id, p, other_options_true_or_false, properties))) then
|
||||
@ -465,7 +465,7 @@ yl_speak_up.eval_trade_list_preconditions = function(player)
|
||||
for i, s_o_id in ipairs(sorted_o_list) do
|
||||
local prereq = options[s_o_id].o_prerequisites
|
||||
local all_ok = true
|
||||
for k, p in pairs(prereq) do
|
||||
for k, p in pairs(prereq or {}) do
|
||||
if(not(yl_speak_up.eval_precondition_npc_inv(p, inv, inv_name))) then
|
||||
all_ok = false
|
||||
break
|
||||
|
Loading…
Reference in New Issue
Block a user