Scripting: Functions

From Waltz
Jump to navigation Jump to search

Functions are pieces of code that you can execute by calling them. They sometimes require parameters to perform their function, and sometimes return a value back from their execution.

A Color object, for example has a method called brighter than can be called with the following syntax:

Color(92, 92, 92).brighter();

Notice that even though there are no parameters required by the brighter function, the opening and closing parenthesis are still required. The brighter function in this example is returning a Color object that is brighter than the Color upon which the function was called.

Nodes also can provide functions. The OSC Output Node, for example, provides a send function that takes a value that you want to send via OSC and uses the properties of that node to send the value, as in the following example:


In this example, we send a single parameter, 99, to the destination OSC device that the node already defined. There is not return value from this function.

Expressions and Scripting
Concepts Script Expressions · JavaScript
Fundamentals Constructors · Functions · Grammar · Operations · Outputs · Parameters · Referencing Nodes
Advanced Topics Flow Control · Consumer Functions · Loops and Iterations · Reference Chains
Errors Recursion · Script Exceptions · Syntax Errors · Try and Catch