Frictional Games Forum (read-only)
Use key to unlock door script, but the script crashes my level? - 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 (https://www.frictionalgames.com/forum/forum-35.html)
+--- Thread: Use key to unlock door script, but the script crashes my level? (/thread-7020.html)



Use key to unlock door script, but the script crashes my level? - Austums - 03-23-2011

Hi guys. I just added this to my hps

Code:
void OnStart()
{
AddEnemyPatrolNode("servant_grunt_1","PathNodeArea_25",3.0f, "");
AddEnemyPatrolNode("servant_grunt_1","PathNodeArea_17",3.0f, "");
AddEntityCollideCallback("Player", "Scream_1", "Scream_1", true, 1);
AddEntityCollideCallback("Player", "Monster_1", "MonsterFunc1", true, 1);
AddUseItemCallback("", "key_study_1", "level_wood_1", "KeyOnDoor", true);
}

void KeyOnDoor(string &in asItem, string &in asEntity)
{
    SetLevelDoorLocked("level_wood_1", false, true);
    PlaySoundAtEntity("", "unlock_door.snt", "level_wood_1", 0.0f, true);
}

The AddUseItemCallback is where the key stuff starts, obviously.

I don't see what the problem is. I named everything correctly.


Oh, here's the error I get

main (28,5) : ERR: No matching signatures to 'SetLevelDoorLocked(string@&, const bool, const bool)'


RE: Use key to unlock door script, but the script crashes my level? - Viperdream - 03-23-2011

What does the error say?

EDIT:
Nevermind, this is what's wrong, you left the name open.
Code:
AddUseItemCallback("KeyOnDoor", "key_study_1", "level_wood_1", "KeyOnDoor", true);  //Fix'd code

This should help


RE: Use key to unlock door script, but the script crashes my level? - Austums - 03-23-2011

Updated my original post with the error.
Still getting an error :/

ERR: No matching signatures to 'SetLevelDoorLocked(string@&, const bool, const bool)'

I'll post my entire script. Everything works fine when I take out this new door script, btw. Also thank you for your help!

Code:
void OnEnter()
{
AddTimer("FadeIntro", 0, "FadeIntro");
}

void FadeIntro(string &in asTimer)
{
FadeOut(0);
FadeIn(6);
PlaySoundAtEntity("Startle_1", "react_scare.snt", "Startle_1", 0, false);
}

void OnLeave()
{
}

void OnStart()
{
AddEnemyPatrolNode("servant_grunt_1","PathNodeArea_25",3.0f, "");
AddEnemyPatrolNode("servant_grunt_1","PathNodeArea_17",3.0f, "");
AddEntityCollideCallback("Player", "Scream_1", "Scream_1", true, 1);
AddEntityCollideCallback("Player", "Monster_1", "MonsterFunc1", true, 1);
AddUseItemCallback("KeyOnDoor", "key_study_1", "level_wood_1", "KeyOnDoor", true);

}

void KeyOnDoor(string &in asItem, string &in asEntity)
{
    SetLevelDoorLocked("level_wood_1", false, true);
    PlaySoundAtEntity("", "unlock_door.snt", "level_wood_1", 0.0f, true);
}

void MonsterFunc1(string &in asParent, string &in asChild, int alState)
{
  SetEntityActive("servant_grunt_1", true);
}
void Scream_1(string &in asParent, string &in asChild, int alStates)
{
   AddTimer("Somenamedoesntreallymatter", 3.0f, "Scream_Trigger");
}

void Scream_Trigger(string &in asTimer)
{
   PlaySoundAtEntity("Scream_1", "12_girl_scream.snt", "Scream_1", 0, false);
   PlaySoundAtEntity("Scream_1", "react_scare.snt", "Scream_1", 0, false);
   StartPlayerLookAt("LookArea_1", 2, 2, "");
   AddTimer("Somenamedoesntreallymatter", 2.0f, "LookArea_Trigger");
}
void LookArea_Trigger(string &in asTimer)
{
   StopPlayerLookAt();
}



RE: Use key to unlock door script, but the script crashes my level? - Viperdream - 03-23-2011

Wait, now I see the problem

Remove the last "true" of the SetLevelDoorLocked

Level doors don't have an effect Smile


RE: Use key to unlock door script, but the script crashes my level? - Austums - 03-23-2011

Good news is the level ran!

Bad news is, the door wasn't even locked. xD Do I lock a door from the Level Editor?


RE: Use key to unlock door script, but the script crashes my level? - Viperdream - 03-23-2011

Yup

You can also do that in the script with

Code:
void OnStart()
{
SetLevelDoorLocked("level_door", true);
}

But that's kind of a waste of time Tongue