generate random number

Christie Widget Designer Version 6 - Q&A

Moderator: Moderator Group

Forum rules
When asking make sure to include the operating system and the revision of Widget Designer you are using.

generate random number

Postby videodsh » Tue Jan 09, 2024 5:07 pm

Hey guys,

maybe one of you creative programmers has an idea how to solve this:

i need widgetdesgner to switch my ATEM PGM BUS every 5 seconds to another source. (between Inputs 1-5)
My idea was to create a generator node wich wil generate random numbers between 1 and 5 an a script timer to execute the ATEM switching.

Switching works fine, but what happens is that the random number sometimes is the same as the previous one. so in fact there is no switching.
You understand, what I mean?

so I need to find a way to generate a number between 1 and 5 wich MUST be different from previous number.


In a second step i need to exclude one or more numbers, lets say just switch between Cam 3,4 and 5, or 1,3,4 etc.

I would like to have 5 toggle Buttons named Cam 1 to Cam 5 and press them in order to be part of the random thing.

Maybe anyone has an idea.

thanks in advance

cheers
videodsh
 
Posts: 34
Joined: Sat Apr 23, 2016 6:52 pm
Location: Düsseldorf, Germany

Re: generate random number

Postby satanete666 » Wed Jan 10, 2024 7:56 am

i think the easyest way is to do is to store the last value in a global variable and in you re script timer do a if else sentece where you can see if the new number is the same that you have store in the variable then you can substract or add value to this number to be different.

Regards
satanete666
 
Posts: 193
Joined: Fri May 20, 2011 5:20 pm

Re: generate random number

Postby videodsh » Wed Jan 10, 2024 2:07 pm

var_mix = Math.Random(1,6)

Label1.text = var_mix

if var_mix = var_lastnumber {
WDCustomScriptClick(5)

Good advice, my workaround is now a customscript button
the on Click script puts the last value into var_lastnumber
the on release script generates a number, compares it to the var_lastnumber and repeats if both values are the same.

working , half way done, but now comes the tricky part

math.random generates a random number within the boundaries (min,max)
but I need to choose a number of a pre-defined list i.e. 1,2,5 or 2,3,4,5

Any Idea on that
videodsh
 
Posts: 34
Joined: Sat Apr 23, 2016 6:52 pm
Location: Düsseldorf, Germany

Re: generate random number

Postby Daniel Kaminski » Thu Jan 11, 2024 2:37 am

Nice Challange.

I would create an Array that holds all the ID of the Cameras you can Switch.
Than you only need to remove the currently switched Camera from the Array and generate a random Number over the amount of elements of the array.

I created a small example how I would do it.

Feel free to use it and feedback and questions are welcome.

Daniel
You do not have the required permissions to view the files attached to this post.
--
Daniel Kaminski
Pandoras Box Expert
User avatar
Daniel Kaminski
 
Posts: 1071
Joined: Tue Jul 22, 2008 10:55 am
Location: Herten, Germany


Return to Widget Designer V6

Who is online

Users browsing this forum: No registered users and 69 guests