OFPEC Forum
Editors Depot - Mission Editing and Scripting => ArmA - Editing/Scripting General => Topic started 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.
randomiser, blah, blah, goto : any one of 8 #
#1
#2
#3
#4 etc.
please somebody help me in a way that I can understand.
-
_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
{
};
};
-
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 ":" ?
-
Just a guess here ....but I would say between the {}
case 1:
{
IN HERE I THINK
};
:cool2:
Planck
-
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".
-
But this way it would be less cryptic :P
-
Alright I tried it and got error messages.
_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 "}"
-
You are missing a ; after each hint.
-
I still get the "default - Generic error, generic error in expression"
-
Of course you named it .SQF and executed it with execVM, right?
-
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:
-
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.
-
Alas still no joy. Here's exatly what I want to fit into the script. In one particular circumstance.
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.
-
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)