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


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

Posts: 77
Threads: 23
Joined: Apr 2011
Reputation: 0
#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
Tanshaydar Offline
From Beyond

Posts: 3,085
Threads: 17
Joined: Mar 2009
Reputation: 67
#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
Website Find
NylePudding Offline
Member

Posts: 77
Threads: 23
Joined: Apr 2011
Reputation: 0
#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
jens Offline
Frictional Games

Posts: 4,093
Threads: 199
Joined: Apr 2006
Reputation: 202
#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
Website Find
Tanshaydar Offline
From Beyond

Posts: 3,085
Threads: 17
Joined: Mar 2009
Reputation: 67
#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
Website Find
NylePudding Offline
Member

Posts: 77
Threads: 23
Joined: Apr 2011
Reputation: 0
#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




Users browsing this thread: 1 Guest(s)