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


Post Reply 
 
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
What's wrong with this script?
Author Message
NylePudding Offline
Member

Posts: 77
Joined: Apr 2011
Reputation: 0
Post: #1
What's wrong with this script?

What's wrong with this script? It says this line: "void Timer02 (string &in asTimer)" has a missing "(" but I can't see how. So I guess I've made a mistake somewhere else?

Huh

void Timer01(string &in asTimer)

{

int RanEve_1 = RandInt(1,2);

if (RanEve_1 == 1)
{
SetEntityActive("servant_grunt_1", true);
}

else if (RanEve_1 == 2)
{
SetEntityActive("servant_brute_1", true);
}

SetEntityActive("ScriptArea_1", true);
SetMessage("Example", "Entry2", 0);
PlayMusic("10_event_coming.ogg", false, 1.0f, 0, 0, true);

void Timer02 (string &in asTimer)
{
if (RanEve_1 == 1)
{
ShowEnemyPlayerPosition("servant_grunt_1");
}

if (RanEve_1 == 2)
{
ShowEnemyPlayerPosition("servant_brute_1");
}

SetSwingDoorLocked("mansion_1", false, false);

}
}


And I thought I was just getting a grip with C++... Thanks for any help. Smile
05-02-2011 07:41 AM
Find all posts by this user Quote this message in a reply
Tanshaydar Offline
From Beyond

Posts: 3,085
Joined: Mar 2009
Reputation: 66
Post: #2
RE: What's wrong with this script?

This is whole script? You don't have an "OnStart" section, and you have placed a second timer function inside first timer which you shouldn't. The functions you want to call should be same level with others.

05-02-2011 08:08 AM
Visit this user's website Find all posts by this user Quote this message in a reply
NylePudding Offline
Member

Posts: 77
Joined: Apr 2011
Reputation: 0
Post: #3
RE: What's wrong with this script?

(05-02-2011 08:08 AM)Tanshaydar Wrote:  This is whole script? You don't have an "OnStart" section, and you have placed a second timer function inside first timer which you shouldn't. The functions you want to call should be same level with others.

This isn't the whole script only the area which has the problem.

Here's the whole script if it helps:

void OnStart()
{
AddTimer("tut01", 3, "Intro");
AddTimer("tut02", 30, "Timer01");

SetEnemyIsHallucination("servant_grunt_1", true);
SetEnemyIsHallucination("servant_brute_1", true);

SetSwingDoorLocked("mansion_1", true, false);

PlayMusic("ambience_wind_eerie.ogg", true, 0.5f, 0, 0, true);

AddEntityCollideCallback("Player" , "ScriptArea_1" , "BodyFunc1" , true , 1);
}
void BodyFunc1(string &in asParent , string &in asChild , int alState)
{
SetEntityActive("corpse_male_1" , true);
AddTimer("tut03", 10, "Timer02");
AddTimer("tut03", 10, "Timer03");
}


void Intro(string &in asTimer)
{
SetMessage("Example", "Entry1", 0);

}

void Timer01(string &in asTimer)

{

int RanEve_1 = RandInt(1,2);

if (RanEve_1 == 1)
{
SetEntityActive("servant_grunt_1", true);
}

else if (RanEve_1 == 2)
{
SetEntityActive("servant_brute_1", true);
}

SetEntityActive("ScriptArea_1", true);
SetMessage("Example", "Entry2", 0);
PlayMusic("10_event_coming.ogg", false, 1.0f, 0, 0, true);

void Timer02 (string &in asTimer)
{
if (RanEve_1 == 1)
{
ShowEnemyPlayerPosition("servant_grunt_1");
}

if (RanEve_1 == 2)
{
ShowEnemyPlayerPosition("servant_brute_1");
}

SetSwingDoorLocked("mansion_1", false, false);

}
}

void OnEnter()
{

}

void OnLeave()
{

}

(05-02-2011 08:08 AM)Tanshaydar Wrote:  This is whole script? You don't have an "OnStart" section, and you have placed a second timer function inside first timer which you shouldn't. The functions you want to call should be same level with others.

Okay, I'll arrange my script differently.

So you can't have another timer function within another? I just thought it would save time with the RanEve_1 variable.

So how would you make a variable effective throughout the script?
(This post was last modified: 05-02-2011 08:16 AM by NylePudding.)
05-02-2011 08:13 AM
Find all posts by this user Quote this message in a reply
jens Offline
Frictional Games

Posts: 3,564
Joined: Apr 2006
Reputation: 172
Post: #4
RE: What's wrong with this script?

you should move one of the } above void OnEnter to above void Timer02. Currently you have (short version)

void Timer01()
{
void Timer02()
{
}
}

which will result in an error.
05-02-2011 08:17 AM
Visit this user's website Find all posts by this user Quote this message in a reply
Tanshaydar Offline
From Beyond

Posts: 3,085
Joined: Mar 2009
Reputation: 66
Post: #5
RE: What's wrong with this script?

One local variable can be used in one hps file and all functions will see it.

05-02-2011 08:35 AM
Visit this user's website Find all posts by this user Quote this message in a reply
NylePudding Offline
Member

Posts: 77
Joined: Apr 2011
Reputation: 0
Post: #6
RE: What's wrong with this script?

(05-02-2011 08:35 AM)Tanshaydar Wrote:  One local variable can be used in one hps file and all functions will see it.

Okay thank you, with everyone's help I've managed to see sense and I've fixed my script. Big Grin
05-02-2011 08:43 AM
Find all posts by this user Quote this message in a reply
Post Reply 




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