Expression¶
-
class
guerilla.
Expression
¶ Bases:
guerilla.ControlNode
,guerilla.HostNode
An Expression is a Lua scriptable control.
-
Code
¶ The expression compiled code, dependent on Script
Type: function
-
Script
¶ The expression Lua code
An Expression code is a Lua script that evaluates its output valuesusing 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.
type: str
-
add
(name, type, 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: LUA{ 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. LUA{ local mod = Document:modify () mod.deleteplug (expression.Value1) mod.finish () }
param name: The input/output name type name: str param type: the type of the input/output type type: types param isinput: True to create an input type isinput: bool param value: The default value to assign to the input type value: ? rtype: ExpressionInput
orExpressionOutput
-