This is my script.
Why am i getting an error, that it expected a ; at the highlighted text?
Don't worry, this is not my whole script file. I know this single passage wouldn't work in any way. It's a part of a timer, as you see in the top of the script
JAP already solved the issue, but to explain the error a little....
It was saying there was an issue at the line directly below where the actual problem was.
The compiler reads this line, but because there is no ; at the end, it does not know where the line ends. As far as the compiler knows, the next line down is part of the same statement.
To the compiler it looks like this
int AhVariable = RandInt(1, 2) switch(AhVariable) {
The error is generated because it was expecting to the have the statement terminated by the ;
switch(int) { is not a valid part of a statement, so it throws the error on this line.
tl;dr - the line number given in the error message is approximate, with this particular error, it tends to be the line above
(04-24-2013, 04:50 PM)BeeKayK Wrote: I tried. Now just nothing happens
(04-24-2013, 04:56 PM)Adrianis Wrote: The compiler reads this line, but because there is no ; at the end, it does not know where the line ends. As far as the compiler knows, the next line down is part of the same statement.
To the compiler it looks like this
int AhVariable = RandInt(1, 2) switch(AhVariable) {
The error is generated because it was expecting to the have the statement terminated by the ;
switch(int) { is not a valid part of a statement, so it throws the error on this line.
tl;dr - the line number given in the error message is approximate, with this particular error, it tends to be the line above
Okay, well if this is the case, how do we resolve the issue. Like I just can't figure out how to fix it. I keep getting the same error.
It tells me the expected ';' or ',' is for line 117. This is my script:
(05-07-2013, 04:30 AM)JustAnotherPlayer Wrote: Have you added a ; at said line?
I have, it proceeds to tell me Expected '}' at the very last line of my script. :/ Ah, I'm sucha noob. I've come so far on it already and I thought it would be nice to jazz it up with something more random.
EDIT: And before this, my script worked perfectly fine, no issues. So I decided to just not do the random event, my script has changed since.
(This post was last modified: 05-07-2013, 05:24 AM by RurouniMori.)
This bit of code is wrong - You don't need any curly braces { } inside of each Case statement, the code block for the Case statement is defined within the space between the keyword 'case [int]:' and 'break;'
case 3: CODE HERE
CODE HERE
break;
(the break; keyword is not strictly necessary, but it is needed in order to stop the flow of the case statements before it starts executing code from the other cases)
^ That is all explained in JAP's original post, underneath the code sample
You also cannot define a function within the code block of a case statement, as you do here
void Push(string &in asParent, string &in asChild, int alState)
{
code
}
Now, I'm not sure exactly what event you are trying to set up, but the code that JAP kindly provided is not as simple to use as it might appear - I highly recommend you learn about how switch...case statements work before attempting to use this method. I say that for your benefit, this will cause more headaches then it will solve
There an explanation of how they work here... http://www.angelcode.com/angelscript/sdk...ments.html
This bit of code is wrong - You don't need any curly braces { } inside of each Case statement, the code block for the Case statement is defined within the space between the keyword 'case [int]:' and 'break;'
case 3: CODE HERE
CODE HERE
break;
(the break; keyword is not strictly necessary, but it is needed in order to stop the flow of the case statements before it starts executing code from the other cases)
^ That is all explained in JAP's original post, underneath the code sample
You also cannot define a function within the code block of a case statement, as you do here
void Push(string &in asParent, string &in asChild, int alState)
{
code
}
Now, I'm not sure exactly what event you are trying to set up, but the code that JAP kindly provided is not as simple to use as it might appear - I highly recommend you learn about how switch...case statements work before attempting to use this method. I say that for your benefit, this will cause more headaches then it will solve
There an explanation of how they work here... http://www.angelcode.com/angelscript/sdk...ments.html
What Adrianis said. Even though it looks kind of easy, it's actually very hard.
(04-16-2013, 03:10 PM)JustAnotherPlayer Wrote: Hello everyone! I've used this technique in my custom story, A Forgotten Memory. Special thanks for people that helped me to understand this. Using this will randomize the scares you will have. This gives the CS/FC replay value.
It's like this, each playthrough had different results. Example;
First Playthrough : You pass out and wakes up in some other place.
Second Playthrough : A door blew open.
It's good. Why? Because the Player will think like he knew, but he didn't.
void PlrCollideSwitch(string &in asParent, string &in asChild, int alState) { int x = RandInt(1, 5); switch(x) { case 1: //Scare 1 break; case 2: //Scare 2 break; case 3: //Scare 3 break; case 4: //Scare 4 break; case 5: //Scare 5 break; } }
Get it? Integer is RandInt, and it will randomize between 1 and 5 as 1 is the minimal and 5 is the maximal. If one of the cases fit with the inputInteger, it will do that case until the first break is reached. For this, you don't need curly brackets({}) to envelope code, but you need breaks.
Just change the
//Scare #CaseNumber
to what scare you want.
Even nobody including you (the creator) will know which one is picked.
This will give your custom story/full conversion replay value.
OFF-TOPIC:
Even Scares are now can be randomized. I'm so smart.
EDIT:
It seems like the script gives everyone an error. I already changed it and now tell me if it works or not.
Do I simply copy this into my hps or do I have to change some things?