Home   Help Search Login Register  

Author Topic: 8 random possiblilities  (Read 2487 times)

0 Members and 1 Guest are viewing this topic.

Offline The-Architect

  • Former Staff
  • ****
  • Bite my shiny metal...
    • Bob's Un-official Flashpoint Page
8 random possiblilities
« 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.
James Andrew Wilkinson 1977 - 2005 R.I.P.
"If it ain't the friggin' incoming it's the friggin' outgoing. Only difference is who gets the friggin' grease, and that ain't no friggin' difference at all."

Offline Mandoble

  • Former Staff
  • ****
    • Grunt ONE and MandoMissile suite
Re: 8 random possiblilities
« Reply #1 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
   {
   };
};


Offline The-Architect

  • Former Staff
  • ****
  • Bite my shiny metal...
    • Bob's Un-official Flashpoint Page
Re: 8 random possiblilities
« Reply #2 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 ":" ?
James Andrew Wilkinson 1977 - 2005 R.I.P.
"If it ain't the friggin' incoming it's the friggin' outgoing. Only difference is who gets the friggin' grease, and that ain't no friggin' difference at all."

Offline Planck

  • Honoured
  • Former Staff
  • ****
  • I'm never wrong ....I'm just not always right !
Re: 8 random possiblilities
« Reply #3 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
I know a little about a lot, and a lot about a little.

Offline DucusSumus

  • Members
  • *
  • I'm a llama!
Re: 8 random possiblilities
« Reply #4 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".

Offline Mandoble

  • Former Staff
  • ****
    • Grunt ONE and MandoMissile suite
Re: 8 random possiblilities
« Reply #5 on: 28 Jun 2007, 22:26:51 »
But this way it would be less cryptic  :P

Offline The-Architect

  • Former Staff
  • ****
  • Bite my shiny metal...
    • Bob's Un-official Flashpoint Page
Re: 8 random possiblilities
« Reply #6 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 "}"
James Andrew Wilkinson 1977 - 2005 R.I.P.
"If it ain't the friggin' incoming it's the friggin' outgoing. Only difference is who gets the friggin' grease, and that ain't no friggin' difference at all."

Offline Mandoble

  • Former Staff
  • ****
    • Grunt ONE and MandoMissile suite
Re: 8 random possiblilities
« Reply #7 on: 29 Jun 2007, 00:29:17 »
You are missing a ; after each hint.

Offline The-Architect

  • Former Staff
  • ****
  • Bite my shiny metal...
    • Bob's Un-official Flashpoint Page
Re: 8 random possiblilities
« Reply #8 on: 29 Jun 2007, 00:44:02 »
I still get the "default - Generic error, generic error in expression"
James Andrew Wilkinson 1977 - 2005 R.I.P.
"If it ain't the friggin' incoming it's the friggin' outgoing. Only difference is who gets the friggin' grease, and that ain't no friggin' difference at all."

Offline Mandoble

  • Former Staff
  • ****
    • Grunt ONE and MandoMissile suite
Re: 8 random possiblilities
« Reply #9 on: 29 Jun 2007, 00:48:22 »
Of course you named it .SQF and executed it with execVM, right?

Offline The-Architect

  • Former Staff
  • ****
  • Bite my shiny metal...
    • Bob's Un-official Flashpoint Page
Re: 8 random possiblilities
« Reply #10 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:
James Andrew Wilkinson 1977 - 2005 R.I.P.
"If it ain't the friggin' incoming it's the friggin' outgoing. Only difference is who gets the friggin' grease, and that ain't no friggin' difference at all."

Offline Mandoble

  • Former Staff
  • ****
    • Grunt ONE and MandoMissile suite
Re: 8 random possiblilities
« Reply #11 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.

Offline The-Architect

  • Former Staff
  • ****
  • Bite my shiny metal...
    • Bob's Un-official Flashpoint Page
Re: 8 random possiblilities
« Reply #12 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.
James Andrew Wilkinson 1977 - 2005 R.I.P.
"If it ain't the friggin' incoming it's the friggin' outgoing. Only difference is who gets the friggin' grease, and that ain't no friggin' difference at all."

Offline Gielovic

  • Contributing Member
  • **
Re: 8 random possiblilities
« Reply #13 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
information on the random function
information on the floor function
« Last Edit: 29 Jun 2007, 19:36:08 by Gielovic »