Node: Script Function

From Waltz
Revision as of 13:11, 25 July 2019 by Patrick Angle (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

The Script Function node allows you to encapsulate a common Script Expression you use inside a single function. A set of arguments can be provided to the function for processing, and a result can be returned from the function for use by the caller of the function. The function defined by this node can be called with the run(arguments) function defined by this node.

Settings

Expected Type Details Default
argumentNames List<String> Note: This value is not represented by an Expression. A list of named arguments that will be provided to the functionBody.
functionBody Any The body of the function that will be executed when calling the run(arguments) function. The arguments from argumentNames are available to be used in this function. The value returned from the function will either be the result of the last line of script, or the result preceded by the return keyword. No script after the return keyword will be executed. return text.length;

Parameters

Type Details
consumer Consumer<Any> Note: The parameter is read-only. This script function, as a consumer, ready to be used by another function that requires a consumer as its argument. This consumer will have the same number of arguments as this Script Function does, and this script will be executed every time the consumer is used. This is useful to reuse a consumer across multiple situations.

Functions

Argument(s) Type Returns Details
run(arguments) Varargs... of Any Any Calling this function will execute the function body with the provided arguments. Any number of arguments, separated by commas, can be provided but only the first entries with a corresponding entry in argumentNames can be referenced by their name. The returned value will be that value returned by the functionBody, or null if no value can be determined to be the return value or if there was an issue executing the script.

Example Usage

No examples provided.

Nodes
Devices ArtNet Input · ArtNet Output · Interactive LED Processor · NDI™ Input · NDI™ Output · OSC Input · OSC Output · Projector · SensorLink · TCP · TUIO Output · UDP Input · UDP Output · Watchout Media Server
Objects LED Tile Layout · List · Map · Random Number · Simulated Touch · Timer · Value · Wave
Operators Blend · Change · Clip · Cluster Tracker · DMX Multiverse Merge · Ease · Filter · Hold · JSON Mapper · JSON Stringify · Logic · Math · Proximity · Range · Rotate · Scale · Shear · Smooth · Touch Mapper · Translate
Scenes External Scene · Material Scene
Materials Graph · Touch Material
Scripting Script Function · Script
Comments Comment