:github_url: hide

.. DO NOT EDIT THIS FILE!!!
.. Generated automatically from Godot engine sources.
.. Generator: https://github.com/godotengine/godot/tree/4.3/doc/tools/make_rst.py.
.. XML source: https://github.com/godotengine/godot/tree/4.3/modules/limboai/doc_classes/Blackboard.xml.

.. _class_Blackboard:

Blackboard
==========

**Inherits:** 

A key/value storage for sharing among :ref:`LimboHSM<class_LimboHSM>` states and :ref:`BehaviorTree<class_BehaviorTree>` tasks.

.. rst-class:: classref-introduction-group

Description
-----------

Blackboard is where data is stored and shared between states in the :ref:`LimboHSM<class_LimboHSM>` system and tasks in a :ref:`BehaviorTree<class_BehaviorTree>`. Each state and task in the :ref:`BehaviorTree<class_BehaviorTree>` can access this Blackboard, allowing them to read and write data. This makes it easy to share information between different actions and behaviors.

Blackboard can also act as a parent scope for another Blackboard. If a specific variable is not found in the active scope, it looks in the parent Blackboard to find it. A parent Blackboard can itself have its own parent scope, forming what we call a "blackboard scope chain." Importantly, there is no limit to how many Blackboards can be in this chain, and the Blackboard doesn't modify values in the parent scopes.

New scopes can be created using the :ref:`BTNewScope<class_BTNewScope>` and :ref:`BTSubtree<class_BTSubtree>` decorators. Additionally, a new scope is automatically created for any :ref:`LimboState<class_LimboState>` that has defined non-empty Blackboard data or for any root-level :ref:`LimboHSM<class_LimboHSM>` node.

.. rst-class:: classref-reftable-group

Methods
-------

.. table::
   :widths: auto

   +---------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
   | |void|                                      | :ref:`bind_var_to_property<class_Blackboard_method_bind_var_to_property>`\ (\ var_name\: ``StringName``, object\: ``Object``, property\: ``StringName``, create\: ``bool`` = false\ )               |
   +---------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
   | |void|                                      | :ref:`clear<class_Blackboard_method_clear>`\ (\ )                                                                                                                                                   |
   +---------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
   | |void|                                      | :ref:`erase_var<class_Blackboard_method_erase_var>`\ (\ var_name\: ``StringName``\ )                                                                                                                |
   +---------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
   | :ref:`Blackboard<class_Blackboard>`         | :ref:`get_parent<class_Blackboard_method_get_parent>`\ (\ ) |const|                                                                                                                                 |
   +---------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
   | ``Variant``                                 | :ref:`get_var<class_Blackboard_method_get_var>`\ (\ var_name\: ``StringName``, default\: ``Variant`` = null, complain\: ``bool`` = true\ ) |const|                                                  |
   +---------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
   | ``Dictionary``                              | :ref:`get_vars_as_dict<class_Blackboard_method_get_vars_as_dict>`\ (\ ) |const|                                                                                                                     |
   +---------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
   | ``bool``                                    | :ref:`has_var<class_Blackboard_method_has_var>`\ (\ var_name\: ``StringName``\ ) |const|                                                                                                            |
   +---------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
   | |void|                                      | :ref:`link_var<class_Blackboard_method_link_var>`\ (\ var_name\: ``StringName``, target_blackboard\: :ref:`Blackboard<class_Blackboard>`, target_var\: ``StringName``, create\: ``bool`` = false\ ) |
   +---------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
   | :ref:`Array<class_Array>`\[``StringName``\] | :ref:`list_vars<class_Blackboard_method_list_vars>`\ (\ ) |const|                                                                                                                                   |
   +---------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
   | |void|                                      | :ref:`populate_from_dict<class_Blackboard_method_populate_from_dict>`\ (\ dictionary\: ``Dictionary``\ )                                                                                            |
   +---------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
   | |void|                                      | :ref:`set_parent<class_Blackboard_method_set_parent>`\ (\ blackboard\: :ref:`Blackboard<class_Blackboard>`\ )                                                                                       |
   +---------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
   | |void|                                      | :ref:`set_var<class_Blackboard_method_set_var>`\ (\ var_name\: ``StringName``, value\: ``Variant``\ )                                                                                               |
   +---------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
   | :ref:`Blackboard<class_Blackboard>`         | :ref:`top<class_Blackboard_method_top>`\ (\ ) |const|                                                                                                                                               |
   +---------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
   | |void|                                      | :ref:`unbind_var<class_Blackboard_method_unbind_var>`\ (\ var_name\: ``StringName``\ )                                                                                                              |
   +---------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+

.. rst-class:: classref-section-separator

----

.. rst-class:: classref-descriptions-group

Method Descriptions
-------------------

.. _class_Blackboard_method_bind_var_to_property:

.. rst-class:: classref-method

|void| **bind_var_to_property**\ (\ var_name\: ``StringName``, object\: ``Object``, property\: ``StringName``, create\: ``bool`` = false\ ) :ref:`🔗<class_Blackboard_method_bind_var_to_property>`

Establish a binding between a variable and the object's property specified by ``property`` and ``object``. Changes to the variable update the property, and vice versa. If ``create`` is ``true``, the variable will be created if it doesn't exist.

.. rst-class:: classref-item-separator

----

.. _class_Blackboard_method_clear:

.. rst-class:: classref-method

|void| **clear**\ (\ ) :ref:`🔗<class_Blackboard_method_clear>`

