# FRNodeControllable

The FRNodeControllable module allows you to control an external MonoBehaviour script in the scene – which implements the INodeControllable interface – from a node.\
See the demo scene: **NodeModules**

### Example

The simplest way of using this, is by adding the **External Script Controller** node to your graph.\
FlowReactor then shows you all nodes which have the FRNodeControllable module added in the FlowRector Component.

<figure><img src="/files/wXZMZmCJiJo9q87rVy0U" alt=""><figcaption></figcaption></figure>

Next create a new Monobehaviour script and add the **INodeControllable** interface to it like this:

```csharp
// Namespace
using FlowReactor.Nodes.Modules
 
public class ControllableExample : MonoBehaviour, INodeControllable
{
   // Gets called on node initialization
   public void OnNodeInitialize(Node _node)
   {
      Debug.Log("On Initialization");
   }
   
   // Gets called on node execution
   public void OnNodeExecute()
   {
      Debug.Log("On Execute");
   }
 
   // Gets called on node stop execution
   public void OnNodeStopExecute()
   {
     Debug.Log("On Stop Execute");
   }
   
   // Method for manual controllable method calls
   // This requires that the node which has the FRControllableModule to
   // call the method: CallOnNode(_flowRector, this, null);
   public void OnNode(Node _node,  object[] _parameters){}
}
//
```

### INodeControllable interface

<pre class="language-csharp"><code class="lang-csharp"><strong>using System;
</strong>using System.Collections;
using System.Collections.Generic;
using UnityEngine;
 
using FlowReactor;
 
namespace FlowReactor.Nodes.Modules
{
  public interface INodeControllable
  {
    // Automatically called on node initialization
    void OnNodeInitialize(Node _node);
    // Automatically called on node execution
    void OnNodeExecute();
    // Automatically called on node stop execution
    void OnNodeStopExecute();
    // Method for manual controllable method calls
    void OnNode(Node _node, params object[] _parameters);
  }
}
//
</code></pre>

### Add FRNodeControllable to custom node

If you want to implement the FRNodeControllable or any other node module to a custom node, you simply have to create a new instance of the module like this:

```csharp
// Namespace
using FlowReactor.Nodes.Modules;
 
// Create new instance of type FRNodeControllable
FRNodeControllable moduleNodeControllable = new FRNodeControllable();
 
```

Then you can execute the methods in your custom node:

```csharp
//
FRNodeControllable moduleNodeControllable = new FRNodeControllable();
 
// Call OnInitialize method manually
moduleNodeControllable.CallInitializeNode(_flowRector, this);
 
// Call OnNodeExecute method manually
moduleNodeControllable.CallStartExecuteNode(_flowRector, this);
 
// Call OnNodeStopExecute method manually
moduleNodeControllable.CallStopExecuteNode(_flowRector, this);
 
// Call OnNode method manually
moduleNodeControllable.CallOnNode(_flowRector, this, null);
//
```


---

# 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://giantgrey.gitbook.io/flowreactor/in-depth/node-modules/frnodecontrollable.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.
