User Tools

Site Tools


macros:control_structures

Control Structures

When a macro is called, all its steps are executed sequentially.

However, you can define conditional steps - steps which are only executed if a condition is met. In order to do this, simply give the step a condition property, like in Chase - Double speed:

<step condition="Math.IsEqual(Playbacks.Editor.Times.ChaseSpeed, 0.0)">
  ActionScript.SetProperty.Float("Playbacks.Editor.Times.ChaseSpeed", 1.0)
</step>

At the moment (version 10.0 and 10.1) it looks like such conditions are stripped when a macro is copied in Titan. Hence, always move macros with conditions (which has the backdraw that you can have a macro only on one handle.

This step is only executed if its condition is met - and the condition is a function written in double quotes: Math.IsEqual takes two values as arguments and returns true if both values are equal. In total, if the property Playbacks.Editor.Times.ChaseSpeed equals 0.0 then this step is performed and sets this property to 1.0.

Another mechanism is also related to control structures albeit strictly it is just juggling with booleans: simple toggle logic, see Timecode - Enable/Disable:

<step>ActionScript.SetProperty.Boolean("Timecode.Enabled", !Timecode.Enabled)</step>

This simply negates a variable, effectively turning it into its reciprocal value: if the variable 'Timecode.Enabled' is true it will be set to false, and vice versa.

There are also some other syntax versions:

<step>
  {
    if(Math.IsNotEqual(Playbacks.Editor.Times.ChaseSpeed, 0.0)) {
      ** Do Something **
    } else {
      ActionScript.SetProperty.Float("Playbacks.Editor.Times.ChaseSpeed", 1.0);
    }
  }
</step>

and as of version 10, it is possible to write conditions in a more modern way:

<step>
  {
    if(Playbacks.Editor.Times.ChaseSpeed == 0.0) {
       ActionScript.SetProperty.Float("Playbacks.Editor.Times.ChaseSpeed", 1.0);
    }
  }
</step>

It appears that the else hive must not be empty. If it is empty then Titan doesn't start, and the Log Viewer complains “Compliation of action script failed:… Unexpected token '' found.” (The typo is courtesy of the Log Viewer :-) )

If you only need the if hive, then omit the else altogether.

Also see an example here: Dummy speed as condition

further readings

2017/10/13 17:12 · icke_siegen
You could leave a comment if you were logged in.
macros/control_structures.txt · Last modified: 2019/02/06 22:07 by icke_siegen