Accesso rapido:  

Forum: General Discussion

Topic: Can you generate random values?
bibi-bPRO InfinityMember since 2022
Hi there,

is it possible to generate a random number (best between 0 and 255) with a script?

Reason: I want to set a DMX fixture with a random value every beat by OS2L.

 

Inviato Fri 17 Feb 23 @ 12:19 pm
No, there's no random seed generator.
However, I guess you could query something like volume (get_level), and multiply it with something like seconds elapsed to get a pseudorandom seed.
 

Inviato Fri 17 Feb 23 @ 2:09 pm
SepatroPRO InfinityMember since 2019
That sounds like an interesting experiment. A common way to generate (pseudo-)random values is to indeed take some kind of variable (as you suggest, get_level, or something else like get_cpu) and then mutiply that by a very large number and then use the MOD operator. But I can't find which operators are supported in VDJ script... (e.g. MOD).
 

Inviato Sun 19 Feb 23 @ 2:23 pm
locoDogPRO InfinityModeratorMember since 2013
param_mod is a thing
 

Inviato Sun 19 Feb 23 @ 8:31 pm
AdionPRO InfinityCTOMember since 2006
Although the required operations are indeed there (param_multiply, param_add, param_mod) it looks like the most basic random number generators require operations on 32-bit unsigned integers, and because vdj internally uses floating point for the param_ operations they don't seem to get the right result when i tried some.
 

Inviato Mon 20 Feb 23 @ 5:54 am
seanPRO InfinityMember since 2018
I had the same use case as @bibi-b, sending random numbers to OS2L.

I accidentally wrote this code and have no idea why it works, ... but it seems to be enough to meet my usecase, a random "enough" number between 1-10. It requires a song to be playing to work because it uses get_time:

get_time & param_cast & get_time & param_mod 10 & param_add 1 & param_cast & debug
 

Inviato Thu 26 Sep 24 @ 6:57 pm