Contact Us

CATEGORIES

Whoops…Nothing found

Try other keywords in your search

Expanding Your Actions

 6 Minutes

 0 Likes

 3 Views

Actions can execute whole programs and control many different things at once.

There are two tools in Control for defining the functionality of an Action. The first one is the Scripting IDE which support LUA as a scripting language.

The second one is the Block Builder, which is a graphical representation of the Scripting IDE. Instead of writing code, blocks of commands can be connected with each other to define the behavior of the Action. It allows a fast realization of simple tasks, but is usually not sufficient for advanced projects.


Scripting Text Editor and Block Builder

 

To open the Scripting IDE (Text Editor), click on the Action. On the right side in the inspector will be the IDE. This view is for LUA scripting mentioned later. To get to the Block Builder, click on the “text” symbol in the top right corner.

Also note below the symbol to the right of the Block Builder symbol is to save your changes, use this or Ctrl + S to save what you create in this article.


How to Pause a Timeline Using the Block Builder

 

Below is an example on how to pause a Timeline using the Block Builder:

First Create a new Module with an Action called “pause()”, then select the Action and open the Block Builder. Click on the “+” sign to create a new command, choose: “Pixera → Timelines → Timeline 1 → pause”.

 

This setup does basically the same as drawing a wire from your Action to the “Pixera” Module and connecting it to the “pause” Action of the Timeline.

To test your new Action, press the arrow next to the Action name to run it.


Using Conditions in the Block Builder

 

Sometimes, instead of manually triggering a call, you need an event to occur which will then trigger the call once it occurs. This can be realized by using conditions. The easiest one is the “if”-statement. It will execute the next command if its condition has been fulfilled.

To create a Condition, right click onto the plus symbol and select “Add Condition”.

The text field on the right with “true” defines the condition. The “double equal” symbol means “expression on the left is equal to expression on the right”. Currently the “expression on the left” is not defined. Click on the arrow to add it.


In this case, we want to get information from the Timeline and choose the transport mode. The transport mode tells us if the Timeline is currently playing, is paused, or stopped.

 

The transport mode can have three values:

  • Play = 1.0
  • Pause = 2.0
  • Stop = 3.0

The current condition will execute the next command if the transport mode is playing. To define this conditional command, press on the indented plus symbol.

 

If the command is executed, then the Timeline must be currently playing, in which case it should then be paused. Therefore, the "pause" Action of the Timeline is called.


LUA Scripting Actions


Most projects can be realized using only the Block Builder, but there are some situations where this tool finds its limits.

Scripts inside Actions are written in LUA, a lightweight programming language comparable to Python. Thus, complex projects can be realized in a quick and straightforward manner. Users can manually enter LUA code into Actions alongside API calls to create their own functionality.

Traditionally the first thing to do when learning a new programming language is displaying “Hello World!” on the screen. In order do show this example, you must first open the Log which is used to monitor the execution of your project. Data from your Actions (e.g., warnings and errors) are shown in the Log. To open it, press “Show Log” in the upper right corner above the workspace. You can choose the position of the Log on the screen.

 

Create a new Module with an Action named “HelloWorld()”, then open the Scripting IDE and type the following line into the editor: 

pixc.log("Hello World!")

 

“pixc” allows you to interact with other aspects of Control such as the Log, this line will send the text inside to the Log.

Save your code by clicking on the save symbol in the IDE:

 

When executed, the Action will display the line “Hello World!” in the Log.


How to Stop a Timeline Using the Scripting IDE

 

Create a new Module with an Action called “stop()”, then open the Scripting IDE and write the following line into the editor:

Pixera.Timelines.getTimelineAtIndex(0).stop()

 

Going over this line and what it means, at first the “Pixera” Module is being called, the Timeline folder is being opened, and a Timeline is being chosen.

For choosing a Timeline, the “getTimelineAtIndex(0)” is used which will return the Timeline at index zero, index zero is always the top Timeline.

Then “stop()” is being called on this Timeline, and the Action is finished. Save your code in the Scripting IDE and run the Action to test.


How to Play or Pause a Timeline Using the Scripting IDE


Moving to a slightly advanced example, here you will learn how to play or pause the Timeline when running the Action depending on if it is currently playing or is paused. In this case, Conditions again must be used.

Create a new Module with an Action named “playPause()”, then open the Scripting IDE.

First, the current transport mode of the Timeline must be found to know its state. Since this information will be used a few times, this example will save save the data in a variable called “mode”:

local mode = Pixera.Timelines.getTimelineAtIndex(0).getTransportMode()

 

The keyword “local” before the variable name means that it is only valid in the current Action. If you don’t use it, you’ll be able to use this variable in every Action inside this Module. This can be helpful but will often lead to problems, for instance, if you create a variable of the same name in another Action.

Next is the first condition: “If Timeline is playing then pause it”. For which you would use the following line:

if mode == 1.00 then
   Pixera.Timelines.getTimelineAtIndex(0).pause()

 

If this is not the case, the Timeline is paused or stopped, and you will want to play it. This means a command must be used that says: “Else play the Timeline”. Which looks like this:

else
   Pixera.Timelines.getTimelineAtIndex(0).play()
end

 

Please note that each “if”-statement needs an “end”.

