Contact Us

CATEGORIES

Whoops…Nothing found

Try other keywords in your search

Defining an Input Variable

 1 Minute

 0 Likes

 50 Views

When creating your own Actions in Control, you can enter input variables, also called parameters, which will save incoming values for use inside the Action's LUA code.


Basic Input Variables

 

You define the name of the input variable by entering a word between the parenthesis of an Action, as shown below:

 

You can add multiple input variables by separating each name with a comma, there is no limit to this.

myAction(val1, val2, val3, val4, val5)

Input Variable Data

 

Now that named variable can be used inside the Action's body where custom LUA code is written. The data the variable holds will be determined by what it is passed to by another Action connected to its left side in the form of a “wire string” visual.

 

The variable will update with every call sent to this Action, so the example above using the “Time” of the Timeline will update the Action at the same rate the Timeline is updating, so at 60fps by default.

 

To use the variable data in the LUA code of the Action, you just need to use the variable name in-place of the hardcoded value you would use, so if you sent an opacity value to be set on a Timeline you would use this code:

Pixera.Timelines.Timeline.getInst("Timeline 1").setOpacity(variable1)

Ellipsis

 

You can use ellipsis as the last input variable to catch as many values to be placed into a reference list that can then be accessed in the Action's code.

For example, sending an Action “1, 2, 3, 4, 5, 6” that looks like below will save the values 3, 4, 5, and 6 into the “…”:

myAction(val1, val2, ...)

 

From there, you can access the “…” values by storing it into a table using curly brackets:

pixc.log(val1)
pixc.log(val2)

for i, n in pairs({...}) do
	pixc.log(n)
end

 

Ellipsis are useful if wanting to run a call on every input value instead of ignoring extras, or to keep track of data being sent in.


Input Variables with Values

 

To help be more explicit with what should be sent to an Action, all input variables other than ellipsis can be defined with a data type before the name.

By default, native LUA does not require a defined data type for a variable, as it assigns one in the backend based on the data saved in it. However, even if you define a variable with a data type, if a different type is sent to be saved in that variable it will use this type instead. So the ability to enter the data type into the Action is purely documentational.

myAction(string valString, bool valBool, double valDouble, int valInt)

 

PIXERA 2.0.230 | 27. January 2024 | CL

Was this article helpful?