# Blackboard Note

## Blackboard Notes

{% hint style="warning" %}
To receive updates from a Blackboard Note or a Blackboard Event, a script must implement `IFollowBlackboard`, or [inherit from `BlackboardFollower`](/magic-pig-games/game-modules-4/module-documentation/blackboard/blackboard-follower.md).
{% endhint %}

**Blackboard Notes** contain a "Topic" and "Subject", both strings, which are similar to the key in a Dictionary key/value pair. They also contain a selection of data types, including Game Module types like GameItemObject or GameStat.

The Blackboard module allows other objects to follow it, and receive a notification whenever a `BlackboardNote` is added or updated, and when a `BlackboardEvent` is sent. Followers should check to see if the topic and subject are what they are looking for, and if so, handle the new data.

<pre class="language-csharp" data-overflow="wrap"><code class="lang-csharp"><strong>// BlackboardNote.cs
</strong><strong>public string name; // Mostly useful for the inspector
</strong>public string topic; // The broad topic. Examples could be "Kills" or "Dungeon Doors"
public string subject; // The specific subject. Such as "Goblins" or "Crypt" 
public object value;

// General types
public float valueFloat; 
public int valueInt;
public string valueString; 
public bool valueBool;
public GameObject valueGameObject;
        
// Game Module types
public GameStat valueGameStat;
public GameItemObject valueGameItemObject;
public GameItemAttribute valueGameItemAttribute;
public GameCondition valueGameCondition;
public GameQuest valueGameQuest;
public GameLootBox valueGameLootBox;
        
// Game Lists
public GameStatList valueGameStatList;
public GameItemObjectList valueGameItemObjectList;
public GameConditionList valueGameConditionList;
public GameQuestList valueGameQuestList;
</code></pre>

You can `Add()` Blackboard Notes, though it may be more ideal to Update() the note in most cases, as this will automtically add the note if it does not yet exist.

```csharp
// Update a note value, or add it if it doesn't exist
blackboard.UpdateNote("Party", "Distance Travelled", DistanceTravelled, true, true);

// Update a note without sending a notification to followers
blackboard.UpdateNote("Party", "Distance Travelled", DistanceTravelled, true, false);

// Get a note from the Blackboard
blackboard.TryGet(topic, subject, out BlackboardNote note);
Debug.Log($"The int value is {note.valueInt}.");

// Example of receiving a change from the blackboard
public override void ReceiveChange(BlackboardNote blackboardNote)
{
     // We only care about our topic / subject
     if (blackboardNote.topic != topicWeCareAbout 
          || blackboardNote.subject != subjectWeCareAbout) return;

     DoSomethingWith(blackboardNote);
}
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://infinitypbr.gitbook.io/magic-pig-games/game-modules-4/module-documentation/blackboard/blackboard-note.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
