What is Scripted Output ?

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

  1. Translate period text
  2. Combine fields
  3. Add zeros, delimiters, etc
  4. Add or subtract fields
  5. Output custom information (even text) based on the value of one or more fields
  6. Add custom validation, so that you dont send “rubbish” values to GFX engine
  7. Validate against the previous field value
  8. Trigger show/hide actions on graphics engine based on a value of a field
  9. Tell your GFX engine to display an image based on field value (depends on GFX engine)

How to make it work ?

  1. Make sure you have the latest version installed. Update if needed
  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. The fields used by script have to be created for script to work.
  6. Click 'Ok'
  7. As the digits change, you should see the script working
  8. If scripted field displays 'script error':
    1. move your mouse over the script field to see the error message
    2. check if the source fields have been created
    3. 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"].size() > 0) {
if (field["period"] == "0") {
    output = "not started"
} else if (field["period"] == "1") {    
    output = "period 1"
} else if (field["period"] == "2") {    
    output = "period 2"
} else if (field["period"] == "3") {    
    output = "period 3"
} else if (number(field["period"]) > 3) {    
    output = "overtime"
}
}
else {    
    output = ""
}

—-

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

output = "";
if (field["down"] == "" || field["distance"] == "" || number(field["down"]) >= 5 || number(field["down"]) == 0) {
    output = ""
} else {    
	if (field["down"][0] == "1") {    
		output = "1st"
	} else if (field["down"][0] == "2") {    
		output = "2nd"
	} else if (field["down"][0] == "3") {    
		output = "3rd"
	} else if (field["down"][0] == "4") {    
		output = "4th"
	} 
    output = output + " " + "%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"].size() > 0) {
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 = "C:\\Samples\\transparent.png"
}
}
else
{
    output = "C:\\Samples\\transparent.png"
}

Here are some additional instructions for vMix


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

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

Here are some additional instructions for vMix


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(field["score_a"]) - number(old["score_a"]) == 3) {    
    output = "C:\\Samples\\3pts.png"
} else {    
    output = "C:\\Samples\\transparent.png"
}

Here are some additional instructions for vMix
You will need at least version 21.02.18 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 = "C:\\Samples\\transparent.png"
    }
} else {    
    output = "C:\\Samples\\transparent.png"
}

Here are some additional instructions for vMix


15. Check if period shows 'E' and output nothing (depends on the positioning of 'E')

if (field["period"].size() > 0) {
  if (number(field["period"][0]  + "") > 4)  {
    output = ""
} else {    

if (field["period"][0] == "0") {
    output = ""
} else if (field["period"][0] == "1") {    
    output = "1st"
} else if (field["period"][0] == "2") {    
    output = "2nd"
} else if (field["period"][0] == "3") {    
    output = "3rd"
} else if (field["period"][0] == "4") {    
    output = "OT"
}

}
} else {    
    output = ""
}

- Assumption is that 'E' will be recognized as '6'. If there is a different symbol instead of 'E', this might not work.
- This should also work if there are two symbols such as '1Q'


16. How to show/hide timeout indicator in Singular.live?

if (field["HomeTeamFoul"].size() > 0) {
if (number(field["HomeTeamFoul"]) >= 1)
  {    
    output = "true"
  }
else {
    output = ""
}
}
else {
    output = ""
}

- You can use “Glass” basketball template from Singular.live marketplace
- The object we are trying to control is a checkbox Control Field that is labeled “team1Timeout1”
- That checkbox is linked a visibility checkbox that turns on and off the layer visibility for the timeout indicator


17. How to create custom format and add character ?

if (field["test1"].size() > 0) {
if (field["test1"].size() == 3) {
output = field["test1"][field["test1"].size() - 3] + "";
}
else {
output = "";
}
output = output + field["test1"][field["test1"].size() - 2] + ".";
output = output + field["test1"][field["test1"].size() - 1] + "k";
}
else {
output = "";
}


17. Output score after end of every period

if(field["period"] == "2nd"){
output = field["score_a"]
}

You need at least version 21.02.18 installed


