neillt
Active Member
Lupinglade and anyone else who might be able to help here....
I am trying to generate a whole-house vacation mode script to turn on random lights for random intervals during night time to give the house a "lived in" look.
The trouble I am having is with the Random class, I can't seem to figure out how to call it to generate a new Random object.
Stack Overflow had a good example of:
public static int randInt(int min, int max) {
// Usually this can be a field rather than a method variable
Random rand = new Random();
// nextInt is normally exclusive of the top value,
// so add 1 to make it inclusive
int randomNum = rand.nextInt((max - min) + 1) + min;
return randomNum;
}
But this is for full-blown Java, not scripting. I have also tried using the Math.random method but that's crashing HaikuHelper when I call it.
So in the end, what method do I use to generate a random number?
I am trying to generate a whole-house vacation mode script to turn on random lights for random intervals during night time to give the house a "lived in" look.
The trouble I am having is with the Random class, I can't seem to figure out how to call it to generate a new Random object.
Stack Overflow had a good example of:
public static int randInt(int min, int max) {
// Usually this can be a field rather than a method variable
Random rand = new Random();
// nextInt is normally exclusive of the top value,
// so add 1 to make it inclusive
int randomNum = rand.nextInt((max - min) + 1) + min;
return randomNum;
}
But this is for full-blown Java, not scripting. I have also tried using the Math.random method but that's crashing HaikuHelper when I call it.
So in the end, what method do I use to generate a random number?