Frictional Games Forum (read-only)
How to make more than 1 script? - Printable Version

+- Frictional Games Forum (read-only) (https://www.frictionalgames.com/forum)
+-- Forum: Amnesia: The Dark Descent (https://www.frictionalgames.com/forum/forum-6.html)
+--- Forum: Custom Stories, TCs & Mods - Development (https://www.frictionalgames.com/forum/forum-38.html)
+---- Forum: Development Support (https://www.frictionalgames.com/forum/forum-39.html)
+---- Thread: How to make more than 1 script? (/thread-15795.html)



How to make more than 1 script? - FrictionalWeekly - 06-02-2012

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

__________________________________________


RE: How to make more than 1 script? - Bridge - 06-02-2012

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?


RE: How to make more than 1 script? - palistov - 06-02-2012

Missing } at the very end of your script.


RE: How to make more than 1 script? - Bridge - 06-02-2012

(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.


RE: How to make more than 1 script? - Putmalk - 06-03-2012

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

Code:
//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()
{

}