18. Output custom time format based on number of digits (box production)

if (field["time"].size() == 3) {
output = field["time"][field["time"].size() - 3] + ":" + field["time"][field["time"].size() - 2] + field["time"][field["time"].size() - 1];
}
else if (field["time"].size() == 4) {
output = field["time"][field["time"].size() - 4] + ":" + field["time"][field["time"].size() - 3] + field["time"][field["time"].size() - 2] + "." + field["time"][field["time"].size() - 1];
}
else {
output = "";
}

-if there are 3 digits, then output m:ss
-if there are 4 digits, then output m:ss.d
-make sure you choose 'Custom' format for time and check 'Output leading zeros' checkbox

NOT YET IMPLEMENTED


19. How to display Time (h:mm:ss) format ?

output = "";
if (field["test1"].size() >= 6) {
	output = output + field["test1"][field["test1"].size() - 6];
}
if (field["test1"].size() >= 5) {
	output = output + field["test1"][field["test1"].size() - 5];
}
else {
	output = output + "0";
}
output = output  + ":";
if (field["test1"].size() >= 4) {
	output = output + field["test1"][field["test1"].size() - 4];
}
else {
	output = output + "0";
}
if (field["test1"].size() >= 3) {
	output = output + field["test1"][field["test1"].size() - 3];
}
else {
	output = output + "0";
}
output = output  + ":";
if (field["test1"].size() >= 2) {
	output = output + field["test1"][field["test1"].size() - 2];
}
else {
	output = output + "0";
}
if (field["test1"].size() >= 1) {
	output = output + field["test1"][field["test1"].size() - 1];
}
else {
	output = output + "0";
}

-Its important that you use “Custom” format for the source field


20. How to convert Time (mm:ss, ss.d) to Time (mm:ss, m:ss.d)?

output = field["time"];
if (field["time"].size() > 0) {
	if (field["time"][field["time"].size() - 2] == ".") {
		if (output.size() == 3) {
			output = "0:0" + field["time"]
		}
		else if (output.size() == 4) {
			output = "0:" + field["time"]
		}
	}
	else {
		output = field["time"];
	}	
}
else {
	output = "";
}

21. How to convert basketball Shot Clock (ss, s.d) to Shot Clock (ss) ?

output = field["shot"];
if (field["shot"].size() > 1) {
	if (field["shot"][field["shot"].size() - 2] == ".") {
		output = field["shot"][0] + "";
	}
	else {
		output = field["shot"];
	}	
}
else if (field["shot"].size() == 0) {
	output = "";
}

22. How to display voleyball serve direction in vMix ?

  1. add one symbol type field for each team server direction 'serve_a' and 'serve_b'
  2. draw a rectangle around serve direction for each respective symbol field
  3. add one Script field for each team 'serve_a.Source' and 'serve_b.Source' and use the script below for each field
  4. make sure you save a the serve direction picture 'serve.png' in the folder mentioned in the script below
  5. make sure you save transaprent picture 'transparent.png' in the folder mentioned in the script below
  6. in vMix Title Designer add two image fields to your scorebug and name them 'serve_a' and 'serve_b'

Here are some additional instructions for vMix

if (field["serve_a"] == "1") {    
    output = "C:\\Samples\\serve.png"
} else {    
    output = "C:\\Samples\\transparent.png"
}

23. How to hide time when it reaches zero ?

if (field["BreakTime"].size() > 0) {
if ((field["BreakTime"] == "0:00") || (field["BreakTime"] == "0.0"))
  {    
    output = "";
  }
else {
    output = field["BreakTime"];
}
}
else {
    output = "";
}

24. How to cycle between Time (h:mm:ss.d) and Time (h:mm:ss.dd) format (swimming, athletics) ?

