logo

Live Production Software Forums


Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

Options
Go to last post Go to first unread
MSFTGuruGuy  
#1 Posted : Saturday, September 13, 2025 1:16:43 PM(UTC)
MSFTGuruGuy

Rank: Advanced Member

Groups: Registered
Joined: 5/1/2020(UTC)
Posts: 33
United States
Location: Tennessee

Thanks: 1 times
Was thanked: 1 time(s) in 1 post(s)
Hey All! I was curious if anyone has a simple scripting solution to continuously check whether or not a data source is positive and if it's not, take the abs of it and replace the data feed with the abs of that number. I've tried to use 'newnumber = math.abs(oldnumber)' and then using 'API.Function("SetText",Input:=scoreboard , Value:=newballon, SelectedName:="Ballon.Text")'
but running that in a continuous script seems to be producing no solution. The Context is I have a scoreboard sending Vmix a JSON data stream in American Football. Depending on field position the ball location, the scoreboard will send a negative number for field position. I've been trying to find the right set of commands to right a script but it seems to evade me. Thanks in advance, and I did look at the scripting for dummies and didn't see any math examples.

Kris
doggy  
#2 Posted : Saturday, September 13, 2025 5:08:50 PM(UTC)
doggy

Rank: Advanced Member

Groups: Registered
Joined: 12/27/2012(UTC)
Posts: 5,434
Belgium
Location: Belgium

Thanks: 309 times
Was thanked: 999 time(s) in 827 post(s)
Originally Posted by: MSFTGuruGuy Go to Quoted Post
Hey All! I was curious if anyone has a simple scripting solution to continuously check whether or not a data source is positive and if it's not, take the abs of it and replace the data feed with the abs of that number. I've tried to use 'newnumber = math.abs(oldnumber)' and then using 'API.Function("SetText",Input:=scoreboard , Value:=newballon, SelectedName:="Ballon.Text")'
but running that in a continuous script seems to be producing no solution. The Context is I have a scoreboard sending Vmix a JSON data stream in American Football. Depending on field position the ball location, the scoreboard will send a negative number for field position. I've been trying to find the right set of commands to right a script but it seems to evade me. Thanks in advance, and I did look at the scripting for dummies and didn't see any math examples.

Kris


First off spelling and writing commands when scripting(coding) is very important

commands to right a script ==> commands to write a script

When it comes to a script you don't mention how you are retrieving the value. In vMix scripting using vb.net one usually has to retrieve datasource data through a title (simplest way).
Do some logic or conversion on that and like in this case send to your title
And put the whole thing in a loop for repeated checking

Code:
Do While true

  Dim text as string = Input.Find("title.gtzip").Text("Headline.Text")

  Dim value As Integer = Integer.Parse(text)
        
  Dim abs1 As Integer = Math.Abs(value)
        
  API.Function("SetText",Input:="title.gtzip" , SelectedName:="Description.Text" , Value:=abs1)
 
  Sleep(500)

Loop

' or for short

Do While true

    API.Function("SetText",Input:="title.gtzip" , SelectedName:="Description.Text" , Value:=Math.Abs(Integer.Parse(Input.Find("title.gtzip").Text("Headline.Text"))))
 
  Sleep(500)

Loop

thanks 1 user thanked doggy for this useful post.
MSFTGuruGuy on 9/13/2025(UTC)
MSFTGuruGuy  
#3 Posted : Saturday, September 13, 2025 11:47:15 PM(UTC)
MSFTGuruGuy

Rank: Advanced Member

Groups: Registered
Joined: 5/1/2020(UTC)
Posts: 33
United States
Location: Tennessee

Thanks: 1 times
Was thanked: 1 time(s) in 1 post(s)
Thanks Doggy Thanks for catching that typo of a fifth-grade homophone while I was juggling a conversation with my daughter about what was right and wrong to write in a birthday card. But you make a very good point, not only are spelling and writing commands important, equally is grammar.

spelling and writing commands when scripting(coding) is very important ==> spelling and writing commands when scripting(coding) are very important can also be very important.

This has two rules depending on the part of the world you are educated from; however, because spelling and writing are joined, we need to use the plural subject instead of the singular. It might feel better pairing these thoughts into a single combined idea; however, "are" is correct because they are two separate skills were referenced, but this is where the use of "is and "are" becomes dependent on the location where the education curriculum was initiated. :) In either way, it highlights the importance of leading with the right tone and it doesn't come across as a lecture or pontification as I'm sure this post has done already, so I'll apologize because I appreciate you. You probably would have rather just read the following and moved on.


I really appreciate all your help over the years; it's been so wonderful to have someone willing to support a worldwide community as a volunteer like you have. Again, you've expressed your masterful knowledge of this platform, and I know you have had countless thankyous, but I'll add one more. Thank you! I'll give this a try this morning and I'm sure (as most of your rescues) it will resolve the issue. I mentioned it was a JSON data feed leveraged in a title. I believe the common way for vMix to ingest a JSON data feed is by declaring it in the Data Sources Manager & making the association in the title editor. That was my mistake for assuming that's what anyone else might assume how the data is retrieved. Thanks again for the help and the hopeful read of the first part of this reply with a little jocular tone.


Kris
doggy  
#4 Posted : Sunday, September 14, 2025 12:23:24 AM(UTC)
doggy

Rank: Advanced Member

Groups: Registered
Joined: 12/27/2012(UTC)
Posts: 5,434
Belgium
Location: Belgium

Thanks: 309 times
Was thanked: 999 time(s) in 827 post(s)
Originally Posted by: MSFTGuruGuy Go to Quoted Post
Thanks again for the help and the hopeful read of the first part of this reply with a little jocular tone.


Kris


Of course I did as it's not my first (native) language ;-)

BTW I often use extra hidden fields in my titles exactly for such purposes (sort of reproces or customize such data for display)
Users browsing this topic
Guest (2)
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.