Help with generating random numbers

sbangs
I tried numerous ways to use $rand(1;100)$ in my game, and try to output the value, or get the value assigned to a numeric variable, or a string variable and have not succeeded. I get internal error many times, and I'm sure I'm using it wrong.

Can someone help with an example of how to actually implement this function in the game?

Thanks much,


Alex
That looks correct to me, can you attach an example ASL file?

sbangs
Thanks Alex, what looks correct could only be $rand(1;100)$

Thats it. What's not correct is what I am doing with that? LOL.

I cant seem to figure out where to put that statement in the game, where it will display the random number?

Ok, i modified the grey goose als file from before. My incorrect use of this function is in the script that will fire when you pick up the bottle. Thanks.

Alex
You're overcomplicating the variable assignment - you're not asking the player to type in a random number, so don't use those commands.

I see you want a variable called "random". Here's how to do it:

- Under the Variables category, choose "Set a numeric variable"
- For numeric variable name, type "random"
- For contents, enter the function: "$rand(1;100)$"

Now your random number is stored in the numeric variable, and you can access it using %random%. So change your final print statement to "Your random number is %random%"

sbangs
Here is what I am doing.

Change the contents of variable "random1" to "$rand(1;100)$"
Print "[SIZE 00]Ur number is %random1%"

When the script fires the print statement is a -37258 number, like the default negative when no value is present, i think.

I also seem to be confused with using $ or # or % on certain variables.

sbangs
got it, whoops. I didnt set numeric variable.

Ok, i'm good to go now.

Thanks again for the quick responses.



This topic is now closed. Topics are closed after 60 days of inactivity.

Support

Forums