output = "";
if (field["test1"].size() == 6) {
	output = output + field["test1"][field["test1"].size() - 6] + ":";
}
if (field["test1"].size() >= 5) {
	output = output + field["test1"][field["test1"].size() - 5];
}
if (field["test1"].size() >= 4) {
	output = output + field["test1"][field["test1"].size() - 4]  + ":";
}
if (field["test1"].size() >= 3) {
	output = output + field["test1"][field["test1"].size() - 3];
}
if (field["test1"].size() >= 2) {
	output = output + field["test1"][field["test1"].size() - 2];
}
else {
	output = output + "0";
}
output = output  + ".";
if (field["test1"].size() >= 1) {
	output = output + field["test1"][field["test1"].size() - 1];
}
else {
	output = output + "0";
}
if (field["test2"].size() == 1) {
	output = output + field["test2"];
}

Assumption - usually in athletics and swimming clock running is in h:mm:ss.d format, but when it stops it changes to h:mm:ss.dd format
-create two custom fields test1 and test2
-add all h:mm:ss.d digits to test1 (do not add the 1/100th of the second)
-add only 1/100th of the second to test2 field


25. How to display static Time (mm:ss.dd) (swimming) ?

output = "";
if (field["test1"].size() == 6) {
	output = output + field["test1"][field["test1"].size() - 6];
}
if (field["test1"].size() >= 5) {
	output = output + field["test1"][field["test1"].size() - 5] + ":";
}
if (field["test1"].size() >= 4) {
	output = output + field["test1"][field["test1"].size() - 4];
}
if (field["test1"].size() >= 3) {
	output = output + field["test1"][field["test1"].size() - 3]  + ".";
}
if (field["test1"].size() >= 2) {
	output = output + field["test1"][field["test1"].size() - 2];
}
if (field["test1"].size() >= 1) {
	output = output + field["test1"][field["test1"].size() - 1];
}

No normal camera can capture 100 frames per second, so it is impossible to display 1/100 of a second, but in many cases the time runs at rate of 1/10 and 1/100 is only displayed as a static clock, which can be easily read by Scoreboarc OCR and a standard camera. Here is how to make it happen:

  1. Make sure you add field named 'test1', choose Custom type and add all digis that display m:ss:dd
  2. Add Scripted field and copy/paste the script from above

26. Another American Football script example

if (number(field["HF"]) == number(field["VF"])) {
output = "No Advantage"
} else if (number(field["HF"]) > number(field["VF"])) {
output = "Adv. " + (field["HomeTeam"])
} else if (number(field["HF"]) < number(field["VF"])) {
output = "Adv. " + (field["HomeTeam"])
}

27. Combine two fields and add "-" in between them

      output = field["score2"]  + "-" + field["score1"]
  1. create two fields score1 and score2 and add respective scores
  2. create new fields and choose type Script and add the script from above

28. How to display sss.dd format?

output = "";
if (field["test1"].size() == 5) {
	output = output + field["test1"][field["test1"].size() - 5];
}
if (field["test1"].size() >= 4) {
	output = output + field["test1"][field["test1"].size() - 4];
}
if (field["test1"].size() >= 3) {
	output = output + field["test1"][field["test1"].size() - 3];
}
else {
	output = output + "0";
}
output = output  + ".";
if (field["test1"].size() >= 2) {
	output = output + field["test1"][field["test1"].size() - 2];
}
else {
	output = output + "0";
}
if (field["test1"].size() >= 1) {
	output = output + field["test1"][field["test1"].size() - 1];
}
else {
	output = output + "0";
}

-Its important that you use “Custom” format for the source field


29. How to output 'OT' for the 4th period?

if (field["period"].size() > 0) {
  if (number(field["period"][0]  + "") > 4)  {
    output = ""
} else {    

if (field["period"][0] == "0") {
    output = ""
} else if (field["period"][0] == "1") {    
    output = "1st"
} else if (field["period"][0] == "2") {    
    output = "2nd"
} else if (field["period"][0] == "3") {    
    output = "3rd"
} else if (field["period"][0] == "4") {    
    output = "OT"
}

}
} else {    
    output = ""
}

30. Output "0", if field is blank

if (field["field1"] == "") {
    output = "0"
} else {    
    output = field["field1"]
}

31. Convert number to xxx.xx km/h

