Graphics

 View Only
Expand all | Collapse all

How to take online and playout a scene automatically when data conditions are met

  • 1.  How to take online and playout a scene automatically when data conditions are met

    Posted 12-17-2024 12:00
    Visual Logic conditions for XPression auto playout of scene

    (1) last shot is by home team, and

    (2) shot speed is higher than 100km/hr).  

    I can use Visual Logic to set up conditions, but I don't know to script an automatic playout based on my criteria.  Can someone help me with this?  Thanks in advance!



    ------------------------------
    Sonja Broomfield
    On-Air graphics (Duet & Xpression)
    Freelance
    Canada
    ------------------------------



  • 2.  RE: How to take online and playout a scene automatically when data conditions are met

    Posted 12-18-2024 08:08

    Hi Sonja,
    if I understand it right, you have got one scene online and you want to trigger another scene under the described conditions.

    Add the following 2 Scripts to your MainScene:

    Sub OnOnline(Engine as xpEngine, Self as XpScene)
    Dim SceneToBeCalled as xpScene
    'Get a handle to the scene to be called. If the scene does not exist EXIT
    If Not Engine.GetSceneByName("Scene2", SceneToBeCalled, False) then Exit Sub
    Dim probe as xpTextObject
     
    ' Check the conditions
    If Self.GetObjectByName("LAST SHOT SPEED",probe) then
    If val(probe.Text) < 100 then Exit Sub
    End If
     
    If Self.GetObjectByName("TRI",probe) then
    If probe.Text <> "MTL" then Exit Sub
    End If
     
    ' So we know know that all conditions are met
    ' Let´s call Scene2 into FrameBuffer 0 on Layer 1
    SceneToBeCalled.SetOnline(0,1)


    Sub OnOffline(Engine as xpEngine, Self as XpScene)
    'Set the other scene offline, when this scene goes offline
    Dim SceneToBeCalled as xpScene
    If Engine.GetSceneByName("Scene2", SceneToBeCalled, False) then
        SceneToBeCalled.SetOffline()
    End If
    ________________________________________________________________________

    The second script is to set scene2 offline if scene1 is going offline. Don´t know if you need this.

    If you want to show the second scene while scene1 is already online and just the Text is changed you need a little more. Let me know.



    ------------------------------
    Tom Lehmann
    CEO
    IT Services
    Frankfurt/Main Germany
    ------------------------------



  • 3.  RE: How to take online and playout a scene automatically when data conditions are met

    Posted 12-21-2024 01:59

    The scene in question is a stand-alone scene played out in Layer 1 over any scene on Layer 0.  It flies in the 'last shot' information (if the last shot meets the two conditions), then flies out and takes itself offline.  The scene works without a macro, but I must play it out manually because I can't find a way to trigger it based on conditions.



    ------------------------------
    Sonja Broomfield
    On-Air graphics (Duet & Xpression)
    Freelance
    Canada
    ------------------------------



  • 4.  RE: How to take online and playout a scene automatically when data conditions are met

    Posted 12-18-2024 08:17

    Hi Sonja,
    a second approach you could do is putting the content of scene2 as a group into scene1.

    In this case you could do it in visual logic by setting this group invisible if the conditions do not met.
    There is imho no way to adress a different scene from within visual logic.

    Tom



    ------------------------------
    Tom Lehmann
    CEO
    IT Services
    Frankfurt/Main Germany
    ------------------------------



  • 5.  RE: How to take online and playout a scene automatically when data conditions are met

    Posted 10-05-2025 08:31

    Apparently there is a way to do it from a script in a scene director which you play out from visual logic (see Simon reply below).  The problem becomes automating the scene so that the setup scene is always online, and triggers the second scene every time conditions are met.  Another wrinkly is that I don't want to have the scene repeat endlessly until the conditions are no longer met, so the scripting would have to include a line that limits its application to only when data changes.



    ------------------------------
    Sonja Broomfield
    On-Air graphics (Duet & Xpression)
    Freelance
    Canada
    ------------------------------



  • 6.  RE: How to take online and playout a scene automatically when data conditions are met

    Posted 12-18-2024 08:42

    One idea I had that would have minimal scripting would be if those conditions are met they play a scene director. 

    That scene director could have a script on it that takes the scene on air. 

    dim take1 as xpTakeItem

    Engine.sequencer.getTakeItemByID(1001,take1)

    take1.execute



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



  • 7.  RE: How to take online and playout a scene automatically when data conditions are met

    Posted 10-05-2025 08:24

    Still working on this.  This works great once, but I need it to work every time the data changes.  For instance, if player 1 meets conditions at 1:00 in play, it should play out once.  Then, if player 2 meets conditions, it should play out with updated info once.  If, in between, a player shoots but does not meet one of the conditions, it should not play out.  Is there a way to trigger visual logic and the script when data changes?



    ------------------------------
    Sonja Broomfield
    On-Air graphics (Duet & Xpression)
    Freelance
    Canada
    ------------------------------



  • 8.  RE: How to take online and playout a scene automatically when data conditions are met

    Posted 10-06-2025 09:53

    If you want to stop it triggering all the time you just need to put a check like, is the scene director already playing and telling it not to play. That's the method I used most. 



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



  • 9.  RE: How to take online and playout a scene automatically when data conditions are met

    Posted 10-06-2025 09:22

    @Simon Redmile - Would it not be possible to use a text objects "onChange" for this?
    Like when the text for speed goes higher than a specific value, then trigger the scene director or scene?
    Or does that not trigger from a DataLinq source perhaps?

    @Sonja Broomfield - Where's the data for the speed comming from?
    External System -> DataLinq -> Xpression?
    External System -> DashBoard -> DataLinq -> Xpression?

    ------------------------------
    Aleksander Stalsberg
    Inland Norway University of Applied Sciences/Lillehammer Icehockey Club
    Norway
    ------------------------------



  • 10.  RE: How to take online and playout a scene automatically when data conditions are met

    Posted 10-06-2025 16:20

    A good theory, but I have two conditions, not just speed. 

    Here is what I have so far, and it sort of works.  I made the scene script pretty much as Mr. Lehmann kindly advised, but instead of playing out a sequence director I played a take item, as Mr. Redmile suggested:

    Dim probe as xpTextObject
    ' Check the conditions
    If Self.GetObjectByName("TRI",probe) then
    If probe.Text <> "MTL" then Exit Sub
    End If

    If Self.GetObjectByName("SPEED",probe) then
    If val(probe.Text) < 100 then Exit Sub
    End If

    ' So we know know that all conditions are met
    ' Call up TakeItem 5
    dim takeitem as xpTakeItem
    engine.sequencer.GetTakeitemByID(5, takeitem)
    takeitem.Execute

    The only problem is when there are two shots back-to-back, the graphic updates in mid-playout, even though live update is off for all objects.  Not sure how to fix this.



    ------------------------------
    Sonja Broomfield
    On-Air graphics (Duet & Xpression)
    Freelance
    Canada
    ------------------------------



  • 11.  RE: How to take online and playout a scene automatically when data conditions are met

    Posted 10-07-2025 05:47

    Wrap it all in an if statement that checks if the graphic is already playing like I mentioned higher up. 



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



  • 12.  RE: How to take online and playout a scene automatically when data conditions are met

    Posted 10-07-2025 06:04

    Yes, thanks, that's exactly what I don't know how to do.  :) 



    ------------------------------
    Sonja Broomfield
    On-Air graphics (Duet & Xpression)
    Freelance
    Canada
    ------------------------------



  • 13.  RE: How to take online and playout a scene automatically when data conditions are met

    Posted 10-07-2025 06:14

    dim sd as xpSceneDirector
    self.GetSceneDirectorByName("the animation scene director you are after", sd)

    if  sd.Position <> 0

    ' do nothing as it must be playing since its not at 0

    else

        'put the rest of your code here

    end if 

    I think you should also make sure that scene you are triggering goes offair after playing if you aren't already doing that. 



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



  • 14.  RE: How to take online and playout a scene automatically when data conditions are met

    Posted 10-07-2025 06:17

    hmmmm actually now I think about this the above method works because the way I make things  the scene with the animation is always online, you'll actually need a different check to what I just wrote. Instead you just need to check if the scene is online rather than  if the animation is playing. 

    Do you know how to check a layer for a scene?



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



  • 15.  RE: How to take online and playout a scene automatically when data conditions are met

    Posted 10-07-2025 06:39

    Wrap the rest of you script in this. 

    dim otherScene as xpScene

    dim fb as xpOutputFramebuffer

    dim layer as integer = "your layer number for takeitem 5" 

     

    engine.GetOutputFramebuffer(0, fb)

    if fb.GetSceneOnLayer(layer, otherScene)

    ' do nothing

    else

    ' your script here

    end if 



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



  • 16.  RE: How to take online and playout a scene automatically when data conditions are met

    Posted 10-07-2025 11:16
    Perfect!  Thank you for your expert help.

    I also made sure I was not updating live or refreshing dynamic materials on data changes, so the player didn't change while the last shot graphic was playing out.







  • 17.  RE: How to take online and playout a scene automatically when data conditions are met

    Posted 10-07-2025 11:41

    Nice one! :)



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



  • 18.  RE: How to take online and playout a scene automatically when data conditions are met

    Posted 10-09-2025 21:52
    OK one last wrinkle.
    I didn't notice earlier, but the script only works if my cursor is on the setup page takeitem in the sequencer.  The moment I go to do other stuff, the setup page updates (live updates is on), but it does not trigger the graphic.  The minute I get back to it, it triggers.

    Ideas?







  • 19.  RE: How to take online and playout a scene automatically when data conditions are met

    Posted 10-10-2025 04:03

    Share your entire script with me.



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



  • 20.  RE: How to take online and playout a scene automatically when data conditions are met

    Posted 10-11-2025 14:53
    So far I have a trigger scene, which will always be online.

    The idea is that whenever the data changes and the two conditions (SpeedData under 95 and TriCode=MTL) are met, this scene would trigger another scene to play out with the correct info on it (i.e. the name of a Montréal player and the speed of the shot). 

    Here is my script which I am using in my trigger scene, playing out TakeItem 5 (in theory) whenever the SpeedData changes (OnSetText) and conditions are met:


    What happens:

    • Take Item 5 plays out regardless of conditions whenever I click on the Trigger page in the sequencer.  I don't even have to put it online.  I don't want this to happen ever.
    • Once I put the Trigger page online, if the data changes, it does not play out the first shot that meets the conditions.
    • After that it plays out correctly until a condition changes.  Then it gets 1 wrong, and continues correctly until conditions change again.

    I think the trigger is happening before the conditions are being evaluated.  I think that happens every time, which is why when two shots occur back-to-back with similar conditions, it is accurate, but not if conditions differ from one shot to the next.

    I am going crazy trying to figure this out!  

    Any insights you might have would be most welcome.

    Thanks again for your help.

    Sonja

    Anna Sophia (Sonja) Broomfield
    (514) 803-6662





  • 21.  RE: How to take online and playout a scene automatically when data conditions are met

    Posted 10-12-2025 05:53

    On set text will always play first time it goes on air unless you use the check script I already provided above? 

    The way you have this written it will play if either of those condition are met, you haven't written it in a way that requires both to be true. 

    Please show me the example where you have also included the check script I provided? 



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



  • 22.  RE: How to take online and playout a scene automatically when data conditions are met

    Posted 10-12-2025 06:07
      |   view attached

    Yes sorry, I copied the script that I had on the Speed trigger.  This is the one on the Scene.  I put it on Preview Render because it's the only one that doesn't seem to screw up.  But it still plays anything when I focus on it.  And it still updates when the data changes while the scene is on the air.  I did try to come up with a single criteria, by making a TakeItem that incorporates both in Visual Logic (MTLSpeedShot=500(if TriCode=MTL)+95(minimum speed, so if MTLSpeedShot>=595 it can go on air on SetText in MTLSpeedShot).  But I still think Visual Logic is processed after the scene is triggered.  In any case it doesn't work.



    ------------------------------
    Sonja Broomfield
    On-Air graphics (Duet & Xpression)
    Freelance
    Canada
    ------------------------------



  • 23.  RE: How to take online and playout a scene automatically when data conditions are met

    Posted 10-12-2025 06:09

    could you copy and paste the script here rather than a screen shot, then I don't have to write the script from scratch to help :)



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



  • 24.  RE: How to take online and playout a scene automatically when data conditions are met

    Posted 10-12-2025 06:21

    dim otherScene as xpScene
    dim fb as xpOutputFramebuffer
    dim layer as integer = "5"
    engine.GetOutputFramebuffer(0, fb)
    if fb.GetSceneOnLayer(layer, otherScene)

    ' do nothing

    else

    ' your script here

    Dim probe as xpTextObject
    ' Check the conditions
    If Self.GetObjectByName("Tricode",probe) then
    If probe.Text <> "MTL" then Exit Sub
    End If

    If Self.GetObjectByName("SpeedData",probe) then
    If val(probe.Text) < 95 then Exit Sub
    End If

    ' So we know know that all conditions are met
    ' Let´s call up TakeItem 5
    dim takeitem as xpTakeItem
    engine.sequencer.GetTakeitemByID(5, takeitem)
    takeitem.Execute

    end if



    ------------------------------
    Sonja Broomfield
    On-Air graphics (Duet & Xpression)
    Freelance
    Canada
    ------------------------------



  • 25.  RE: How to take online and playout a scene automatically when data conditions are met

    Posted 10-12-2025 06:31

    Here is the one with the single condition:

    dim otherScene as xpScene
    dim fb as xpOutputFramebuffer
    dim layer as integer = "5"
    engine.GetOutputFramebuffer(0, fb)
    if fb.GetSceneOnLayer(layer, otherScene)

    ' do nothing

    else

    ' your script here

    Dim probe as xpTextObject
    ' Check the conditions
    If Self.GetObjectByName("MTLSpeedShot",probe) then
    If val(probe.Text) < 595 then Exit Sub
    End If

    ' So we know know that all conditions are met
    ' Let´s call up TakeItem 5
    dim takeitem as xpTakeItem
    engine.sequencer.GetTakeitemByID(5, takeitem)
    takeitem.Execute

    end if



    ------------------------------
    Sonja Broomfield
    On-Air graphics (Duet & Xpression)
    Freelance
    Canada
    ------------------------------



  • 26.  RE: How to take online and playout a scene automatically when data conditions are met
    Best Answer

    Posted 10-12-2025 06:41
    Because of how you have it written I think the script is stopping as soon as one isn't true. 

    Try this. 

    Dim otherScene As xpScene
    Dim fb As xpOutputFramebuffer
    Dim layer As Integer
    layer = 5
     
    engine.GetOutputFramebuffer(0, fb)
     
    If fb.GetSceneOnLayer(layer, otherScene) Then
        ' Scene already on layer 5, do nothing
    Else
        Dim probe As xpTextObject
        Dim tricodeOK As Boolean
        Dim speedOK As Boolean
     
        tricodeOK = False
        speedOK = False
     
        ' --- Check Tricode ---
        If Self.GetObjectByName("Tricode", probe) Then
            If probe.Text = "MTL" Then
                tricodeOK = True
            End If
        End If
     
        ' --- Check SpeedData ---
        If Self.GetObjectByName("SpeedData", probe) Then
            If Val(probe.Text) >= 95 Then
                speedOK = True
            End If
        End If
     
        ' --- Both must be true ---
        If tricodeOK And speedOK Then
            Dim takeitem As xpTakeItem
            engine.sequencer.GetTakeItemByID(5, takeitem)
            takeitem.Execute
        End If
    End If



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



  • 27.  RE: How to take online and playout a scene automatically when data conditions are met

    Posted 10-12-2025 07:12

    Yes! This works perfectly, thank you, no more issues on the trigger! 

    Two remaining problems: 

    1) where to put the script.  OnPreviewRender means I have to keep my focus on the trigger page.  I have tried the other ones, but nothing seems to work while I am playing out other stuff (on other fbs & layers).  I want to just put the trigger on air at the beginning of the night and forget about it.  Any idea where it should go?

    2) The animation page has live updates turned off on the data objects, but it still updates the player and speed on air if the scene is triggered by two shots close together (less than 5 seconds apart).  Thankfully it doesn't happen if conditions aren't met, so it shouldn't be a huge problem.

    Thanks again Simon.  I've just been enjoying your Ross U lesson on Transition Logic. :) 



    ------------------------------
    Sonja Broomfield
    On-Air graphics (Duet & Xpression)
    Freelance
    Canada
    ------------------------------



  • 28.  RE: How to take online and playout a scene automatically when data conditions are met

    Posted 10-12-2025 07:24

    I would put it onSetText of the speed data text object.

    You need to change "Self" to "Scene" in the script.


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



  • 29.  RE: How to take online and playout a scene automatically when data conditions are met

    Posted 10-12-2025 07:42

    That did it!  It still triggers when I click on the trigger, but it also plays out when I'm on other stuff.  Just need to keep paws off the trigger during the show!  Thanks so much, this was a really valuable experience for me.



    ------------------------------
    Sonja Broomfield
    On-Air graphics (Duet & Xpression)
    Freelance
    Canada
    ------------------------------



  • 30.  RE: How to take online and playout a scene automatically when data conditions are met

    Posted 10-12-2025 07:45

    Have you removed it from on preview render?



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



  • 31.  RE: How to take online and playout a scene automatically when data conditions are met

    Posted 10-12-2025 08:06

    Yes.  I guess ON SET TEXT is triggered when you focus on the scene, whether it is played out or not.



    ------------------------------
    Sonja Broomfield
    On-Air graphics (Duet & Xpression)
    Freelance
    Canada
    ------------------------------



  • 32.  RE: How to take online and playout a scene automatically when data conditions are met

    Posted 10-12-2025 08:58

    No idea why, but the problem has resurfaced.  I haven't changed anything since it worked after I changed the script.
    It is once again skipping one trigger when conditions change.  I am mystified.  I am rebooting.



    ------------------------------
    Sonja Broomfield
    On-Air graphics (Duet & Xpression)
    Freelance
    Canada
    ------------------------------



  • 33.  RE: How to take online and playout a scene automatically when data conditions are met

    Posted 10-12-2025 09:00

    Are you using debug messages and debug monitor to check what the script is doing? 



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



  • 34.  RE: How to take online and playout a scene automatically when data conditions are met

    Posted 10-12-2025 13:23

    I have no idea how to do that.



    ------------------------------
    Sonja Broomfield
    On-Air graphics (Duet & Xpression)
    Freelance
    Canada
    ------------------------------



  • 35.  RE: How to take online and playout a scene automatically when data conditions are met

    Posted 10-12-2025 13:56

    Ah no worries, I tried to script without it at first but then realise debugging is an important part of script writing. Doing it without is a bit like designing graphics without a monitor.

    In preferences, advanced, you should switch on "debug monitor" 

    Then in your scripts you can add the message engine.debugmessage("my message here", 0)

    That way you can figure out where you script is breaking. 



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