The complete code looks like this:

local mode = Pixera.Timelines.getTimelineAtIndex(0).getTransportMode()
if mode == 1.00 then
   Pixera.Timelines.getTimelineAtIndex(0).pause()
else
   Pixera.Timelines.getTimelineAtIndex(0).play()
end

 

Save your code in the Scripting IDE and execute your Action.


Action Input and Output

 

Every Action can both receive and send multiple values, which is called Input and Output. The default setting is that “everything that goes in comes out”.

As an example, create a new Action named “play”, then bring in the “Logger” Module found in the Tools of the Library. This Module displays the Output of an Action in the log, now connect the right end of the “play()” Action (the Output)  to the left beginning of the “info()” Action (the Input).

 

This Action has no defined input variable – signified by the empty parentheses - and therefore all input values are directly channeled to the output. This setup may be sufficient when used to pass slider data, but not if you want to modify the input values inside your Action.

Therefore, input variables must be defined. This is done by naming an Action “play(x, y, z)”. The Action now possesses three input variables called x, y and z, which allows us to address the input values by these names.

 

The Output behavior can be modified by using the following command written into the Action code:

pixc.callRefs(y)

 

“callRefs(y)” defines that only the input variable “y” is passed to the Output, which can be tested with the “Run” option that can be found using right click on an Action. By passing 3, 4 and 5 to the Action, now only 4 should be forwarded to the Output.

 

However, sometimes it can happen that you must process your input variables, but you don’t know the number of variables you’ll need. In that case, ellipses (…) come in handy. They function as a placeholder for a variable number of arguments. Just rename your Action to “play(…)” and modify “callRefs()” to:

pixc.callRefs(...)

 

This will forward all input values to the Output and is basically the default behavior. However if you want to only send specific values from the one-based input stream, you will want to use a table like this:

local table = {...}
pixc.callRefs(table[1], table[7])

 

This will forward the first and the seventh value of all input values to the Output.

 

In some cases, you might even need an Action that receives input but doesn’t send Output. This can be realized with the following command:

pixc.suppressCallRefs()

 

Now all Output of the Action is blocked:


Coding a Cue Slider

 

In this example, a Slider will be created that allows you to switch between all the cues on the Timeline.

Create a new Module called “Input” with an Action called “getSliderValue()”. This Action will only be used to get and forward the current Slider value, so it can stay empty.

Create a second Module called “Processing” with two Actions, “getNumberCues()” and “computeCueIndex(val)”.

“computeCueIndex(val)” should get the Slider value from “getSliderValue()” as Input. Therefore, connect the Output of “getSliderValue()” with the Input of “computeCueIndex(val)”.

 

Before you can Slide through all the cues, you must at first know how many there are for the Slider to go between. 

First, write the following line into “getNumberCues()”:

return Pixera.Timelines.getTimelineAtIndex(0).getCues()

 

The Action uses “getCues()” , which will get a table with all cues in it. Since other Actions should be able to call this Action and get its result, you must specify what exactly the “result” is. This is done with the return keyword. In this case “getNumberCues()” will return a table with all cues in it.

Now that we have all the cues, this information must be combined with the current Slider value to calculate the right index. This is done in “computeCueIndex(val)”:

local noCues = #(self.getNumberCues())

 

To call another Action in the same Module, the self-keyword is used. “self.getNumberCues()” will return a table with all cues in it, but only the number of table entries is needed for the setup. Therefore, use the "#" operator to get this information, which is then saved in the “noCues” variable.

Now an area on the Slider must be allocated for each cue. Since the Slider Element by default has a maximum value of 100, dividing this maximum by the number of cues returns the size of these area, which is then saved in a variable:

local rangeSize = 100 / noCues

 

Now the cue index will be calculated based on the current position of the Slider. “val” is the input Variable of the Action that is provided by “getSliderValue()” and defines the current slider position. If there are five cues on the Timeline, then the Slider must be divided into 5 areas with a size of 20.

When the Slider position is at 79.0 , which cue should be applied? Cue_0 lies in the area 0-20 on the slider, Cue_1 at 20-40, Cue_2 at 40-60, and Cue_3 at 60-80. Therefore, the searched index should be 3

To create this logic more efficiently, the Condition called a “while" loop will be used. It will continuously execute the next command as long as its Condition is fulfilled. In our case, the while loop adds up the area size until it is bigger than the slider-position.

local currentTile = rangeSize
local index = 0
while val > currentTile do
   index = index + 1
   currentTile = currentTile + rangeSize
end

 

Now that the correct index has been found, it now needs to be forwarded to the Output.

pixc.callRefs(index)

 

Lastly, we create a Module called “Output” with the Action “setCue(index)”. We connect the Output of “computeCueIndex(val)” with the Input of “setCues(index)”.

 

Now “setCues(index)” should place the nowpointer at the right cue, which is achieved by the following line:

Pixera.Timelines.getTimelineAtIndex(0).getCueAtIndex(index).apply()

 

Finally, create a Slider with a Range from 0 to 100, connect it to “getSliderValue()” and test it. You should now be able to slide fast through all your cues on the Timeline.


PIXERA 2.0.239 | 04 February 2025 | CL

Was this article helpful?