User Tools

Site Tools


macros:control_structures

This is an old revision of the document!


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>

Also see an example here: Dummy speed as condition

further readings

2017/10/13 15:12 · icke_siegen
You could leave a comment if you were logged in.
macros/control_structures.1536420826.txt.gz · Last modified: 2018/09/08 15:33 by icke_siegen

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki