(08-30-2011, 02:43 PM)Mooserider Wrote: Can you please explain for statements to me in a way I can understand?
Every time I see an explanation of it my brain explodes I just don't get it.
Thanks in advance! It's really kind of you to offer help to people.
A "switch" statement is very much like an "if" statement. A switch statement organizes data in a different way. It can be used mostly when there are many possible outcomes, or things that could happen.
If you type "switch" when in an ".hps" script file, you will notice that it changes color (If you have the right ".hps" package for Notepad++ or course.), that's how you know that it can be used for something important.
Let us say that you have a number variable, and this number variable will be changed. We need to find a way to know what the current value of the variable is.
Then we check and see what it equals in case if we don't know what it really equals. Like if the player picks a number between 1 and 10, we would need to know which one the player chose.
That wouldn't work correctly because 2 always equals 2, and variable x isn't supposed to be constant or else there would be no point in having a "switch" statement.
Now I'll introduce you something called a "case". A case is like a piece of an "if" statement. There can be as many cases as you want there to be. It is normally listed "case 1:", "case 2:"... ect. But you can also have it be a string after the case, like "case 'Name':", where it checks if the value of the switch's variable is equal to "Name". There has to be single quotes ( ' ) between it. To end a certain "case", you have to type "break;" at the end of it. I'm going to show you what the differences between an "if" statement and a "switch" statement looks like, while demonstrating where each part came from.
"Switch" statement:
void OnStart()
{
int x = 1;
x = 2; switch(x)
{ case 1:
{
// Have something to happen here, if x = 1.
break;
} case 2:
{
// Have something to happen here, if x = 2.
break;
} default: // Used like an "else" statement.
{
// Have something to happen here, if x doesn't equal 1 or 2.
}
}
"If" statement:
void OnStart()
{
int x = 1;
x = 2; if(x == 1)
{
// Have something to happen here, if x = 1.
} if(x == 2)
{
// Have something to happen here, if x = 2.
} else
{
// Have something to happen here, if x doesn't equal 1 or 2.
}
}
Quote:I learned it by knowing actual C++ scripting and having lots of time and experience with it and also with AngelScript for Amnesia of course.
I'm a fast learner.
well that would make sense then, i suppose if we have a particular area of talent you pick things up very fast unfortunately scripting isnt like that with me, my area of talent is in music, but your scripting is quite admirable!
work if i want that something will happen STRAIGHT after you watch watching this white text ?
Hmm, this is quite interesting. I never used that command function before When I tried it out, I see what you mean how it could be difficult to track it. As I'm testing it right now, I'm trying to see if the boolean command function you want to use can do the job correctly.
I finished testing it, and it appears that I can't time it correctly when the player clicks it, but then as I waited there, it finished by itself, so that means that if you have a timer from when the flashback starts, then you can time it the right moment when it ends, while having the player be set unactive.
I'm not sure if it depends on how much text that's in the message that lengthens the time it waits, or if it always happens at the same time. Or else I just accidently pressed the wrong button, causing it to stop. xD
What im trying to do is make it so that when the player opens a part of the desk, and that part of the desk colides with the area, it will cause the monster to become active. After the monster walks a certain distance into a area, it will vanish. For some reason i can't even get the monster to spawn. Some help would be nice.
(This post was last modified: 08-30-2011, 05:24 PM by ZRPT1.)
It appears that it should work, scripting wise. Perhaps you named something wrong in the level editor to the script, or script area "armtroll" isn't big enough of an area for "trolldesk" to collide with it?
Also, make sure that the name of the monster is "troll1", or else it wouldn't work. And if you're using a monster with a troll face on it, perhaps it doesn't work? xD
Im trying to make it, after the note has been picked up, and you look at a certain area, the door will fly open. For some reason it's not working, i'm not sure what the issue is. The area the player would look at would be "wind".
(This post was last modified: 08-30-2011, 05:42 PM by ZRPT1.)