User Tools

Site Tools


scripted_output

What is Scripted Output ?

Scripted Output gives you total control of digit validation and format sent to GFX engine using scripting. Here is what you can do:

  1. Combine fields
  2. Add zeros, delimiters, etc
  3. Add or subtract fields
  4. Output custom information (even text) based on the value of one or more fields
  5. Add custom validation, so that you dont send “rubbish” values to GFX engine

How to make it work ?

First make sure that source fields do not contain dots, spaces or non-latin symbols. The sripted field has no limitations on field name syntax

  1. Add field and choose 'Script' field type
  2. Select the field and click on 'Edit Script'
  3. Copy/paste one of the examples below or create your own script
  4. Makes sure you replace the field names in the script with your actual field names
  5. Click 'Ok'
  6. As the digits change, you should see the script working
  7. If scripted field displays 'script error':
    1. check if the source fields have been created
    2. send us an email and we will help

We have provided some examples below, but feel free to send us an email and we will prepare one for your specific case.


1. Create custom period output

if (period == "0") {
    output = "not started"
} else if (period == "1") {    
    output = "period 1"
} else if (period == "2") {    
    output = "period 2"
} else {    
    output = "overtime"
}

2. Combine two fields and add "&" if they are not empty (American football)

if (down == "" || distance == "") {
    output = ""
} else {    
    output = down + " " + "&" + " " + distance
}

3. Show "BONUS" if fouls reach 5

if (number(fouls_a) >= 5) {
    output = "BONUS"
} else {    
    output = fouls_a
}

4. Validate value before sending to GFX engine

if (number(shot_clock) <= 24) {
    output = shot_clock
}

5. Change delimiter for Time (mm:ss -> mm.ss)

output = down;
output[output.size() - 3] = '.';

6. Create padding with zeros so that you send "04" to GFX engine

if (number(score_a) < 10)  {
    output = "0" + score_a
} else {    
    output = score_a
}

8. Create text for a tweet

output = "Home team just scored and is leading " + score_a " over " + score_b 

9. Tell GFX engine to display a certain image for every foul count

if (fouls_b == "1") {    
    output = "fouls1.png"
} else if (fouls_b == "2") {    
    output = "fouls2.png"
} else if (fouls_b == "3") {    
    output = "fouls3.png"
} else if (fouls_b == "4") {    
    output = "fouls4.png"
} else if (fouls_b >= "5") {    
    output = "fouls5.png"
} else {    
    output = ""
}
scripted_output.txt · Last modified: 2020/09/18 20:34 by arturs