Jump to content

Recommended Posts

2 hours ago, --- -.- said:

is there a way to check if the player has a container opened

I assume you're trying to check from the player object and not the container.

The inventory component keeps tracks of all open containers in 

inventory.opencontainers

So you could probably just check that. Maybe something like:

for inst in pairs(player.components.inventory.opencontainers) do
	print(player, "has a container of prefab", inst.prefab, "open")
end

 

2 hours ago, --- -.- said:

when the container prefab is?

Most, if not all components keep track of their instance in a "inst" field.

So you can do

-- assuming "container" is a container component
print(container.inst.prefab)

 

  • Like 2

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...