Custom Nodes

Learn how to write custom schematic and formula nodes.

Adding custom nodes to schematics or formulas doesn’t require implementing them in a plugin or Makinom’s source code – you can just add them in a script file in your Unity project.

Base Nodes #

Some basics are valid for schematic and formula nodes.

Information Attributes #

You need to let the editor know some details about the node. this is handled by adding attributes above the class.

EditorHelp #

The EditorHelp attribute is used for the help text of the node and the node’s title/name. The 1st string parameter defines the name, the 2nd defines the description. The 3rd string parameter can be used for additional information, e.g. a link to a website with more details, it can be omitted.

NodeInfo #

The NodeInfo attribute is used to define where the node will be added in the add node selection.

You can add the node to sub-sections by separating them with a / – and you can add multiple sections where the node should be added by using multiple string parameters. E.g.:

This will place the node in Add Node > Section.

This will place the node in Add Node > Section > Sub-Section.

This will place the node in Add Node > Section A and Add Node > Section B.

Editor Functions #

Additionally to the attributes, there are functions that should be implemented in your node to tell the editor the info text and color of the node.

The GetNodeDetails function returns the text that is displayed in the node’s info area. The EditorColor property returns the color that is used to tint the node in the editor.

Additionally, you can create multi-slot nodes by overriding the next slot functions. See the BaseSchematicCheckNode or BaseFormulaCheckNode for examples:

Schematic Nodes #

You can create custom nodes by deriving from the BaseSchematicNode or BaseSchematicCheckNode classes. For examples it’s best to check out the available node implementations.

Deriving from BaseSchematicNode will make it a node with a single Next slot, the connection to the next node is stored in the int field next.

Deriving from BaseSchematicCheckNode (which descends from BaseSchematicNode) will make a node with a Success and a Failed slot – the Success connection is stored in the int field next, the Failed connection is stored in the int field nextFail.

You can also create multi-slot nodes, see below for more details.

Using schematic nodes should use the schematic node namespace.

Or, implement the node in the namespace (not required).

Node Execution #

The most crucial part of the node is the Execute function, which will be used when the node is executed by the schematic. This function will handle whatever you want to do with your node – and it must tell the schematic which node will be executed next.

You can also execute the next node after a wait time by using the StartTime function of the schematic:

The 1st parameter is a float that defines the time in seconds until executing the next node, the 2nd parameter defines the next node’s index (int).

Example #

In total, a node class can look like this:

This node doesn’t do much, though. You can add your settings in the class and do whatever needs to be done in the Execute function.

Please note that your custom node doesn’t need to be in the GamingIsLove.Makinom.Schematics.Nodes namespace, it can be placed in any namespace (or none at all).

Formula Nodes #

You can create custom nodes by deriving from the BaseFormulaNode or BaseFormulaCheckNode classes. For examples it’s best to check out the available node implementations.

Deriving from BaseFormulaNode will make it a node with a single Next slot, the connection to the next node is stored in the int field next.

Deriving from BaseFormulaCheckNode (which descends from BaseFormulaNode) will make a node with a Success and a Failed slot – the Success connection is stored in the int field next, the Failed connection is stored in the int field nextFail.

You can also create multi-slot nodes, see below for more details.

Using formula nodes should use the formula node namespace.

Or, implement the node in the namespace (not required).

Node Calculation #

The most crucial part of the node is the Calculate function, which will be used when the node is executed by the formula. This function will handle whatever you want to do with your node – and it must return which node (index) will be executed next.

To change the current value of the formula, change the call‘s result (float value).

The call also has access user and target of the formula, as well as local variables and selected data.

Example #

In total, a node class can look like this:

This node doesn’t do much, it just adds 1 to the result. You can add your settings in the class and do whatever needs to be done in the Calculate function.

Please note that your custom node doesn’t need to be in the GamingIsLove.Makinom.Formulas.Nodes namespace, it can be placed in any namespace (or none at all).