output = "";
if (field["test1"].size() >= 5) {
	output = output + field["test1"][field["test1"].size() - 5];
}
if (field["test1"].size() >= 4) {
	output = output + field["test1"][field["test1"].size() - 4];
}
if (field["test1"].size() >= 3) {
	output = output + field["test1"][field["test1"].size() - 3]  + ".";
} else {
	output = "0.";
}
if (field["test1"].size() >= 2) {
	output = output + field["test1"][field["test1"].size() - 2];
} else {
	output = output + "0";
}
if (field["test1"].size() >= 1) {
	output = output + field["test1"][field["test1"].size() - 1] + " km/sec";
}

32. Convert number to x.xxxx

output = "";
if (field["test1"].size() >= 7) {
	output = output + field["test1"][field["test1"].size() - 7];
}
if (field["test1"].size() >= 6) {
	output = output + field["test1"][field["test1"].size() - 6];
}
if (field["test1"].size() >= 5) {
	output = output + field["test1"][field["test1"].size() - 5];
}
else {
	output = output + "0";
}
output = output  + ".";

if (field["test1"].size() >= 4) {
	output = output + field["test1"][field["test1"].size() - 4];
}
else {
	output = output + "0";
}
if (field["test1"].size() >= 3) {
	output = output + field["test1"][field["test1"].size() - 3];
}
else {
	output = output + "0";
}
if (field["test1"].size() >= 2) {
	output = output + field["test1"][field["test1"].size() - 2];
}
else {
	output = output + "0";
}
if (field["test1"].size() >= 1) {
	output = output + field["test1"][field["test1"].size() - 1];
}
else {
	output = output + "0";
}


33. How to display Time (ss.ddd) format (climbing) ?

output = "";
if (field["test1"].size() == 5) {
	output = output + field["test1"][field["test1"].size() - 5];
}
if (field["test1"].size() >= 4) {
	output = output + field["test1"][field["test1"].size() - 4]  + ".";
}
if (field["test1"].size() >= 3) {
	output = output + field["test1"][field["test1"].size() - 3];
}
if (field["test1"].size() >= 2) {
	output = output + field["test1"][field["test1"].size() - 2];
}
if (field["test1"].size() >= 1) {
	output = output + field["test1"][field["test1"].size() - 1];
}
if (field["test1"].size() == 3) {
	output = "0." + output;
}
if (field["test1"].size() == 0) {
	output = "0.000";
}

-Its important that you use “Custom” format for the source field


34. How to add +/- in front of the time ?

if (field["sign"] == "0") {
    output = "-" + field["time"]
} else {    
    output = "+" + field["time"]
}


35. Convert number to xxx.xxx

output = "";
if (field["test1"].size() >= 8) {
	output = output + field["test1"][field["test1"].size() - 8];
}
if (field["test1"].size() >= 7) {
	output = output + field["test1"][field["test1"].size() - 7];
}
if (field["test1"].size() >= 6) {
	output = output + field["test1"][field["test1"].size() - 6];
}
if (field["test1"].size() >= 5) {
	output = output + field["test1"][field["test1"].size() - 5];
}
if (field["test1"].size() >= 4) {
	output = output + field["test1"][field["test1"].size() - 4];
}
else {
	output = output + "0";
}
output = output  + ".";

if (field["test1"].size() >= 3) {
	output = output + field["test1"][field["test1"].size() - 3];
}
else {
	output = output + "0";
}
if (field["test1"].size() >= 2) {
	output = output + field["test1"][field["test1"].size() - 2];
}
else {
	output = output + "0";
}
if (field["test1"].size() >= 1) {
	output = output + field["test1"][field["test1"].size() - 1];
}
else {
	output = output + "0";
}

36. How to output OT when OVERTIME is displayed on the screen?

if (number(field["overtime"]) == 0) {
    output = "OT"
} else {    
    output = ""
}

Since “O” looks like “0” (zero), we can recognize it, so you need to mark only the first letter of word “OVERTIME”.



If need any help with creating your custom script, just send us an email to ocr@scoreboard-ocr.com