Add Time as a Label

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

This is a live workflow button template for soccer.


How-to:

  1. Create two code buttons from the image below:

    • Button 1 - A code button with a lead time of 0.5 seconds and a lag time of 0.5 seconds. This button has the button ID "start".
      This button is activated at the start of each half.
    • Button 2 - A code button with a lead time of 0 seconds and a lag time of 59 seconds. This button has the button ID "minute".
      This button creates one minute instances on the timeline.

    Buttons 1 & 2 do not require scripting. Use an activation link to connect button 1 to button 2.

  2. Create button 3 as shown in the image above. It is an action (toggle) button with the Button ID "clock_tog".

  3. Give button 3 the following script:

    $a = count instances where row = "START"
    if ($a = 0, exit)
    if ($a = 2, exit)
    if ($a = 4, exit)

    if (button #'minute' state = 1, push button up)
    if (button #'minute' state = 1, exit)

    if (button #'minute' state = 0, push button down)

    Use an activation link to connect button 3 to button 2. An action button can either "make movie" or "toggle", be sure to select the correct one.

  4. Create button 4 as shown in the image above. It is a label button with the Button ID "minute_count".

  5. Give button 4 the following script:

    $start1 = start instances where row = "START" limit 0,1
    $a = count instances where row = "MINUTE"
    $b = "MINUTE " + (1 + $a)

    This script will calculate the minutes of the first half.

    $start2 = start instances where row = "START" limit -1,-1
    $c = count instances where row = "MINUTE" and start time > $start2
    $d = "MINUTE " + (45 + $c)

    This script will calculate the minutes of the second half.

    $a = count instances where row = "START"
    if ($start1 = $start2, rename $b)
    if ($start2 > $start1, rename $d)

    The final 2 lines of script rename the label button to the appropriate minute.

  6. Create buttons 5 and 6 as shown in the image above:

    • Button 5 - A code button with a lead time of 2 seconds and a lag time of 3 seconds. This button has the Button ID "test_1".
      This button is activated at the start of each half.
    • Button 6 - A code button with a lead time of 2 seconds and a lag time of 3 seconds. This button has the Button ID "test_2'.

    Both of these buttons should have activation links going to button 4.

  7. Once pressed, these code buttons will create an instance on the timeline that will contain the minute the instance occurred in.

You can link further code buttons to the "Minute" label button as required.