Skip to content

The Inventory system

get_inventory_value(id_or_object, key, default=None)

get inventory value with the given key the the agent has this is the way to create a collection in inventory

Parameters:

Name Type Description Default
id_or_obj Agent | int

The agent id or object to check

required
key str

The key/name of the inventory item

required
default any

the default value data

None

Returns: any: The inventory value associated with the provided key, or the default value if it doesn't exist.

get_shared_inventory_value(key, default=None)

Get inventory value from the shared data agent.

Parameters:

Name Type Description Default
key str

The key/name of the inventory item

required
default any

the value to return if not found

None

has_inventory(key)

get the set of agent ids that have a inventory item with the given key

Parameters:

Name Type Description Default
key str

The key/name of the inventory item

required

Returns:

Type Description

set[int]: set of ids

has_inventory_value(key, value)

Get the object that have a inventory item with the given key

Parameters:

Name Type Description Default
key str

The key/name of the inventory item

required

Returns:

Type Description

set[int]: set of ids

inventory_set(source, key)

Get the set that inventory items with the given key the the link source has this is the way to create a collection in inventory

Note

This is like set_inventory_value but the value is a set

Parameters:

Name Type Description Default
source Agent

The agent id or object to check

required
key str

The key/name of the inventory item

required
set[any]

set of data

required

inventory_value(id_or_obj, key, default=None)

Get inventory value with the given key the the agent has. This is the way to create a collection in inventory.

Parameters:

Name Type Description Default
id_or_obj agent

The agent id or object to check

required
key str

The key/name of the inventory item

required
default any

the default value data

None

remove_inventory_value(so, key)

Remove a value from the agent's inventory. so can be a set. If it is, the value is removed from the inventory of each member in the set.

Parameters:

Name Type Description Default
id_or_obj Agent | int | set[Agent | int]

The agent id or object to check

required
key str

The key/name of the inventory item

required
value any

the value

required

set_inventory_value(so, key, value)

Set inventory value with the given key the the agent has. This is the way to create a collection in inventory. so can be a set. If it is, the inventory value is set for each member in the set.

Parameters:

Name Type Description Default
id_or_obj Agent | int | set[Agent | int]

The agent id or object or set to check

required
key str

The key/name of the inventory item

required
value any

the value

required

set_shared_inventory_value(key, value)

Set inventory value with the given key on the shared agent.

Parameters:

Name Type Description Default
key str

The key/name of the inventory item

required
value any

the value

required