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
How to make more than 1 script?
FrictionalWeekly Offline
Junior Member

Posts: 19
Threads: 6
Joined: Apr 2011
Reputation: 2
#1
How to make more than 1 script?

I'm having trouble making my first custom story because I'm newby with scripts. I'm having trouble making 2 scripts in 1 map mainly and it's frustrating.

Here's what it is that I'm trying to do that's wrong somehow

_____________________________________________________________

void OnEnter()

{
PlayMusic("penumbra_music_E1_D1", true, 1, 0, 0, true);
}

void DoggyAttackPart(string &in asEntity, string &in type)
{
SetEntityActive("doggy", true);
StartPlayerLookAt("doggy", 15, 15, "");
AddTimer("monstertimer", 2, "monstertimer");
ShowEnemyPlayerPosition("doggy");
}

void monstertimer(string &in asTimer)
{
StopPlayerLookAt();
}


//////// Scare music in bloody room
void AddEntityCollideCallback("Player", "scare_script", "scare_script", false, 0);



void scare_script(string &in asParent, string &in asChild, int alState)
{
//music scripts here
// If enters and leave
if(alState == 1)
{
PlayMusic("Penumbra_BP_C1.ogg", false, 1.00, 0, 5, true);
}
if(alState == -1)
{

}
_____________________________________________________________________________________



And this is the error that pops up when it tries to load the map.



___________________________________________

FATAL ERROR: Could not load script file 'custom_stories/Zombie
Survival/maps/C;/Program Files (x86)/Amnesia - The Dark
Descent/redist/custom_stories/Zombie Survival/maps/lv3.hps'!
ExecuteString (1, 1) : ERR : No matching signatures to 'OnLeave()'
main (37, 2): ERR : Unexpected end of file

__________________________________________
(This post was last modified: 06-02-2012, 11:34 PM by FrictionalWeekly.)
06-02-2012, 11:18 PM
Find
Bridge Offline
Posting Freak

Posts: 1,971
Threads: 25
Joined: May 2012
Reputation: 128
#2
RE: How to make more than 1 script?

I don't really know anything about Amnesia scripting but presumably every declaration of OnEnter() must be followed by a declaration of OnLeave(), even if it's blank, right? That seems to be what the compiler is complaining about.

Is this the complete script? There is no reference to lv3.hps anywhere so I have no idea why it's mentioning that. Also that file path is really fucked up, are you sure it's correct?

Main (37, 2) is complaining about it being incomplete code I guess. Don't you need to return 0 or something?

EDIT: Actually I suppose you don't since I recall seeing a function called OnStart() on the wiki which returns type void. In that case, where is that function? Is this only an excerpt?
(This post was last modified: 06-02-2012, 11:45 PM by Bridge.)
06-02-2012, 11:42 PM
Find
palistov Offline
Posting Freak

Posts: 1,208
Threads: 67
Joined: Mar 2011
Reputation: 57
#3
RE: How to make more than 1 script?

Missing } at the very end of your script.

06-02-2012, 11:53 PM
Find
Bridge Offline
Posting Freak

Posts: 1,971
Threads: 25
Joined: May 2012
Reputation: 128
#4
RE: How to make more than 1 script?

(06-02-2012, 11:53 PM)palistov Wrote: Missing } at the very end of your script.
Surely that won't resolve all of his issues, or that debugger doesn't know what it's talking about. Speaking of missing squiggly brackets you should really wrap some [code] tags around that and make sure it's properly indented, it's hell to read.
(This post was last modified: 06-02-2012, 11:57 PM by Bridge.)
06-02-2012, 11:56 PM
Find
Putmalk Offline
Senior Member

Posts: 290
Threads: 13
Joined: Apr 2012
Reputation: 15
#5
RE: How to make more than 1 script?

It's late and I had more to say but I just rewrote the script so it should work...

//I'm guessing this is called after picking up a key or something?
void DoggyAttackPart(string &in asEntity, string &in type)
{
    SetEntityActive("doggy", true);
    StartPlayerLookAt("doggy", 15, 15, "");
    AddTimer("monstertimer", 2, "monstertimer");
    ShowEnemyPlayerPosition("doggy");
}

void monstertimer(string &in asTimer)
{
    StopPlayerLookAt();
}

void scare_script(string &in asParent, string &in asChild, int alState)
{
    //music scripts here
    // If enters and leave
    if(alState == 1)
    {
        PlayMusic("Penumbra_BP_C1.ogg", false, 1.00, 0, 5, true);
    }
    if(alState == -1)
    {

    }
} // error was here, you forgot to add this end bracket

void OnStart()
{
    //////// callbacks go here
    AddEntityCollideCallback("Player", "scare_script", "scare_script", false, 0);
}

void OnEnter()
{
    PlayMusic("penumbra_music_E1_D1", true, 1, 0, 0, true);
}

void OnLeave()
{

}

06-03-2012, 06:52 AM
Find




Users browsing this thread: 2 Guest(s)