Removes all variables from the Blackboard. Parent scopes are not affected.

.. rst-class:: classref-item-separator

----

.. _class_Blackboard_method_erase_var:

.. rst-class:: classref-method

|void| **erase_var**\ (\ var_name\: ``StringName``\ ) :ref:`🔗<class_Blackboard_method_erase_var>`

Removes a variable by its name.

.. rst-class:: classref-item-separator

----

.. _class_Blackboard_method_get_parent:

.. rst-class:: classref-method

:ref:`Blackboard<class_Blackboard>` **get_parent**\ (\ ) |const| :ref:`🔗<class_Blackboard_method_get_parent>`

Returns a Blackboard that serves as the parent scope for this instance.

.. rst-class:: classref-item-separator

----

.. _class_Blackboard_method_get_var:

.. rst-class:: classref-method

``Variant`` **get_var**\ (\ var_name\: ``StringName``, default\: ``Variant`` = null, complain\: ``bool`` = true\ ) |const| :ref:`🔗<class_Blackboard_method_get_var>`

Returns variable value or ``default`` if variable doesn't exist. If ``complain`` is ``true``, an error will be printed if variable doesn't exist. If the variable doesn't exist in the current **Blackboard** scope, it will look in the parent scope **Blackboard** to find it.

.. rst-class:: classref-item-separator

----

.. _class_Blackboard_method_get_vars_as_dict:

.. rst-class:: classref-method

``Dictionary`` **get_vars_as_dict**\ (\ ) |const| :ref:`🔗<class_Blackboard_method_get_vars_as_dict>`

Returns all variables in the Blackboard as a dictionary. Keys are the variable names, values are the variable values. Parent scopes are not included.

.. rst-class:: classref-item-separator

----

.. _class_Blackboard_method_has_var:

.. rst-class:: classref-method

``bool`` **has_var**\ (\ var_name\: ``StringName``\ ) |const| :ref:`🔗<class_Blackboard_method_has_var>`

Returns ``true`` if the Blackboard contains the ``var_name`` variable, including the parent scopes.

.. rst-class:: classref-item-separator

----

.. _class_Blackboard_method_link_var:

.. rst-class:: classref-method

|void| **link_var**\ (\ var_name\: ``StringName``, target_blackboard\: :ref:`Blackboard<class_Blackboard>`, target_var\: ``StringName``, create\: ``bool`` = false\ ) :ref:`🔗<class_Blackboard_method_link_var>`

Links a variable to another Blackboard variable. If a variable is linked to another variable, their state will always be identical, and any change to one will be reflected in the other. If ``create`` is ``true``, the variable will be created if it doesn't exist.

You can use this method to link a variable in the current scope to a variable in another scope, or in another Blackboard instance. A variable can only be linked to one other variable. Calling this method again will overwrite the previous link. However, it is possible to link to the same variable from multiple different variables.

.. rst-class:: classref-item-separator

----

.. _class_Blackboard_method_list_vars:

.. rst-class:: classref-method

:ref:`Array<class_Array>`\[``StringName``\] **list_vars**\ (\ ) |const| :ref:`🔗<class_Blackboard_method_list_vars>`

Returns all variable names in the Blackboard. Parent scopes are not included.

.. rst-class:: classref-item-separator

----

.. _class_Blackboard_method_populate_from_dict:

.. rst-class:: classref-method

|void| **populate_from_dict**\ (\ dictionary\: ``Dictionary``\ ) :ref:`🔗<class_Blackboard_method_populate_from_dict>`

Fills the Blackboard with multiple variables from a dictionary. The dictionary keys must be variable names and the dictionary values must be variable values. Keys must be StringName or String.

.. rst-class:: classref-item-separator

----

.. _class_Blackboard_method_set_parent:

.. rst-class:: classref-method

|void| **set_parent**\ (\ blackboard\: :ref:`Blackboard<class_Blackboard>`\ ) :ref:`🔗<class_Blackboard_method_set_parent>`

Assigns the parent scope. If a value isn't in the current Blackboard scope, it will look in the parent scope Blackboard to find it.

.. rst-class:: classref-item-separator

----

.. _class_Blackboard_method_set_var:

.. rst-class:: classref-method

|void| **set_var**\ (\ var_name\: ``StringName``, value\: ``Variant``\ ) :ref:`🔗<class_Blackboard_method_set_var>`

Assigns a value to a variable in the current Blackboard scope. If the variable doesn't exist, it will be created. If the variable already exists in the parent scope, the parent scope value will NOT be changed.

.. rst-class:: classref-item-separator

----

.. _class_Blackboard_method_top:

.. rst-class:: classref-method

:ref:`Blackboard<class_Blackboard>` **top**\ (\ ) |const| :ref:`🔗<class_Blackboard_method_top>`

Returns the topmost **Blackboard** in the scope chain.

.. rst-class:: classref-item-separator

----

.. _class_Blackboard_method_unbind_var:

.. rst-class:: classref-method

|void| **unbind_var**\ (\ var_name\: ``StringName``\ ) :ref:`🔗<class_Blackboard_method_unbind_var>`

Remove binding from a variable.

.. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
.. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
.. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
.. |constructor| replace:: :abbr:`constructor (This method is used to construct a type.)`
.. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`
.. |operator| replace:: :abbr:`operator (This method describes a valid operator to use with this type as left-hand operand.)`
.. |bitfield| replace:: :abbr:`BitField (This value is an integer composed as a bitmask of the following flags.)`
.. |void| replace:: :abbr:`void (No return value.)`
