Facebook Twitter YouTube Frictional Games | Forum | Privacy Policy | Dev Blog | Dev Wiki | Support | Gametee


Thread Rating:
  • 5 Vote(s) - 4 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Looking For Help? Look No More!
Kyle Offline
Posting Freak

Posts: 911
Threads: 36
Joined: Sep 2010
Reputation: 7
#41
RE: Looking For Help? Look No More!

(08-30-2011, 02:43 PM)Mooserider Wrote: Can you please explain for statements to me in a way I can understand? Big Grin
Every time I see an explanation of it my brain explodes Tongue I just don't get it.

Thanks in advance! Smile It's really kind of you to offer help to people. Smile

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.

Here we have a variable:

int x = 1;

Here the value is changed:

x = 2;

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.

Now we start the "switch" statement.

void OnStart()
{
     int x = 1;
     x = 2;
     switch(x)
     {
          
     }
}

You might be wondering, why is there parentheses after the "switch" statement and the variable x inbetween is declared?

Well, since we know that the value of x equals 2, we could have it like this:

switch(2)
{
    
}

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.
}
}

I hope this helps! Big Grin

(This post was last modified: 08-30-2011, 03:22 PM by Kyle.)
08-30-2011, 03:21 PM
Find
Tesseract Offline
Senior Member

Posts: 498
Threads: 7
Joined: Mar 2011
Reputation: 18
#42
RE: Looking For Help? Look No More!

off topic but how did you learn all this?
08-30-2011, 03:35 PM
Find
Kyle Offline
Posting Freak

Posts: 911
Threads: 36
Joined: Sep 2010
Reputation: 7
#43
RE: Looking For Help? Look No More!

(08-30-2011, 03:35 PM)Saffire192 Wrote: off topic but how did you learn all this?

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. Big Grin

08-30-2011, 03:43 PM
Find
Elven Offline
Posting Freak

Posts: 862
Threads: 37
Joined: Aug 2011
Reputation: 26
#44
RE: Looking For Help? Look No More!

Same here Smile. I learn was too, but diff is I started learning Tongue.

Kyle, you ignored my question tho

The Interrogation
Chapter 1

My tutorials
08-30-2011, 03:45 PM
Find
Tesseract Offline
Senior Member

Posts: 498
Threads: 7
Joined: Mar 2011
Reputation: 18
#45
RE: Looking For Help? Look No More!

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. Big Grin

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!

08-30-2011, 03:52 PM
Find
Kyle Offline
Posting Freak

Posts: 911
Threads: 36
Joined: Sep 2010
Reputation: 7
#46
RE: Looking For Help? Look No More!

(08-30-2011, 03:45 PM)Elven Wrote: Same here Smile. I learn was too, but diff is I started learning Tongue.

Kyle, you ignored my question tho

I didn't ignore it, I just wanted to take a break before tackling something different.

(08-30-2011, 02:46 PM)Elven Wrote: I want to use
StartEffectEmotionFlash

Will

bool GetFlashbackIsActive();

Checks whether a flashback is still in effect.

work if i want that something will happen STRAIGHT after you watch watching this white text Smile?

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.

Here's what it may looks like:

void OnStart()
{
     AddEntityCollideCallback("Player", "ScriptArea_1", "Func01", true, 1);
}
void Func01(string &in asParent, string &in asChild, int alState)
{
     StartEffectEmotionFlash("Message", "Hint", "");
     SetPlayerActive(false);
     AddTimer("", 6, "Func02");
}
void Func02(string &in asTimer)
{
     SetPlayerActive(true);
     // Do whatever you want to happen after.
}

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

I hope it works for you. Smile

08-30-2011, 04:22 PM
Find
Elven Offline
Posting Freak

Posts: 862
Threads: 37
Joined: Aug 2011
Reputation: 26
#47
RE: Looking For Help? Look No More!

Thanks you kyle Smile!

The Interrogation
Chapter 1

My tutorials
08-30-2011, 04:38 PM
Find
ZRPT1 Offline
Junior Member

Posts: 32
Threads: 4
Joined: Aug 2011
Reputation: 0
#48
RE: Looking For Help? Look No More!

Hey, im currently attempting to script my first monster event, but im not sure what's wrong.

Spoiler below!
void OnStart()
{
AddEntityCollideCallback("trolldesk", "armtroll", "Troll", true, 1);
AddEntityCollideCallback("troll1", "trollgone", "Bye", true, 1);
}


Then later in the script
Spoiler below!

}
void Troll(string &in asParent, string &in asChild, int alState)
{
SetEntityActive("troll1", true);
AddEnemyPatrolNode("troll1", "PathNodeArea_1", 2, "");
AddEnemyPatrolNode("troll1", "PathNodeArea_2", 0, "");
AddEnemyPatrolNode("troll1", "PathNodeArea_3", 0, "");
AddEnemyPatrolNode("troll1", "PathNodeArea_4", 0, "");
AddEnemyPatrolNode("troll1", "PathNodeArea_5", 0, "");
AddEnemyPatrolNode("troll1", "PathNodeArea_6", 0, "");
AddEnemyPatrolNode("troll1", "PathNodeArea_7", 4, "");
}
void Bye(string &in asParent, string &in asChild, int alState)
{
SetEntityActive("troll1", false);
}


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.)
08-30-2011, 05:23 PM
Find
Kyle Offline
Posting Freak

Posts: 911
Threads: 36
Joined: Sep 2010
Reputation: 7
#49
RE: Looking For Help? Look No More!

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

08-30-2011, 05:31 PM
Find
ZRPT1 Offline
Junior Member

Posts: 32
Threads: 4
Joined: Aug 2011
Reputation: 0
#50
RE: Looking For Help? Look No More!

I was actually just scripting it in a .txt file. ._________.

Thank you though.

And that last suggestion may/may not be implemented into the final product.

However, i still have one issue that isn't because of that, let me just post that script here....
Spoiler below!
AddEntityCollideCallback("Player", "earthquakenote", "OnPickup", true, 1);
AddEntityCollideCallback("Player", "doorunlock", "open_door", true, 1);
SetEntityCallbackFunc("earthquakenote", "OnPickup");
SetEntityPlayerLookAtCallback("wind", "windopen", true);

Later in the script;

Spoiler below!
void OnPickup(string &in asEntity, string &in type)
{
if(type == "OnPickup")
{
SetEntityActive("doorunlock", true);
SetEntityActive("wind", true);
}
}

void windopen(string &in asEntity, int alState)
{
if(alState == 1)
{
SetSwingDoorDisableAutoClose("earthquakedoor", true);
SetSwingDoorClosed("earthquakedoor", false, true);
AddPropForce("earthquakedoor", 0, 0, 900, "world");
}
}


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.)
08-30-2011, 05:34 PM
Find




Users browsing this thread: 5 Guest(s)