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
  6. Validate against the previous field value

How to make it work ?

  1. Make sure you have at least version 20.09.29 installed
  2. Add field and choose 'Script' field type
  3. Select the field and click on 'Edit Script'
  4. Copy/paste one of the examples below or create your own script
  5. Makes sure you replace the field names in the script with your actual field names
  6. Click 'Ok'
  7. As the digits change, you should see the script working
  8. 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 (field["period"] == "0") {
    output = "not started"
} else if (field["period"] == "1") {    
    output = "period 1"
} else if (field["period"] == "2") {    
    output = "period 2"
} else {    
    output = "overtime"
}

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

if (field["down"] == "" || field["distance"] == "") {
    output = ""
} else {    
    output = field["down"]+ " " + "%26" + " " + field["distance"]
}

3. Show "BONUS" if fouls reach 5

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

4. Validate value before sending to GFX engine

if (number(field["score_a"]) <= 10) {
    output = field["score_a"]
}

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

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

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

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

8. Create text for a tweet

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

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

if (field["fouls_b"] == "1") {    
    output = "C:\\Samples\\fouls1.png"
} else if (field["fouls_b"] == "2") {    
    output = "C:\\Samples\\fouls2.png"
} else if (field["fouls_b"] == "3") {    
    output = "C:\\Samples\\fouls3.png"
} else if (field["fouls_b"] == "4") {    
    output = "C:\\Samples\\fouls4.png"
} else if (number(field["fouls_b"]) >= 5) {    
    output = "C:\\Samples\\fouls5.png"
} else {    
    output = ""
}

To update an image in vMix, you will have to:
- Add another output 'Multiple Text Files'
- Use the text file with path to image as data source in vMix for the respective image field

You no longer need to do this starting from version 20.10.09


10. Tell GFX engine to display a penaly clock background image, if penalty clock is active

if (field["penalty_a1"] == "") {    
    output = ""
} else {    
    output = "C:\\Samples\\penalty_background.png"
}

To update an image in vMix, you will have to:
- Add another output 'Multiple Text Files'
- Use the text file with path to image as data source in vMix for the respective image field

You no longer need to do this starting from version 20.10.09


11. Add padded zero to Time (mm:ss, ss.d) format

if (field["time"][1] ==':') {
    output = "0" + field["time"]
} else {    
    output = field["time"]
}

12. Tell GFX engine to display an image, if basketball score increases by +3

if (number(old["score_a"]) - number(field["score_a"]) == 3) {    
    output = "C:\\Samples\\3pts.png"
} else {    
    output = ""
}

You will need the version 20.10.28 installed for this to work.


13. Convert foorball match time from 0:00-20:00 to 0:00-65:00 based on period

output = field["time2"];
if (field["period"] == "2") {
    if (output.size() == 5) {
        output[output.size() - 5] = '3'
    }
    else if (output.size() == 4) {
        output = "2" + output
    }
}
else if (field["period"] == "3") {
    if (output.size() == 5) {
        output[output.size() - 5] = '5'
    }
    else if (output.size() == 4) {
        output = "4" + output
    }
}
else if (field["period"] == "4") {
    if (output.size() == 4) {
        output = "6" + output
    }
}

14. Show red background for basketball shot clock during last 5 seconds

if (field["shot_clock"].size() > 0) {    
    if ((number(field["shot_clock"]) < 6) || (field["shot_clock"].size() == 3)) {    
        output = "C:\\Samples\\red.png"
    } else {
        output = ""
    }
} else {    
    output = ""
}
scripted_output.txt · Last modified: 2020/11/06 18:46 by arturs