Graphics

 View Only
  • 1.  How to Make a Countdown Timer Change Font Color?

    Posted 08-29-2019 19:28

    Hello, I need to create a countdown timer that turns red when it hits a certain time i.e. 60 seconds.

    I need to have a countdown timer that changes color when it hits a certain mark.

    My initial thought was to create a Scene Director to achieve the color change.

    Questions:

    - Is there a better way to do it?

    - Is there a script that changes font colors?

    - Is there a way to trigger a Scene Director (which would change the color) by mapping a keyboard key to it?

    Thank you all in advance!

     



  • 2.  RE: How to Make a Countdown Timer Change Font Color?

    Posted 08-29-2019 21:31

    A while back someone had posted similar with a shot clock changing as it counted down. I used the suggestions from that in VL to make mine and change the face material. If the graphic doesn't make sense, feel free to search for shot clock and it may be easier to follow.

    Basically my under 10 material is yellow and under 5 is red. I would assume a regular clock would be similar. 


    #XPression


  • 3.  RE: How to Make a Countdown Timer Change Font Color?

    Posted 08-31-2019 18:42

    Thanks Joshua!

    The visual logic you posted above works perfectly to change the color of the font face.

    The only issue is that my timer runs manually through a widget and I can't get the actual value of the clock to work with the visual logic. In another words, the Timer is not "producing" the right value for the logic to work. When I change from clock widget to regular text and type in the values, it works. But not with the running clock. It doesn't recognize "10:00" as 10, "5:00" as 5, etc etc.

    My challenge now is to extract a number value from the running clock in order to make the visual logic work.

    Any advice on that?


    #XPression


  • 4.  RE: How to Make a Countdown Timer Change Font Color?

    Posted 08-31-2019 19:50

    As an alternative, in case the Visual Logic doesn't work, I'm creating a script trigger in the keyboard mapping to change the clock font color manually:

    dim sd as xpSceneDirector

    Scene.getSceneDirectorByName("ClockRed",sd)

    sd.Play

    It's a really basic script but for some reason I get a rd x on the script menu (OnKeyPress) and it doesn't work.

    I'm totally new to scripting on XPression. Any help is appreciated!


    #XPression


  • 5.  RE: How to Make a Countdown Timer Change Font Color?

    Posted 09-09-2019 19:19

    Paulo, 

    Are you compiling your script? The red x should turn into a green checkmark


    #XPression


  • 6.  RE: How to Make a Countdown Timer Change Font Color?

    Posted 09-19-2019 06:25

    Yes, I'm compiling the script but it gives the error message of "Scene not declared"

    Thanks,


    #XPression


  • 7.  RE: How to Make a Countdown Timer Change Font Color?

    Posted 09-27-2019 00:42

    I was able to compile the script successfully (one victory at a time hehe) but still can't get the script to trigger a certain Scene Director.

    I placed the script inside of an Script Action 'OnKeyPress' in the Keyboard Mapping menu and assigned a shortcut.

    Here is the script:

     

    dim xx as xpScene

    dim sd as xpSceneDirector

    xx.getSceneDirectorByName("PlayAnim",sd)

    sd.Play

     

    When I play message on air and hit the shortcut, nothing happens. Why?

    Thanks for the help!


    #XPression


  • 8.  RE: How to Make a Countdown Timer Change Font Color?

    Posted 10-15-2019 23:44

    Hey Paulo,

    I just wanted to reply on your remark on the Visual Logic: "The only issue is that my timer runs manually through a widget and I can't get the actual value of the clock to work with the visual logic. In another words, the Timer is not "producing" the right value for the logic to work. When I change from clock widget to regular text and type in the values, it works. But not with the running clock. It doesn't recognize "10:00" as 10, "5:00" as 5, etc etc."

    The reason is that in Visual logic a text is not always recognized as a number as you already pointed out.

    The solution would be to extract the numbers from the clock value using the Mid String-block.

    In this block you can then use the Index and Length properties to extract the data from your textfield which is linked to the widget.

    So to give you an example:

    10:00

    index = 0, length = 2 => output = 10

    index = 3, length = 2 => output = 00

    But in order for this to work, you need to make sure that the output of the widget will always display two numbers for the seconds. So 08 instead of 8 otherwise, you will get wrong results.

    To show you what I mean:

    8:00

    index = 0, length = 2 => output = 8:

    index = 3, length = 2 => output = 0

     

    while if you use 

    08:00

    index = 0, length = 2 => output = 08

    index = 3, length = 2 => output = 00

     

    In my opinion the Visual Logic approach would be the easiest.

    Best regards,

    Kenneth


    #XPression