A game about forced loneliness, made by TACStudios
1# Script Graph nodes
2
3Visual scripting has four nodes that you can use to identify and manipulate the Script Graphs assigned to a GameObject and its Script Machines:
4
5- [Set Script Graph](#SetScript)
6- [Has Script Graph](#HasScript)
7- [Get Script Graph](#GetScript)
8- [Get Script Graphs](#GetScripts)
9
10## <a name="SetScript">Set Script Graph</a>
11
12You can use the Set Script Graph node to assign a Script Graph to a specific Script Machine, or to the first Script Machine attached to a specific GameObject.
13
14
15
16<table>
17<thead>
18<tr>
19<th colspan="2"><strong>Item</strong></th>
20<th><strong>Description</strong></th>
21</tr>
22</thead>
23<tbody>
24<tr>
25<td colspan="2"><strong>Node Parameters</strong></td>
26<td></td>
27</tr>
28<tr>
29<td><img src="images\Label-A.png" alt="The letter A in a blue circle, matching the label on the Set Script Graph node image."></td>
30<td><strong>Container Type</strong></td>
31<td>Specifies whether the <b>Target</b> is a GameObject or Script Machine.</td>
32</tr>
33<tr>
34<td colspan="2"><strong>Input Ports</strong></td>
35<td></td>
36</tr>
37<tr>
38<td><img src="images\Label-B.png" alt="The letter B in a blue circle, matching the label on the Set Script Graph node image."></td>
39<td><strong>Enter</strong></td>
40<td>(Input Trigger) The execution input trigger for the node.</td>
41</tr>
42<tr>
43<td><img src="images\Label-C.png" alt="The letter C in a blue circle, matching the label on the Set Script Graph node image."></td>
44<td><strong>Target</strong></td>
45<td>(GameObject or Script Machine) The GameObject or Script Machine where the node sets the <b>Graph</b>.</td>
46</tr>
47<tr>
48<td><img src="images\Label-D.png" alt="The letter D in a blue circle, matching the label on the Set Script Graph node image."></td>
49<td><strong>Graph</strong></td>
50<td>(Script Graph Asset) The Script Graph the node sets on the <b>Target</b>.</td>
51</tr>
52<tr>
53<td colspan="2"><strong>Output Ports</strong></td>
54<td></td>
55</tr>
56<tr>
57<td><img src="images\Label-E.png" alt="The letter E in a blue circle, matching the label on the Set Script Graph node image."></td>
58<td><strong>Exit</strong></td>
59<td>(Output Trigger) The execution output trigger.</td>
60</tr>
61<tr>
62<td><img src="images\Label-F.png" alt="The letter F in a blue circle, matching the label on the Set Script Graph node image."></td>
63<td><strong>Graph</strong></td>
64<td>(Script Graph Asset; Optional) Outputs the <b>Graph</b>.</td>
65</tr>
66</tbody>
67</table>
68
69### Setting the required node parameters and inputs
70
71The Set Script Graph node has one required input parameter, called **Container Type**, which is set using the dropdown in the node's header. The **Container Type** specifies what component type the node should expect as an input for its **Target**:
72
73- If you choose **GameObject**, the node expects to receive a GameObject, and assigns the graph to the first Script Machine attached to that GameObject.
74
75- If you choose **Script Machine**, the node expects to receive a Script Machine, and you can specify the exact Script Machine where you want to set your Script Graph.
76
77Depending on which **Container Type** you select, the icon displayed next to the **Target** input port on the node changes:
78
79| **Container Type** | **Target Icon** |
80| :--- | :--- |
81| __GameObject__ | |
82| __Script Machine__ | |
83
84The node has three input ports, located on the left side. The first port, **Enter**, connects to the node that should start the execution of the Set Script Graph node.
85
86The other two ports collect the Set Script Graph node's required input data:
87
88- The **Target**, or the GameObject or Script Machine where you want to set a Script Graph.
89
90- The **Graph**, or the Script Graph to assign to the GameObject or Script Machine.
91
92### Outputs
93
94The Set Script Graph node has two output ports, located on the right side.
95
96The first port, **Exit**, establishes the connection to the node that should execute after the Set Script Graph node has finished.
97
98The second port, **Graph**, can output the Script Graph that you assigned using the node.
99
100## <a name="HasScript">Has Script Graph</a>
101
102The Has Script Graph node allows you to determine whether a GameObject or Script Machine has a specific Script Graph assigned to it.
103
104
105
106<table>
107<thead>
108<tr>
109<th colspan="2"><strong>Item</strong></th>
110<th><strong>Description</strong></th>
111</tr>
112</thead>
113<tbody>
114<tr>
115<td colspan="2"><strong>Node Parameters</strong></td>
116<td></td>
117</tr>
118<tr>
119<td><img src="images\Label-A.png" alt="The letter A in a blue circle, matching the label on the Set Script Graph node image."></td>
120<td><strong>Container Type</strong></td>
121<td>Specify whether the <b>Target</b> is a GameObject or Script Machine.</td>
122</tr>
123<tr>
124<td colspan="2"><strong>Input Ports</strong></td>
125<td></td>
126</tr>
127<tr>
128<td><img src="images\Label-B.png" alt="The letter B in a blue circle, matching the label on the Set Script Graph node image."></td>
129<td><strong>Enter</strong></td>
130<td>(Input Trigger) The execution input trigger for the node.</td>
131</tr>
132<tr>
133<td><img src="images\Label-C.png" alt="The letter C in a blue circle, matching the label on the Set Script Graph node image."></td>
134<td><strong>Target</strong></td>
135<td>(GameObject or Script Machine) The GameObject or Script Machine where the node should check for the <b>Graph</b>.</td>
136</tr>
137<tr>
138<td><img src="images\Label-D.png" alt="The letter D in a blue circle, matching the label on the Set Script Graph node image."></td>
139<td><strong>Graph</strong></td>
140<td>(Script Graph Asset) The Script Graph to search for on the GameObject or Script Machine.</td>
141</tr>
142<tr>
143<td colspan="2"><strong>Output Ports</strong></td>
144<td></td>
145</tr>
146<tr>
147<td><img src="images\Label-E.png" alt="The letter E in a blue circle, matching the label on the Set Script Graph node image."></td>
148<td><strong>Exit</strong></td>
149<td>(Output Trigger) The execution output trigger, which starts execution of the next node in the flow after checking for the specified Script Graph.</td>
150</tr>
151<tr>
152<td><img src="images\Label-F.png" alt="The letter F in a blue circle, matching the label on the Set Script Graph node image."></td>
153<td><strong>Has Graph</strong></td>
154<td>(Boolean) Outputs <code>true</code> if the node found the specified Script Graph, <code>false</code> if not.</td>
155</tr>
156</tbody>
157</table>
158
159### Setting the required node parameters and inputs
160
161The Has Script Graph node has one required input parameter, called **Container Type**, which is set using the dropdown in the node's header. The **Container Type** specifies what component type the node should expect as an input for its **Target**:
162
163- If you choose **GameObject**, the node expects to receive a GameObject, and checks for the graph on the first Script Machine attached to that GameObject.
164
165- If you choose **Script Machine**, the node expects to receive a Script Machine, and you can specify the exact Script Machine where you want to check for the Script Graph.
166
167Depending on which **Container Type** you select, the icon displayed next to the **Target** input port on the node changes:
168
169| **Container Type** | **Target Icon** |
170| :--- | :--- |
171| __GameObject__ | |
172| __Script Machine__ | |
173
174The node has three input ports, located on the left side. The first port, **Enter**, connects to the node that should start the execution of the Has Script Graph node.
175
176The other two ports collect the Has Script Graph node's required input data:
177
178- The **Target**, or the GameObject or Script Machine where you want to check for a Script Graph.
179
180- The **Graph**, or the Script Graph to search for on the GameObject or Script Machine.
181
182### Outputs
183
184The Has Script Graph node returns `true` if it finds the specified Script Graph. Otherwise, it returns `false`.
185
186You can use a control node connected to the Has Script Graph's output port to change what your script does next, based on the result from Has Script Graph. For more information about control nodes, see [Control nodes](vs-control.md).
187
188## <a name="GetScript">Get Script Graph</a>
189
190The Get Script Graph node returns the first Script Graph set on a GameObject.
191
192
193
194<table>
195<thead>
196<tr>
197<th colspan="2"><strong>Item</strong></th>
198<th><strong>Description</strong></th>
199</tr>
200</thead>
201<tbody>
202<td colspan="2"><strong>Input Ports</strong></td>
203<td></td>
204</tr>
205<tr>
206<td><img src="images\Label-A.png" alt="The letter A in a blue circle, matching the label on the Set Script Graph node image."></td>
207<td><strong>GameObject</strong></td>
208<td>(GameObject) The GameObject where the node should retrieve a set Script Graph.</td>
209</tr>
210<tr>
211<td colspan="2"><strong>Output Ports</strong></td>
212<td></td>
213</tr>
214<tr>
215<td><img src="images\Label-B.png" alt="The letter B in a blue circle, matching the label on the Set Script Graph node image."></td>
216<td><strong>Graph</strong></td>
217<td>(Script Graph Asset) Outputs the first or only Script Graph set on the GameObject, or null if there is no set Script Graph.</td>
218</tr>
219</tbody>
220</table>
221
222### Setting the required node parameters and inputs
223
224The Get Script Graph node is a data node. It can't control any logic in your script, and is only used to return data.
225
226The node has a single input port, located on the left side, which collects the node's required input data:
227
228- The GameObject where the node should retrieve the Script Graph. You can choose a specific GameObject, or leave the default selection as **This** to use the GameObject where your script is currently running.
229
230
231### Outputs
232
233The Get Script Graph node has a single output port, located on the right side. The output port returns the GameObject's first set Script Graph, or `null`, if there is no set Script Graph.
234
235> [!NOTE]
236> The Get Script Graph node returns only the first Script Graph set on a GameObject. To return all Script Graphs set on a GameObject, use the [Get Script Graphs node](#GetScripts).
237
238## <a name="GetScripts">Get Script Graphs</a>
239
240The Get Script Graphs node returns a list of all Script Graphs set on a GameObject.
241
242
243
244<table>
245<thead>
246<tr>
247<th colspan="2"><strong>Item</strong></th>
248<th><strong>Description</strong></th>
249</tr>
250</thead>
251<tbody>
252<td colspan="2"><strong>Input Ports</strong></td>
253<td></td>
254</tr>
255<tr>
256<td><img src="images\Label-A.png" alt="The letter A in a blue circle, matching the label on the Set Script Graph node image."></td>
257<td><strong>GameObject</strong></td>
258<td>(GameObject) The GameObject where the node should retrieve a list of set Script Graphs.</td>
259</tr>
260<tr>
261<td colspan="2"><strong>Output Ports</strong></td>
262<td></td>
263</tr>
264<tr>
265<td><img src="images\Label-B.png" alt="The letter B in a blue circle, matching the label on the Set Script Graph node image."></td>
266<td><strong>Graphs</strong></td>
267<td>(List of Script Graph Assets) Outputs a list of all Script Graphs set on the GameObject, or an empty list if there are no set Script Graphs.</td>
268</tr>
269</tbody>
270</table>
271
272### Setting the required node parameters and inputs
273
274The Get Script Graphs node is a data node. It can't control any logic in your script, and is only used to return data.
275
276The node has a single input port, located on the left side, which collects the node's required input data:
277
278- The GameObject where the node should retrieve a list of Script Graphs. You can choose a specific GameObject, or leave the default selection as **This** to use the GameObject where your script is currently running.
279
280### Outputs
281
282The Get Script Graphs node has a single output port, located on the right side. The output port returns a list of all set Script Graphs for the GameObject, or an empty list, if there are no set Script Graphs.