Axe Software Forums
  Quest Developer Forum
  Random Number generator.


Author Topic:   Random Number generator.
Computer Whizz posted 17-09-2000 15:15 GMT     
is there a random number generator in quest?
I would like the player to go to a terminal in one room, get 4 numbers (eg. A=3 B=7 C=4 D=7), all numbers random. Then he goes into the next room, enters these 4 numbers and is able to do other things (eg. print out a document, delete files/things, unlock doors ect..). I know this would have to be in a procedure and that the terminal would be an object.
I'd use the command "operate terminal" to do these things. How would I get it to do this?
And how would I implement these changes (unlocking doors down the hallway) in the game?
thanx for your help.

--CW

Alex posted 17-09-2000 20:12 GMT          
(www.axeuk.com appears to be having trouble with its CGI scripts at the moment - this is probably a problem with TeraByte, who operate the web server www.axeuk.com sits on - if you have trouble posting, viewing or replying to messages, hit your browser's refresh button until it works)


To generate random numbers use the $(rand;A;B)$ function, where A and B are integers - this will return a random number between A and B. You would store the output from the function in a string or numeric variable, and then print the required code and compare it to what is entered at the terminal.

For unlocking doors, have some script for the north, go to... place actions etc. that check whether the door is locked or unlocked - if locked, print a message; if unlocked, move the player to the required room.


Alex Warren,
Axe Software

Computer Whizz posted 19-09-2000 19:45 GMT          
So I gather you can only use this in Quest3?

I presume that to set the random function, you put it in an action to change the value in a collectable and input the following : test2;$(rand;1;3)$.
I've had some problems with it this way and can't get it to work.
Could you please tell me in detail, or send me an ASL file.
thanx

--CW

Alex posted 19-09-2000 19:55 GMT          
No, the $rand(A,B)$ function exists in Quest 2.0 upwards.

You were almost right with the syntax - the parameter should in fact be of the form test2;$rand(1;3)$.


Alex Warren,
Axe Software