. . . Posted May 17, 2018 Share Posted May 17, 2018 (edited) Hello, does someone know how I can check if inst has an item in their inventory or if their inventory is empty, if someone can help with that that'd be great, thanks for your time ! Edited May 17, 2018 by SuperDavid Link to comment https://forums.kleientertainment.com/forums/topic/90896-solved-how-to-check-if-inst-is-inventory-has-an-item-in-inventory-or-if-its-inventory-is-empty/ Share on other sites More sharing options...
RedHairedHero Posted May 17, 2018 Share Posted May 17, 2018 17 hours ago, SuperDavid said: Hello, does someone know how I can check if inst has an item in their inventory or if their inventory is empty, if someone can help with that that'd be great, thanks for your time ! I know there's a few functions in the inventoryitem.lua components you can use to check your inventory. I don't have access to the files at the moment, but I would start there. Link to comment https://forums.kleientertainment.com/forums/topic/90896-solved-how-to-check-if-inst-is-inventory-has-an-item-in-inventory-or-if-its-inventory-is-empty/#findComment-1036071 Share on other sites More sharing options...
. . . Posted May 17, 2018 Author Share Posted May 17, 2018 Thanks for advice RedHairedHero ! I looked and found "inst.components.inventoryitem:IsHeld()" though I don't know how to make it check if there's an item in inst is inventory or if that's what it does, I checked in inventory.lua and this didn't work either "not inst.components.inventory:NumItems(0)" so still need help from anyone smarter than me. Link to comment https://forums.kleientertainment.com/forums/topic/90896-solved-how-to-check-if-inst-is-inventory-has-an-item-in-inventory-or-if-its-inventory-is-empty/#findComment-1036098 Share on other sites More sharing options...
ksaab Posted May 17, 2018 Share Posted May 17, 2018 (edited) Inventory is empty (doesn't check equip slots and backpack), when inst.components.inventory:NumItems() == 0 If you need to check equip slots and backpack: #(inst.components.inventory:ReferenceAllItems()) == 0 If you want to check inventory for an item with specified prefab: inst.components.inventory:Has("prefab", count) For a specified item (inst is the item, owner is the inventory owner): inst.components.inventoryitem:IsHeldBy(owner) Edited May 17, 2018 by ksaab fix Link to comment https://forums.kleientertainment.com/forums/topic/90896-solved-how-to-check-if-inst-is-inventory-has-an-item-in-inventory-or-if-its-inventory-is-empty/#findComment-1036112 Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now