Jump to content

ItemContainer:isInCharacterInventory() broken?


johndough

Recommended Posts

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()) then

I'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

Well, this:

 

if player:getInventory():contains("BigHikingBag") == false then   player:getInventory():AddItem("Base.BigHikingBag");end

Works 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

 

Well, this:

 

if player:getInventory():contains("BigHikingBag") == false then   player:getInventory():AddItem("Base.BigHikingBag");end

Works 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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...