T122002
Junior Member
Posts: 24
Threads: 10
Joined: Dec 2012
Reputation:
1
|
The if and if else statements
Hello everyone! I have a question to ask.
Most script functions I have a general idea on how to use, but I do not understand how the "if" and "if else" statements work, or how or when to use them. I think after I learn those two statements, than I'll start working with loops and try to mess with puzzles a bit more.
Well, for example, say I want the player to pick up a key, then when they leave the room the key was in, a monster spawns. Or maybe when you do something, like solve a puzzle (I also don't know how to do puzzle scripts), then something will happen.
Can anyone explain to me how to do this, like dumb it down so I can understand and maybe throw in a few examples for me to study? That would be much appreciated!
|
|
04-09-2013, 06:06 PM |
|
OriginalUsername
Posting Freak
Posts: 896
Threads: 42
Joined: Feb 2013
Reputation:
34
|
RE: The if and if else statements
You could see it as asking a if question.
IF the door is closed, do this. ELSE do this.
Example:
if((ifyourdoorislocked, ifplayerhasanitem) == true or false)
{
Do some things
}
Else
{
Do other things
}
I'll give you a link to all these commands once I'm back on my pc
Hope it helps!
Edit: I see your computer already gave the link, good luck
|
|
04-09-2013, 08:16 PM |
|
Your Computer
SCAN ME!
Posts: 3,456
Threads: 32
Joined: Jul 2011
Reputation:
235
|
RE: The if and if else statements
(04-09-2013, 06:06 PM)T122002 Wrote: Well, for example, say I want the player to pick up a key, then when they leave the room the key was in, a monster spawns.
Technically, you don't need if and else statements for that. Just have an interact callback for the key that adds a collision callback for leaving an area that then activates a monster.
(04-09-2013, 06:06 PM)T122002 Wrote: Or maybe when you do something, like solve a puzzle (I also don't know how to do puzzle scripts), then something will happen.
Depending on the puzzle's complexity you also may not need if and else statements.
You can find some information on if-else statements here: http://wiki.frictionalgames.com/hpl2/amn...statements
|
|
04-09-2013, 08:32 PM |
|
T122002
Junior Member
Posts: 24
Threads: 10
Joined: Dec 2012
Reputation:
1
|
RE: The if and if else statements
(04-09-2013, 08:32 PM)Your Computer Wrote: (04-09-2013, 06:06 PM)T122002 Wrote: Well, for example, say I want the player to pick up a key, then when they leave the room the key was in, a monster spawns.
Technically, you don't need if and else statements for that. Just have an interact callback for the key that adds a collision callback for leaving an area that then activates a monster.
(04-09-2013, 06:06 PM)T122002 Wrote: Or maybe when you do something, like solve a puzzle (I also don't know how to do puzzle scripts), then something will happen.
Depending on the puzzle's complexity you also may not need if and else statements.
You can find some information on if-else statements here: http://wiki.frictionalgames.com/hpl2/amn...statements
Hmm..well okay. At least I won't need the if and if else stuff right now then, since you answered exactly what I wanted. But, what are the script functions to pull off the interact callback and the collision callback? I can't find them at the Engine Scripts page, unless they're named differently there.
And thanks for the link for the if else thing, its very helpful!
(This post was last modified: 04-09-2013, 11:30 PM by T122002.)
|
|
04-09-2013, 11:29 PM |
|
OriginalUsername
Posting Freak
Posts: 896
Threads: 42
Joined: Feb 2013
Reputation:
34
|
|
04-10-2013, 07:05 AM |
|
T122002
Junior Member
Posts: 24
Threads: 10
Joined: Dec 2012
Reputation:
1
|
RE: The if and if else statements
(04-10-2013, 07:05 AM)Smoke Wrote: Not sure which page you were looking at, but they're located here: http://wiki.frictionalgames.com/hpl2/amn..._functions
I saw the site, but I couldn't find the functions.
Your Computer said this:
"Technically, you don't need if and else statements for that. Just have an interact callback for the key that adds a collision callback for leaving an area that then activates a monster."
Is there a specific function on how to do this? I mean, how would I set that up?
|
|
04-10-2013, 03:37 PM |
|
PutraenusAlivius
Posting Freak
Posts: 4,713
Threads: 75
Joined: Dec 2012
Reputation:
119
|
RE: The if and if else statements
(04-10-2013, 03:37 PM)T122002 Wrote: (04-10-2013, 07:05 AM)Smoke Wrote: Not sure which page you were looking at, but they're located here: http://wiki.frictionalgames.com/hpl2/amn..._functions
I saw the site, but I couldn't find the functions.
Your Computer said this:
"Technically, you don't need if and else statements for that. Just have an interact callback for the key that adds a collision callback for leaving an area that then activates a monster."
Is there a specific function on how to do this? I mean, how would I set that up? void OnStart()
{
SetEntityCallbackFunc("KeyName", "AreaActive");
}
void AreaActive(string &in asEntity, string &in type)
{
SetEntityActive("NameOfArea", true);
AddEntityCollideCallback("Player", "NameOfArea", "MonsterTrigger", true, 1);
}
void MonsterTrigger(string &in asParent, string &in asChild, int alState)
{
SetEntityActive("MonsterName", true);
}
---
Used using SECF, SEA, and AECC. You can functions and conditional functions in the link provided.
"Veni, vidi, vici."
"I came, I saw, I conquered."
|
|
04-10-2013, 03:44 PM |
|
T122002
Junior Member
Posts: 24
Threads: 10
Joined: Dec 2012
Reputation:
1
|
RE: The if and if else statements
(04-10-2013, 03:44 PM)JustAnotherPlayer Wrote: (04-10-2013, 03:37 PM)T122002 Wrote: (04-10-2013, 07:05 AM)Smoke Wrote: Not sure which page you were looking at, but they're located here: http://wiki.frictionalgames.com/hpl2/amn..._functions
I saw the site, but I couldn't find the functions.
Your Computer said this:
"Technically, you don't need if and else statements for that. Just have an interact callback for the key that adds a collision callback for leaving an area that then activates a monster."
Is there a specific function on how to do this? I mean, how would I set that up? void OnStart()
{
SetEntityCallbackFunc("KeyName", "AreaActive");
}
void AreaActive(string &in asEntity, string &in type)
{
SetEntityActive("NameOfArea", true);
AddEntityCollideCallback("Player", "NameOfArea", "MonsterTrigger", true, 1);
}
void MonsterTrigger(string &in asParent, string &in asChild, int alState)
{
SetEntityActive("MonsterName", true);
}
---
Used using SECF, SEA, and AECC. You can functions and conditional functions in the link provided.
Ooh! Thank you so much for the functions! This was exactly what I was looking for!
|
|
04-10-2013, 06:40 PM |
|
|