OFPEC Forum

Editors Depot - Mission Editing and Scripting => ArmA - Editing/Scripting General => Topic started by: The-Architect on 28 Jun 2007, 18:36:50

Title: 8 random possiblilities
Post by: The-Architect on 28 Jun 2007, 18:36:50
I had a look around at other, older randomisers and found them to be completely incomprehensible for my tiny brain.

I would like to be able to go to 8 random events in a script. Like this.

Code: [Select]
randomiser, blah, blah, goto : any one of 8 #

#1

#2

#3

#4
etc.

please somebody help me in a way that I can understand.
Title: Re: 8 random possiblilities
Post by: Mandoble on 28 Jun 2007, 18:56:21
Code: [Select]
_case = 1 + floor random (8 - 0.001);

switch (_case) do
{
   case 1:
   {

   };
   case 2:
   {

   };
   case 3:
   {

   };
   case 4:
   {

   };
   case 5:
   {

   };
   case 6:
   {

   };
   case 7:
   {

   };
   case 8:
   {

   };
   default
   {
   };
};

Title: Re: 8 random possiblilities
Post by: The-Architect on 28 Jun 2007, 22:10:27
Cheers mandoble.

Could you explain where I put my stuff?

Example.

I have a titelcut and some playsound commands. Where in the above would I put them for each case after the ":" ?
Title: Re: 8 random possiblilities
Post by: Planck on 28 Jun 2007, 22:20:07
Just a guess here ....but I would say between the {}

   case 1:
   {
IN HERE I THINK
   };

 :cool2:


Planck
Title: Re: 8 random possiblilities
Post by: DucusSumus on 28 Jun 2007, 22:24:51
Planck is right.  Make sure you use semicolons after each line if there is going to be more than one command in any given case.

Mandoble, instead of "1 + floor (8 - .001)", you could simply use "ceil 8".
Title: Re: 8 random possiblilities
Post by: Mandoble on 28 Jun 2007, 22:26:51
But this way it would be less cryptic  :P
Title: Re: 8 random possiblilities
Post by: The-Architect on 28 Jun 2007, 23:31:45
Alright I tried it and got error messages.

Code: [Select]
_case = 1 + floor random (8 - 0.001);

switch (_case) do
{
   case 1:
   {
Hint "Hint1"
   };
   case 2:
   {
Hint "Hint2"
   };
   case 3:
   {
Hint "Hint3"
   };
   case 4:
   {
Hint "Hint4"
   };
   case 5:
   {
Hint "Hint5"
   };
   case 6:
   {
Hint "Hint6"
   };
   case 7:
   {
Hint "Hint7"
   };
   case 8:
   {
Hint "Hint8"
   };
   default
   {
   };
};

It didn't like "default" being written on it's own and after I removed default it told me I was missing a "}"
Title: Re: 8 random possiblilities
Post by: Mandoble on 29 Jun 2007, 00:29:17
You are missing a ; after each hint.
Title: Re: 8 random possiblilities
Post by: The-Architect on 29 Jun 2007, 00:44:02
I still get the "default - Generic error, generic error in expression"
Title: Re: 8 random possiblilities
Post by: Mandoble on 29 Jun 2007, 00:48:22
Of course you named it .SQF and executed it with execVM, right?
Title: Re: 8 random possiblilities
Post by: The-Architect on 29 Jun 2007, 01:13:41
No.  :dunno:

I thought it was a simple .sqs script that I could use over and over in different circumstances, ie 5 or 6 scripts doing what this one does.

What I'm doing is having responses over the radio from my guys. Whoever answers the radio call, should be random. one time number 6 answers, another time number 8 or 1 etc.

I'm not a scripter. I don't know the difference between and sqf and a sqs, except there are different ways to get the things working. I never sat down and learned the whole kit and kaboodle.

Also what does execVM mean?

Do i not exec with [] exec "saidscript.sqf" and 5 mins later [] exec "saidscript2.sqf" etc, every time I want to have a radio conversation occur?

I did say my tiny brain would have trouble here.  :confused:
Title: Re: 8 random possiblilities
Post by: Mandoble on 29 Jun 2007, 01:28:10
The delete all the switch block and just use
?_case == 1: blah blah blah
?_case == 2: blah blah blah

And use the old exec for SQS.
Title: Re: 8 random possiblilities
Post by: The-Architect on 29 Jun 2007, 16:25:21
Alas still no joy. Here's exatly what I want to fit into the script. In one particular circumstance.


Code: [Select]
Random generator code!
>magic happens here<

#random1
titletext etc "My radio message blah, blah." Plain Down etc.
unit so and so say "myradiomsg"
~10
home sidechat "standard response mk1, blah blah."
playsound "stanrdrspnsemk1"
goto "exit"

#random2
titletext etc "My radio message 2 blah, blah." Plain Down etc.
unit so and so say "myradiomsg2"
~10
home sidechat "standard response mk1, blah blah."
playsound "stanrdrspnsemk2"
goto "exit"

#random3
titletext etc "My radio message 2 blah, blah." Plain Down etc.
unit so and so say "myradiomsg2"
~10
home sidechat "standard response mk1, blah blah."
playsound "stanrdrspnsemk2"
goto "exit"

#Exit
exit

etc all the way to 8 and possibly more.
Title: Re: 8 random possiblilities
Post by: Gielovic on 29 Jun 2007, 19:33:03
I still get the "default - Generic error, generic error in expression"


You miss the : after the word default i guess
information on the switch construct (http://community.bistudio.com/wiki/switch)
information on the random function (http://community.bistudio.com/wiki/random)
information on the floor function (http://community.bistudio.com/wiki/floor)