Show the Last Actions from a Timeline Row

This tutorial is specific to our newest product, Hudl Sportscode. If you’re on Sportscode v11, use these resources instead or upgrade today.

Example Used

In this example we will look to see which team ("Us" or "Them") had the last scoring "Chance".

How-to:

  1. Create buttons 1, 2 & 3 from the image below:

    • Button 1 - A label button with the button ID 'us'.
      This button is connected to button 3 by an activation link.
    • Button 2 - A label button with the button ID 'them'.
      This button is also connected to button 3 by an activation link.
    • Button 3 - A code button with a lead time of 2 seconds and a lag time of 2 seconds. This button has the button ID 'variable'.
      This button creates an instance on the timeline.
  2. Create buttons 4, 5 & 6 from the image above to form the Color Palette:

    • Button 4 - An inactive button with the button ID 'color1'.
      This button should be the same color as button 1.
    • Button 5 - An inactive button with the button ID 'color2'.
      This button should be the same color as button 2.
    • Button 6 - An inactive button with the button ID 'color3'.
      This Button should be a neutral color.
  3. Create button 7 from the image above to display who had the last chance in the 'variable' row:

    • Button 7 - An inactive button with the button ID "last1".

    Give button 7 the following script:

    button color #'color3'
    This script sets the button color as the neutral 'color3' from the Color Palette.

    $lastinstance = instances where row = #'variable' limit -1,-1
    The limit here is set to show the last instance added to the 'variable' row.

    $ourwin = count "Us" and $lastinstance
    $theirwin = count "Them" and $lastinstance
    These variables will count whether the last instance added to the row contains the label 'Us' or 'Them'.

    if($ourwin = 0, show "-")
    if($theirwin = 0, show "-")
    If there are no labels in the timeline 'variable' row instances then this button will display the '-' symbol.

    if($ourwin = 1, show "US")
    if($theirwin = 1, show "Them")

    if ($ourwin = 1, button color #'color1')
    if ($theirwin = 1, button color #'color2')

    The last two lines of script set the button color, dependent on which label is in the instance.

  4. Create buttons 8 & 9 from the image above. These buttons contain the same script as button 7, apart from line 3 of the script (see below script and image):

    • Button 8 - An inactive button with the button ID 'last2'.
      This button has the following script on line 3:
      $lastinstance = instances where row = #'variable' limit -2,-2

    The limit here is set to show the second last instance added to the 'variable' row.

    • Button 9 - An inactive button with the button ID 'last3'.
      This Button has the following script on line 3:
      $lastinstance = instances where row = #'variable' limit -3,-3

    The limit here is set to show the third last instance added to the 'variable' row.

  5. Create buttons 10 & 11 from the image above. These buttons contain the same script as button 7, apart from line 3 of the script (see below script and image):

    • Button 10 - An inactive button with the button ID 'last4'.
      This Button has the following script on line 3:
      $lastinstance = instances where row = #'variable' limit -4,-4

    The limit here is set to show the fourth last instance added to the 'variable' row.

    • Button 11 - An inactive button with the button ID 'last5'.
      This Button has the following script on line 3:
      $lastinstance = instances where row = #'variable' limit -5,-5

    The limit here is set to show the fifth last instance added to the 'variable' row.