Graphics

 View Only
  • 1.  Penalty Clock visibilities

    Posted 10-06-2014 16:27
    Hi,

    I have two timers created in Dashboard that I have linked to text objects inside of Xpression. These two are to be used for the home/away power play clocks in hockey. What I need is to script it so that the clocks won't be visible when it has "0:00", but at the same time, I need to script it so that if there are offsetting penalties, then both will be not visible. However if one ends before the other, the other will become visible.

    Essentially:

    - If both have more than "0:00" they both won't be visible, but if one goes down to "0:00" before the other, then the other will become visible.

    - However, if they both read "0:00" (the default state with no penalties) then neither will be visible.

    I've been trying to play with the scripting, but haven't managed to get it working

    Simple version of the code to just get one timer to toggle visibility:

    dim homepp as xptextobject

    scene.getobjectbyname ("home pp", homepp)

    if text = "0:00"

    homepp.visibility=false

    else

    homepp.visibility=true

    end if

    This successfully makes it so when I add 2 minutes to the clock, it is visible, and when I rest it to 0 it is not. However, when I try to add code to interact with the other timer is where I am having issues.

    dim homepp as xptextobject

    dim awaypp as xptextobject

    scene.getobjectbyname ("home pp", homepp)

    scene.getobjectbyname ("away pp", awaypp)

    if homepp.text = "0:00"

    homepp.visible=false

    else

    homepp.visible=true

    end if

    This is without even trying to do anything with the other timer. When I change the "text" in the first code to "homepp.text" in the second example, it seems to somehow flip everything around. It is now visible when 0 and when I add 2 minutes, it is not. I am not quite sure why this would be. Still pretty new to this, and admit that the scripting is far from my strong suit.

    Any help is appreciated. Thanks.


  • 2.  RE: Penalty Clock visibilities

    Posted 10-06-2014 22:31
    Hi Jake,

    Your code appears to be fine, but when you write code beware of the Case Sensitivity of the code. I'm not a 100% sure but I think VB is case-sensitive. Which means that if you have written something wrong, the code won't be executed properly.

    Try this:



    dim homepp as xpTextObject

    dim awaypp as xpTextObject

    dim home as string

    dim away as string

    Self.getObjectByName("home pp", homepp)

    Self.getObjectByName("away pp", awaypp)

    home = homepp.Text

    away = awaypp.Text

    ' COMPARE THE VALUES

    if home = "0:00" And away = "0:00" then

    homepp.Visible = false

    awaypp.Visible = false

    end if

    if home = "0:00" And away [SMALLER THEN BIGGER THEN] "0:00" then 'CODE NOT DISPLAYED CORRECTLY

    homepp.Visible = false

    awaypp.Visible = true

    end if

    if home [SMALLER THEN BIGGER THEN] "0:00" And away = "0:00" then 'CODE NOT DISPLAYED CORRECTLY

    homepp.Visible = true

    awaypp.Visible = false

    end if



    Cheers,

    Kenneth

    [EDIT]

    In the two lines marked above there is a comparator which is not being displayed correctly. Where it says SMALLER THEN BIGGER THEN, please replace those words with the actual symbols.

    #XPression


  • 3.  RE: Penalty Clock visibilities

    Posted 10-07-2014 14:36
    Thanks for the help, but that seemed to just make both of them not visible all the time.

    #XPression


  • 4.  RE: Penalty Clock visibilities

    Posted 10-07-2014 18:18
    That's very strange Jake because it's working fine with me here.

    What version of XPression are you using and where did you put this code?

    Since it needs to update all the time, it should be in OnRender.

    Did you also check the syntax, did you use the correct capitals where needed?

    Kenneth

    #XPression