[Closed] Binary generator 0000001 input
Dont know scripting yet, starting to learn, just wondering if its possible with max script to make a random changing binary number generator using the max text function ? How would i set the random function ?
TIA
I’m not in front of max so this is untested, but maybe something like…
fn randBinary len =
(
str = ""
for i in 1 to len do
(
str += (random 0 1) as string
)
str
)
binaryString = randBinary 8
print binaryString
textObj = text()
textObj.text = binaryString
If you’re building a lots of these or they’re very long, you might want to look into StringStreams instead of appending to the string.
Cheers,
Drea
Hi,
In simplification you can always get representation of any number in any number system i.e binary system. So, the idea could be to generate random number in hex (the simplest convertion) and convert it to bin – or you want to change randomly bit(s) in existing number ?
print ( random 0 0xFFE0 ) --in hex is the same :
print ( random 0 65504 ) --in decimal
In maxscript I think you can’t use bin representation of numbers so you can only store it as string but thers’s direct access to bits of numbers, see Value > Basic Data Values > Number Values in max script help.
jk
This is great, thanks, now i just need to figure out how to loop it and control its speed !