johndough Posted August 16, 2013 Share Posted August 16, 2013 I'm trying to use this to check if a container is either my player's inventory or *in* my player's inventory, but it doesn't seem to be working:if timedAction.destContainer == getPlayer():getInventory() or timedAction.destContainer:isInCharacterInventory(getPlayer()) thenI've seen this being used plenty of times in the timed action code that comes with the game. Link to comment Share on other sites More sharing options...
RegularX Posted August 16, 2013 Share Posted August 16, 2013 TrygetPlayer():getInventory():contains(destContainer) Link to comment Share on other sites More sharing options...
johndough Posted August 16, 2013 Author Share Posted August 16, 2013 TrygetPlayer():getInventory():contains(destContainer) That wouldn't work because destContainer is of type ItemContainer and contains() expects a string or InventoryItem. Link to comment Share on other sites More sharing options...
RegularX Posted August 17, 2013 Share Posted August 17, 2013 Well, this: if player:getInventory():contains("BigHikingBag") == false then player:getInventory():AddItem("Base.BigHikingBag");endWorks to check for the existence of a BigHikingBag, which is also an ItemContainer. If you've created this as an item, I think the relationship goes InventoryItem with an ItemContainer var if the type is Container. I mean, you're not trying to add a fridge to a backpack, right? Link to comment Share on other sites More sharing options...
johndough Posted August 17, 2013 Author Share Posted August 17, 2013 Well, this: if player:getInventory():contains("BigHikingBag") == false then player:getInventory():AddItem("Base.BigHikingBag");endWorks to check for the existence of a BigHikingBag, which is also an ItemContainer. If you've created this as an item, I think the relationship goes InventoryItem with an ItemContainer var if the type is Container. I mean, you're not trying to add a fridge to a backpack, right? That function overload checks for a certain item type - I need to check if a particular ItemContainer is present. Link to comment Share on other sites More sharing options...
RegularX Posted August 17, 2013 Share Posted August 17, 2013 Ah OK. I gotya now. Does:timedAction.destContainer:isInside(getPlayer():getInventory)Work any better? Link to comment Share on other sites More sharing options...
johndough Posted August 17, 2013 Author Share Posted August 17, 2013 Ah OK. I gotya now. Does:timedAction.destContainer:isInside(getPlayer():getInventory)Work any better? That function also expects InventoryItem. Link to comment Share on other sites More sharing options...
RegularX Posted August 18, 2013 Share Posted August 18, 2013 How is your item defined exactly? Link to comment Share on other sites More sharing options...
johndough Posted August 18, 2013 Author Share Posted August 18, 2013 I haven't defined any items; I'm just trying to check wether an arbitrary container object is inside the player's inventory. Link to comment 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