Graphics

 View Only
Expand all | Collapse all

Basketball Score Bug Animation Scripting

  • 1.  Basketball Score Bug Animation Scripting

    Posted 01-13-2024 03:21

    I am new to scripting and have been trying to teach myself Visual Basic but I need some help trying to make this work. Essentially I am working on a basketball score bug and I want it to play different animations depending on how much a certain text object increases. I have it set up right now to only play a single animation every time a text objects changes/updates. My script looks like this (for reference I have two text objects each for HOME and AWAY, one hidden and one visible, it is Datalinqd to Daktronics):

    On the scene itself:

    OnOnline

    Dim scr as xpTextObject

    scene.GetObjectByName("AW ScrText" , scr)

    scene.GetObjectByName("Aw Score" , txt)

    txt.Text = scr.Text

    --------------------------------------------------------------------

    On the hidden script (this example is only for the away score):

    OnSetText

    Dim dir as xpSceneDirector

    scene.GetSceneDirectorByName("AW Score" , dir)

    dir.PlayRange(0,60)

    ______________________________________________

    I want to change this to play a simple animation when the hidden text increases by 1 or 2 (For a free throw or field goal in basketball), and then play a different more complicated animation when it increases by 3. I know this is probably simple I am just in the process of learning so thank you for any help you can provide!

    I am guessing something like this but don't know how to connect it to the previous and current values.

    Dim previousValue As Double

    Dim currentValue As Double

    Dim increaseAmount As Double = 1.0

    Dim dir as xpSceneDirector

    If currentValue > previousValue AndAlso currentValue - previousValue >= increaseAmount Then

    scene.GetSceneDirectorByName("AW Score" , dir)

    dir.PlayRange(0,60)

    Or is there an easier way to do this with Visual Logic?



    ------------------------------
    Nathaniel Rudolph
    Xpression Graphics Operator
    CSBN
    ------------------------------



  • 2.  RE: Basketball Score Bug Animation Scripting

    Posted 01-13-2024 06:26

    I would compare the old score with the new score and calculate the delta. 

    If the delta equals 3 then play the animation else play the other animation. 

    I'm traveling and writing this on the move or I'd write the code for you here. 



    ------------------------------
    Simon Redmile
    Senior Graphic Programmer & Designer
    Ross Video
    Bristol United Kingdom
    ------------------------------



  • 3.  RE: Basketball Score Bug Animation Scripting

    Posted 01-15-2024 14:55

    Thank you I updated my code but I am still not sure how to have it know what the previous score is. How would I store this?

    This is what I have so far (For an increase in 3 points):

    Dim previousValue As Double
    Dim currentValue As Double
    Dim dir As xpSceneDirector


    previousValue = GetPreviousScore() 'this is where I am thinking I would get it from I just don't know if there is a method for this
    currentValue = GetCurrentScore()

    Dim delta As Double = currentValue - previousValue

    If Math.Abs(delta) = 3 Then
        scene.GetSceneDirectorByName("AW Score", dir)
        dir.PlayRange(0, 60)



    ------------------------------
    Nathaniel Rudolph
    Xpression Graphics Operator
    CSBN
    ------------------------------



  • 4.  RE: Basketball Score Bug Animation Scripting

    Posted 01-15-2024 14:58

    When you do your animation you must be animating the old score off I assume?

    Then the new score in?

    You can pull the old score from the object you are animating out? 



    ------------------------------
    Simon Redmile
    Senior Graphic Programmer & Designer
    Ross Video
    Bristol United Kingdom
    ------------------------------



  • 5.  RE: Basketball Score Bug Animation Scripting

    Posted 01-15-2024 15:52

    Oh yes I do have that. So would this be correct? (Note that the HM Score is the visible text object on the scorebug itself, and then HM ScrText is the hidden one being updated by Daktronics then will update the HM Score after the animation)

    Dim previousValue As Double
    Dim currentValue As Double
    Dim dir As xpSceneDirector


    previousValue = scene.GetObjectByValue("HM Score", previousValue)
    currentValue = scene.GetObjectByValue("HM ScrText", currentValue)

    Dim delta As Double = currentValue - previousValue

    If Math.Abs(delta) = 3 Then
        scene.GetSceneDirectorByName("HM Three Point", dir)
        dir.PlayRange(0, 60)
    End If



    ------------------------------
    Nathaniel Rudolph
    Xpression Graphics Operator
    CSBN
    ------------------------------



  • 6.  RE: Basketball Score Bug Animation Scripting

    Posted 01-15-2024 16:07

    Where do you plan to run that? On the text object itself when a score is changed? 

    You can of course add an else to run the other scene director for different animation.  

    Yours looks good, mine would have probably looked like this;

    Dim currentValue, previousValue as xpTextObject
    Dim dir as xpSceneDirector
    scene.GetObjectByName("HM Score", previousValue)
    scene.GetObjectByName("HM ScrText", currentValue)
    Dim delta As Integer = currentValue.Text - previousValue.Text
    If delta = 3
        scene.GetSceneDirectorByName("HM Three Point", dir)
        dir.PlayRange(0, 60)
    else
        scene.GetSceneDirectorByName("HM Point", dir)
        dir.PlayRange(0, 60)
    End If



    ------------------------------
    Simon Redmile
    Senior Graphic Programmer & Designer
    Ross Video
    Bristol United Kingdom
    ------------------------------



  • 7.  RE: Basketball Score Bug Animation Scripting

    Posted 01-15-2024 16:21

    Thank you very much for your help! I do plan to run it on the hidden text for the score (HM ScrText). Then I will have a script on the scene director to change the score (HM ScrText to HM Score). Does this still work?



    ------------------------------
    Nathaniel Rudolph
    Xpression Graphics Operator
    CSBN
    ------------------------------



  • 8.  RE: Basketball Score Bug Animation Scripting

    Posted 01-15-2024 16:22

    Sounds good to me. 



    ------------------------------
    Simon Redmile
    Senior Graphic Programmer & Designer
    Ross Video
    Bristol United Kingdom
    ------------------------------



  • 9.  RE: Basketball Score Bug Animation Scripting

    Posted 01-15-2024 17:56

    For some reason it still isn't working. I copied and pasted your code into the script editor, made sure all the play ranges were correct. All the scene directors are named correctly. I am trying it with a counter widget since I don't have Daktronics up at the moment. Any ideas to why it might not be working?



    ------------------------------
    Nathaniel Rudolph
    Xpression Graphics Operator
    CSBN
    ------------------------------



  • 10.  RE: Basketball Score Bug Animation Scripting

    Posted 01-15-2024 18:00

    What does the debug monitor say? 



    ------------------------------
    Simon Redmile
    Senior Graphic Programmer & Designer
    Ross Video
    Bristol United Kingdom
    ------------------------------



  • 11.  RE: Basketball Score Bug Animation Scripting

    Posted 01-15-2024 18:34

    It says that everything is complied no messages, it is green. When I increase the widget (Data source set to Counter 2) any amount on the AW ScrText it does the simple animation (AW Score) for the "else" statement but doesn't do the three point animation when I increase it by 3 (For example I type 3 into the counter when it is 0). Just to make sure this is exactly what I have: 

    Dim currentValue, previousValue as xpTextObject
    Dim dir as xpSceneDirector
    scene.GetObjectByName("AW Score", previousValue)
    scene.GetObjectByName("AW ScrText", currentValue)
    Dim delta As Integer = currentValue.Text - previousValue.Text
    If delta = 3
        scene.GetSceneDirectorByName("AW Three Point", dir)
        dir.PlayRange(0, 131)
    else
        scene.GetSceneDirectorByName("AW Score", dir)
        dir.PlayRange(0, 60)
    End If

    I have attached some images as well

    Compiler on the AW ScrText (OnSetText)

    The hidden text
    Scene directors for the score bug (I have only done the AW one for three point right now)
    Inside the AW Three Point
    This code is inside the script on the scene director:

    Dim scr as xpTextObject

    scene.GetObjectByName("AW ScrText" , scr)

    scene.GetObjectByName("Aw Score" , txt)

    txt.Text = scr.Text



    ------------------------------
    Nathaniel Rudolph
    Xpression Graphics Operator
    CSBN
    ------------------------------



  • 12.  RE: Basketball Score Bug Animation Scripting

    Posted 01-16-2024 04:20

    The debug monitor I am talking about is this one. 



    ------------------------------
    Simon Redmile
    Senior Graphic Programmer & Designer
    Ross Video
    Bristol United Kingdom
    ------------------------------



  • 13.  RE: Basketball Score Bug Animation Scripting

    Posted 01-16-2024 16:00

    Thank you! I checked the debug monitor and nothing is popping up when I run the script. It is kind of working now however just not correctly. When I delete the scorebug from the sequence and re-add it back in then it does the three point animation and the alternate animation at the same time. But after that no matter what I put in it does the alternate one only.



    ------------------------------
    Nathaniel Rudolph
    Xpression Graphics Operator
    CSBN
    ------------------------------



  • 14.  RE: Basketball Score Bug Animation Scripting

    Posted 01-16-2024 16:12

    To stop them playing when they first come online you can add some control such as an if that surrounds all the other if statements. 

    Dim IN as xpSceneDirector

    If sd.position < 5

    else 

    <--- rest of you code here

    end if 

    That means when it first comes online that update text will be triggered but won't do anything. 

    As for the other issues, you could try storing that value in a text object. 

    Dim currentValue, previousValue, deltaValue as xpTextObject
    Dim dir as xpSceneDirector
    scene.GetObjectByName("HM Score", previousValue)
    scene.GetObjectByName("HM ScrText", currentValue)
    scene.GetObjectByName("HM delta", deltaValue)
    deltaValue.Text = currentValue.Text - previousValue.Text
    engine.DebugMessage(deltaValue, 0)
    If deltaValue.Text = 3
        scene.GetSceneDirectorByName("HM Three Point", dir)
        dir.PlayRange(0, 60)
        engine.DebugMessage("3 points", 0)
    else
        scene.GetSceneDirectorByName("HM Point", dir)
        dir.PlayRange(0, 60)
        engine.DebugMessage("less than 3 points", 0)
    End If



    ------------------------------
    Simon Redmile
    Senior Graphic Programmer & Designer
    Ross Video
    Bristol United Kingdom
    ------------------------------



  • 15.  RE: Basketball Score Bug Animation Scripting

    Posted 01-18-2024 11:18

    Would either of you be able to upload the project file you are working on, or a different project with this script in action? I've tried implementing it into my basketball bug graphic and am having trouble calculating the delta with currentValue and previousValue.



    ------------------------------
    Casey Eakins
    Athletics Production Engineer - Student
    University of St. Thomas
    ------------------------------



  • 16.  RE: Basketball Score Bug Animation Scripting

    Posted 01-18-2024 12:55

    I am not at my computer for a while but when I get back I can. I am having trouble calculating the delta as well but I will be trying the new code when I get back. I think if you are using the widget for the scores it isn't working as well. Because when I hooked up my Daktronics and controlled the score through there it started working better but still made mistakes when calculating. But as long as you have a hidden text for the Home and Away score that has the above script. Then visible text that is updated with a script in the scene director once the animation plays then it should work. The only problem is calculating the delta but storing it in another text object might work. But I can't try it at the moment. Thank you Simon for your time you have been a great help!



    ------------------------------
    Nathaniel Rudolph
    Xpression Graphics Operator
    CSBN
    ------------------------------