1
0
mirror of https://github.com/tacigar/maidroid.git synced 2024-11-05 09:40:34 +01:00

Add has_item_in_main method

This commit is contained in:
tacigar 2016-12-21 21:18:23 +09:00
parent 4e2074221c
commit 83bcc91db4

View File

@ -161,6 +161,19 @@ function maidroid.maidroid.is_named(self)
return self.nametag ~= "" return self.nametag ~= ""
end end
-- maidroid.maidroid.has_item_in_main reports whether the maidroid has item.
function maidroid.maidroid.has_item_in_main(self, pred)
local inv = self:get_inventory()
local stacks = inv:get_list("main")
for _, stack in ipairs(stacks) do
local itemname = stack:get_name()
if pred(itemname) then
return true
end
end
end
--------------------------------------------------------------------- ---------------------------------------------------------------------
-- maidroid.manufacturing_data represents a table that contains manufacturing data. -- maidroid.manufacturing_data represents a table that contains manufacturing data.
@ -547,6 +560,7 @@ function maidroid.register_maidroid(product_name, def)
get_wield_item_stack = maidroid.maidroid.get_wield_item_stack, get_wield_item_stack = maidroid.maidroid.get_wield_item_stack,
move_main_to_wield = maidroid.maidroid.move_main_to_wield, move_main_to_wield = maidroid.maidroid.move_main_to_wield,
is_named = maidroid.maidroid.is_named, is_named = maidroid.maidroid.is_named,
has_item_in_main = maidroid.maidroid.has_item_in_main,
}) })
-- register maidroid egg. -- register maidroid egg.