ExpressionΒΆ

class Expression

An Expression is a Lua scriptable control.

Hierarchy

class Expression < class ControlNode < class HostNode < class Node < class SelectableNode

Members

Plugs:

function Code R The expression compiled code, dependent on Script
nil Invalid R The message plug that dependends on all inputs, and on which all outputs depend
string Script RW The expression Lua code

Methods:

ExpressionInput|ExpressionOutput plug add ( string name , types type , boolean isinput , ? value ) Add an input/output to the Expression
nil setLua ( string script ) Set the expression Lua script


Inherited from class HostNode

Plugs:

types.string HostPath RW The data archive to read HostPlugs value when baked

Methods:

nil deleteinheritedattr ( string plugname ) Delete an inherited attribute plug from the node
nil setinheritedattr ( string plugname , [bool|nil] inherited , [ any value ] ) Set the inheritance status of the attribute
nil overrideinheritedattr ( string plugname , any value ) Override the attribute


Inherited from class Node

Plugs:

string Name RW The node name

Methods:

nil onpathchanged ( ) Called by the framework when the name of this node or of one of its parent is modified
any value eval ( Plug plug ) Called by the framework when plug (a node's plug) must be evaluated
boolean state isselected ( ) Tell if the node is selected
Node parent getparent ( ) Get the parent Node of this Node
boolean result isparent ( Node child ) Tells if this node is parent of the potential child
Node parent findparent ( string name ) Find the first parent Node of this Node of a specific class
string path getpath ( ) Returns the node path as a string that can be reused with findchild
Node|Plug child findchild ( string path ) Find a child node or plug using a path
nil move ( Node parent ) Move a node to a new parent
nil delete ( ) Delete a node
nil rename ( string name ) Rename a node
[string|number] name getname ( ) Get the Node name in its parent
Node result getchild ( string name ) Get a child node by its name
boolean result isreference ( ) Tells if a node comes from a reference project
Reference reference getreference ( ) Returns the reference node it is connected to
Reference reference gettopreference ( ) Returns the top reference node it is connected to
bool result belongstoreference ( Reference ref ) Tells if the node belongs to the reference, or a sub reference
{Node} result loadfile ( string filename , [ table options ] ) load a file content in this node. Possible options are: overrideclass to enforce a specific class for the root node.
ReferenceBase refnode referencefile ( string name , string refpath , [ table options ] ) reference a file content in this node.
Node result loadtemplate ( string template , string name ) load a template file
bool,string success,error savefile ( string filename ) load a node to a file
string result getstringcopy ( ) Return a copy of the node and its content as a string to be pasted
nil setflags ( ) Set the node flags
bool result ismoveable ( ) Tells if the node can be moved
{Node},string result,error pastestringcopy ( string copy , [ {} options ] ) Paste a string copy into this node
of table getreferences ( [ topref Reference ] ) Returns the references in the document sorted depth first.
boolean editable iseditable ( ) Indicates if the node can be edited by the user in the UI
nil seteditable ( boolean editable ) Change the editable state of the node
boolean indocument isindocument ( ) Tells if the node is inside a document, or is pending in the void


Inherited from class SelectableNode

Plugs:

boolean Selected R True if the node is selected. Don't use this plug directly to select a node, use the Document's modifier select method.

Documentation

function Code R

The expression compiled code, dependent on Script


nil Invalid R

The message plug that dependends on all inputs, and on which all outputs depend


string Script RW

The expression Lua code

An Expression code is a Lua script that evaluates its output values using its input values. The Expression evaluation is dependent only on its inputs, meaning that if you use other values than declared inputs in your script, you might have invalidation problems.

Within the script context, inputs are accessible directly by their names, and output are also accessible by their names. For instance: Output = Input * 2 is a valid script, where Output and Input have been declared earlier (that is, added as ExpressionInput and ExpressionOutput to the Expression node).

On the other hand, Output = Document.Time:get ()*0.1 is a syntaxically correct script, though Guerilla won't recompute Output value when time changes. To do such a thing, you must first create an ExpressionInput (Time, for instance), and then Time will be available within the script.


ExpressionInput|ExpressionOutput plug add ( string name , types type , boolean isinput , ? value )

Add an input/output to the Expression

Creates an input/output to the Expression. This method fails if a plug of the same name already exists in the Expression.

Here an example of how to use Expression:

local mod = Document:modify ()
local expression = mod.createnode (Document, "Expression""MyExpression")
local input = expression:add ("Value1", types.string, true"")
local output = expression:add ("Output", types.string)
expression:setLua ("Output = 'Output value is : ' .. Value")
mod.finish ()

To remove an input or an output, simply use modifier.deleteplug function.

local mod = Document:modify ()
mod.deleteplug (expression.Value1)
mod.finish ()
Arguments:

  • name The input/output name
  • type the type of the input/output
  • isinput True to create an input
  • value The default value to assign to the input

Return:

  • plug


nil setLua ( string script )

Set the expression Lua script

Arguments:

  • script a Lua script