# Blackboard Event

## Blackboard Events

{% 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 Events have four values. "Topic", "GameUid", and "Status" are strings, and there is also an Object obj.

{% hint style="success" %}
Note that the strings do not have to be specifically what they are named. You can use these values creatively however you'd like to pass data between objects.
{% endhint %}

Events are great ways to pass data to any object in your project which is looking for them. Objects which follow the **Blackboard** can choose whether to handle the event based on the Topic, GameUid, and Status passed through the event.

```csharp
public string topic; // May often be used to describe the gameUid -- i.e. "ItemObject" or "Stat" or something else you've created
public string gameUid; // Unique in-game identifier of the obj
public string status; // Describes the event that has occurred to the topic
public object obj; // The object itself
```

Any script can add a `BlackboardEvent` to the blackboard, and all those who follow the blackboard will then get a notification of the event. Once an event has been sent, it is removed from the blackboard.

{% code overflow="wrap" %}

```csharp
// Add an event to the Blackboard, with no object. All values can be null or empty.
blackboard.AddEvent(topic, gameUid, status, null);

// An example of receiving an event from the Blackboard
public override void ReceiveEvent(BlackboardEvent blackboardEvent)
{
     // We only care about events we are handling, often defined by the string values in the event.
     if (blackboardEvent.topic != topic
          || blackboardEvent.gameUid != gameUid
          || blackboardEvent.status != status)
     return;

     DoSomethingWith(blackboardEvent);
}
```

{% endcode %}


---

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