function itemCheck(item, resultItem, player)local pInv = player:getInventory();local iTab2 ={};--need an empty table later
local dItem;for i =0,(item:size()-1)do--item = number of items required for recipe
dItem = item:get(i);if dItem:getCategory()=="Container"then--if any items in recipe are bags...print("Container detected")if player:getClothingItem_Back()== dItem then--...and are equiped on the back...
player:setClothingItem_Back(nil);endif player:getPrimaryHandItem()== dItem then--...or are equiped primary...
player:setPrimaryHandItem(nil);endif player:getSecondaryHandItem()== dItem then--...or are equiped secondary...
player:setSecondaryHandItem(nil);--remove them from being equipped
end
dInv = dItem:getInventory();--get the inventory of recipe item
dInvItems = dInv:getItems();--get the size of the inventory
if dInvItems:size()>=1then--if container is empty we are finished i.e. less than 1 item
for i2 =0,(dInvItems:size()-1)do--ifnot, iterate over each item
invItem = dInvItems:get(i2);
table.insert(iTab2, invItem)--add each item to empty table
print(invItem:getType());endendendendfor i3, k3 in ipairs(iTab2)doprint(k3:getType()..": removing from container.")
dInv:Remove(k3);--remove items from container in recipe
pInv:AddItem(k3);--add items to player inventory
endend
Try pasting that over Nolan's original code and everything should work. I did some limited testing.
Equiped primary and secondary hand does not work.
And also if the container is not empty.
How to fix it?
Crafting Using Equipped Backpacks
in Help
Posted
Equiped primary and secondary hand does not work.
And also if the container is not empty.
How to fix it?