Skip to reading
Visual Scripting in Depth

38. Build a reusable visual function

Edition 0.86.4.3

0.86.4.3 edition with revised lessons, updated cross-references and new cinematic/camera-safety supplements. Earlier examples, screenshots and registry figures retain their stated edition context.

Download PDFView illustrations

Figure 25. The Award function starts at Change Variable and finishes with Return.

1. Create a Visual Script named Reusable Visual Tools, ID visual_tools.

2. Add Change Variable. Choose score, Operation add, Value {"$param":"amount"}.

3. Add Return with Value {"$param":"amount"}.

4. Connect Change Variable NEXT to Return FLOW.

5. Open Functions as Nodes. Add a function named award, display name Award Workshop Points.

6. Choose the Change Variable node as its entry. Add amount as an int parameter with default 5. Keep Expose checked, then press Use Definitions.

A visual function can begin at an ordinary action node. It does not need an On Interact entry in front of it. The exposed definition supplies the starting node when called.

The amount expression is resolved from the named function parameters. If you run this graph directly without invoking its function definition, that named parameter has not been supplied. Test it through Call Script Function.

Keep the node ID used by the definition valid. Moving or resizing that node is safe. Deleting it requires choosing a replacement entry in the definition.

Page 42 of 93Permalink
Go to page