Page 1 of 1

Txt+ to show framecount in specific order with expressions

PostPosted: Sun Apr 10, 2016 1:20 am
by Eugene Afanasiev
Hi, I want the Text node to give out frames in this order: 0001 0002 etc and when it hits 10, it should must show 0010 and when it hits 100 - 0100 so it must always stay in the 4 digit pattern
So I'm typing an expression in the Styled Text as this:

Text( iff( time<10,"000"..time,"00"..time) )

but it doesn't work.. neither this one: iff(time<10, Text("000"..time, Text("00"..time))

How would be the right way?

Re: Txt+ to show framecount in specific order with expressio

PostPosted: Sun Apr 10, 2016 8:36 am
by Sander de Regt
The right way would in this case be: use the timecode modifier like this

Code: Select all
{
   Tools = ordered() {
      Text1 = TextPlus {
         CtrlWZoom = false,
         Inputs = {
            Width = Input { Value = 1920, },
            Height = Input { Value = 1080, },
            ["Gamut.SLogVersion"] = Input { Value = FuID { "SLog2", }, },
            Font = Input { Value = "Arial", },
            StyledText = Input {
               SourceOp = "TimeCode1",
               Source = "Time",
            },
            Style = Input { Value = "Bold", },
            ManualFontKerningPlacement = Input {
               Value = StyledText {
                  Array = {
                  },
                  Value = "",
               },
            },
            ShadingGradient1 = Input {
               Value = Gradient {
                  Colors = {
                     [0] = { 0, 0, 0, 1, },
                     [1] = { 1, 1, 1, 1, },
                  },
               },
            },
            RenderToDPTFile = Input { Disabled = true, },
            DPTType = Input { Disabled = true, },
            DPTResolution = Input { Disabled = true, },
         },
         ViewInfo = OperatorInfo { Pos = { 55, 16.5, }, },
      },
      TimeCode1 = TimeCode {
         CtrlWZoom = false,
         Inputs = {
            Hrs = Input { Value = 0, },
            Mins = Input { Value = 0, },
            Secs = Input { Value = 0, },
            PadDigits = Input { Value = 4, },
         },
      },
   },
   ActiveTool = "Text1",
}

Re: Txt+ to show framecount in specific order with expressio

PostPosted: Sun Apr 10, 2016 5:53 pm
by Eugene Afanasiev
Cool! Thanks:)

Re: Txt+ to show framecount in specific order with expressio

PostPosted: Sun Apr 10, 2016 6:00 pm
by Eugene Afanasiev
Still... Interesting enough how to make the output text react to conditions, with iff or it's not working for text like that?

Re: Txt+ to show framecount in specific order with expressio

PostPosted: Sun Apr 10, 2016 6:46 pm
by Sander de Regt
Honestly I have no idea. I almost never use expressions or scripting in Fusion. There are lots of things possible though.

Re: Txt+ to show framecount in specific order with expressio

PostPosted: Thu Apr 14, 2016 6:50 am
by Eric Westphal
The Expressions are pretty much based on Lua scripting.
So in the Text+ something like
Code: Select all
Text(string.format("%04d", time))

works just fine.

Cheers.

Eric.

Re: Txt+ to show framecount in specific order with expressio

PostPosted: Thu Apr 14, 2016 12:07 pm
by Eugene Afanasiev
Great! Thank you!

Re: Txt+ to show framecount in specific order with expressio

PostPosted: Mon May 02, 2016 6:37 am
by Eugene Afanasiev
Guys, I've found what was wrong with this string of code:
Text( iff( time<10,"000"..time,"00"..time) )

I'm wondering why Fusion veterans haven't pointed this mistake right away...

Re: Txt+ to show framecount in specific order with expressio

PostPosted: Mon May 02, 2016 6:40 am
by Eugene Afanasiev
well it's the documentation that confused me. there is "iff" mentioned in there not "iif" cause the right way is "iif"

so if you paste this code to styled text expression it'll work:

Code: Select all
Text( iif( time<10,"000"..time,"00"..time) )