Facebook Twitter YouTube Frictional Games | Forum | Newsletter | Dev Blog | Dev Wiki | Support | Shelf | Store

Privacy Policy


Post Reply 
 
Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
"if" scripting
Author Message
BeeKayK Online
Posting Freak

Posts: 1,949
Joined: Mar 2012
Reputation: 75
Post: #1
Question "if" scripting
I have a problem with the if scripting...
My idea is that a room is patroled by a monster, but to keep the monstermusic from being played all the time, the monster only spawns when you touch the door. Then after a few minutes it goes inactive again because it is has no more pathnodes.

Now, when you pick up a note that says you have to go to the other side of the patroled room, the monster will be gone.

Here is my script:
void OnStart()
{
SetEntityPlayerInteractCallback("door_teacher1", "OnInteract1", false);

}


void OnInteract1(string &in asEntity)
{
if(HasItem("note3") == true)
{

}
else

SetEntityActive("monster_teacher1", true);
AddEnemyPatrolNode("monster_teacher1", "PathNodeArea_1", 1, "");
AddEnemyPatrolNode("monster_teacher1", "PathNodeArea_2", 1, "");
}

The problem is that the monster spawns even though i've got the note

We fear what we cannot undo
We fear what we don't know
03-15-2012 06:47 PM
Find all posts by this user Quote this message in a reply
ClayPigeon Offline
Member

Posts: 151
Joined: Mar 2012
Reputation: 6
Post: #2
RE: "if" scripting
Try this:

if(HasItem("note3") == true)
{
SetEntityActive("monster_teacher1", false);
}
03-15-2012 06:56 PM
Find all posts by this user Quote this message in a reply
SilentStriker Offline
Posting Freak

Posts: 939
Joined: Jul 2011
Reputation: 39
Post: #3
RE: "if" scripting
More like

if(HasItem("note3"))

because the == true makes it if true then true

03-15-2012 07:04 PM
Find all posts by this user Quote this message in a reply
BeeKayK Online
Posting Freak

Posts: 1,949
Joined: Mar 2012
Reputation: 75
Post: #4
RE: "if" scripting
Nope still didnt... work...
I guess the script is setup so no matter what, it will run the script beneath "else" because the upper { and the lover } is connected. Then if i has the note it will first set the monster inactive, then set it active... i might try to do this with an area instead because the door will be buggy...
I guess i can just make the area go inactive then?

We fear what we cannot undo
We fear what we don't know
03-15-2012 07:12 PM
Find all posts by this user Quote this message in a reply
SilentStriker Offline
Posting Freak

Posts: 939
Joined: Jul 2011
Reputation: 39
Post: #5
RE: "if" scripting
Does it give you errors or is it just not working?

03-15-2012 07:14 PM
Find all posts by this user Quote this message in a reply
Your Computer Offline
SCAN ME!

Posts: 3,237
Joined: Jul 2011
Reputation: 216
Post: #6
RE: "if" scripting
If it always yields to else, then it is safe to conclude that HasItem cannot be used to determine whether the player has a specific note.

Tutorials: From Noob to Pro
03-15-2012 07:21 PM
Visit this user's website Find all posts by this user Quote this message in a reply
BeeKayK Online
Posting Freak

Posts: 1,949
Joined: Mar 2012
Reputation: 75
Post: #7
RE: "if" scripting
It works fine except the monster is still there

We fear what we cannot undo
We fear what we don't know
03-15-2012 07:24 PM
Find all posts by this user Quote this message in a reply
Post Reply 




User(s) browsing this thread: 1 Guest(s)