Random Numbers

The Ygdrasil Random Number generator is part of the mathematics node. To use it, set the startValue and the endValue to define the range of random numbers you want; then, use the random message to produce a new random number. The changed event will, of course, tell you what the new random number is.

mathematics randomgenerator (
	startValue(0),endValue(100),
	when(changed,print($value))
)

wandTrigger (when(button1,randomgenerator.random))

A Random Beep Generator


sound beep (file("beep.aiff"))

mathematics randomgenerator (
	startValue(.25),endValue(5.0),
	when(changed,
		beep.play,
		random+$value
		),
	random
)

A Slot Machine

The random number generator is routed into a selector node, which switches between its children using the selectNum message. The random generator is set to produce only whole numbers, by using the integer message - this is because the selector node expects integers, not floating-point numbers.

selector slotmachine ()
{
	object (file("bell.pfb"))
	object (file("cherries.pfb"))
	object (file("star.pfb"))
	object (file("bar.pfb"))
	object (file("apple.pfb"))
	object (file("skull.pfb"))
}

mathematics randomgenerator (
	startValue(0),endValue(5),
	integer,
	when(changed,slotmachine.selectNum($value))
)


(c) Ben Chang