Frictional Games Forum (read-only)
Help with a level that has more then two doors. - 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: Help with a level that has more then two doors. (/thread-4810.html)



Help with a level that has more then two doors. - RaZoR~HaX - 09-28-2010

I was wondering if someone could help me code the doors to my level. I can get one door in with void UseKey but when i try to add another door code it doesnt work, could someone help or explain this to me?


RE: Help with a level that has more then two doors. - Jordo76 - 09-28-2010

Easy,Here some example code :
Code:
void UseKey(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked(asEntity, false, true);
PlaySoundAtEntity("", "unlock_door", "Player", 0, false);
RemoveItem(asItem);
}


void OnStart()
{
AddUseItemCallback("useexit", "key_for_door_1", "door_1", "UseKey",true);
AddUseItemCallback("useexit", "key_for_door_2", "door_2", "UseKey",true);
}

I hope it help you !


RE: Help with a level that has more then two doors. - RaZoR~HaX - 09-30-2010

(09-28-2010, 09:46 PM)Jordo76 Wrote: Easy,Here some example code :
Code:
void UseKey(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked(asEntity, false, true);
PlaySoundAtEntity("", "unlock_door", "Player", 0, false);
RemoveItem(asItem);
}


void OnStart()
{
AddUseItemCallback("useexit", "key_for_door_1", "door_1", "UseKey",true);
AddUseItemCallback("useexit", "key_for_door_2", "door_2", "UseKey",true);
}

I hope it help you !

No I do that but it still doesnt work for me, I need an already premade code on how tomake it so there can be more then one locked door on a level without another door being a level door


RE: Help with a level that has more then two doors. - Jordo76 - 09-30-2010

The code i sent you work and if you want to add a door just do :
Code:
AddUseItemCallback("useexit", "name of the key", "name of the door", "UseKey",true);
After the 2 others


RE: Help with a level that has more then two doors. - RaZoR~HaX - 10-01-2010

(09-30-2010, 05:50 PM)Jordo76 Wrote: The code i sent you work and if you want to add a door just do :
Code:
AddUseItemCallback("useexit", "name of the key", "name of the door", "UseKey",true);
After the 2 others

You are my hero


RE: Help with a level that has more then two doors. - fantino - 10-02-2010

I have a problem with 2 locked doors. When i write this, one key open two doors.
Code:
void OnStart()

{
AddUseItemCallback("", "key_study_1", "mansion_2", "UsedKeyOnDoor", true);
AddUseItemCallback("", "key_study_2", "mansion_3", "UsedKeyOnDoor", true);
}

void UsedKeyOnDoor(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked("mansion_2", false, true);
PlayMusic("safe.ogg", true, 1, 11, 1, true);
RemoveItem("key_study_1");

SetSwingDoorLocked("mansion_3", false, true);
PlaySoundAtEntity("", "unlock_door", "mansion_3", 0, false);
RemoveItem("key_study_2");
}

And when i write this, the game crash.
Code:
void OnStart()

{
AddUseItemCallback("", "key_study_1", "mansion_2", "UsedKeyOnDoor", true);
}

void UsedKeyOnDoor(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked("mansion_2", false, true);
PlayMusic("safe.ogg", true, 1, 11, 1, true);
RemoveItem("key_study_1");
}

{
AddUseItemCallback("", "key_study_2", "mansion_3", "UsedKeyOnDoor", true);
}

void UsedKeyOnDoor(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked("mansion_3", false, true);
PlaySoundAtEntity("", "unlock_door", "mansion_3", 0, false);
RemoveItem("key_study_2");
}

Can you help me please ?


RE: Help with a level that has more then two doors. - Jordo76 - 10-02-2010

Revised the Script :
Code:
void OnStart()

{
AddUseItemCallback("", "key_study_1", "mansion_2", "UsedKeyOnDoor", true);
AddUseItemCallback("", "key_study_2", "mansion_3", "UsedKeyOnDoor", true);
}

void UsedKeyOnDoor(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked(asEntity, false, true);
PlaySoundAtEntity("", "unlock_door", "Player", 0, false);
RemoveItem(asItem);
}
Explication : You have not use asItem in RemoveItem,asEntity in SwingDoorLocked
For the 2nd script,all is wrong,you don't have to do more than one void UsedKeyOnDoor
And sometimes you put an { } without void before,crashing the game...


RE: Help with a level that has more then two doors. - fantino - 10-02-2010

Thank you very much! Tongue