How do I randomize the state of a Switch?

Discuss problems and solutions.
Post Reply
danielmkarlsson
Newbie
Posts: 2
Joined: 08 Feb 2013 05:06

How do I randomize the state of a Switch?

Post by danielmkarlsson »

Hello.
I would like to randomize the state of a switch w/ a pad.
I'd be very grateful for any help I can get.

All the best

Daniel M Karlsson
Attachments
RandSwitchState.jzml
Randomize switch state
(7.54 KiB) Downloaded 63 times
brianc
Regular
Posts: 87
Joined: 10 Jan 2012 02:16

Re: How do I randomize the state of a Switch?

Post by brianc »

The x value for a switch can only be 0 or 1. rand() gives you a number between 0 and 1 that is not likely exactly 0 or 1. You can fix this in your script by rounding the random value:

Code: Select all

UltraSoloSwitch.x=round(rand());
danielmkarlsson
Newbie
Posts: 2
Joined: 08 Feb 2013 05:06

Re: How do I randomize the state of a Switch?

Post by danielmkarlsson »

Right. Integers and floats.
Works like a charm now.
Thank you very much for your help brianc.
Post Reply