Frictional Games Forum (read-only)
How to unlock door with key? - 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 unlock door with key? (/thread-5650.html)

Pages: 1 2 3


RE: How to unlock door with key? - LoneWolf - 12-11-2010

Scripts all right, its the tabs in the level editor which may have been filled out wrongly. I think the key needs 3 names down, 1 for the cfg file, for name of key and text to appear, and 1 for key picked up and 1 for key to be used on door and for key to be removed.

But the door just needs 2, one in collide i think and 1 in name.

If you've done this right then, have you posted your full script? and does the error say theres a line wrong? eg. (2,1).


RE: How to unlock door with key? - HumiliatioN - 12-11-2010

(12-11-2010, 01:45 AM)LoneWolf Wrote: Scripts all right, its the tabs in the level editor which may have been filled out wrongly. I think the key needs 3 names down, 1 for the cfg file, for name of key and text to appear, and 1 for key picked up and 1 for key to be used on door and for key to be removed.

But the door just needs 2, one in collide i think and 1 in name.

If you've done this right then, have you posted your full script? and does the error say theres a line wrong? eg. (2,1).

I have corrected these in level editor..


ERROR: FATAL ERROR: Could not load script file custom/stories/FTD/custom_stories/FTD/maps/00_example.hps'! main (3,2) : ERR : No matching signatures to 'AddUseItemCallback(string@&, string@&, const bool)'


Full Script:

void OnStart()
{
AddUseItemCallback("", "key_1", "door_1" "UsedKeyOnDoor", true);
}

void UsedKeyOnDoor(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked("door_1", false, true);
PlaySoundAtEntity("", "unlock_door.snt", "door_1", 0.0f, false);
RemoveItem("key_1");
AddDebugMessage("KeyOnDoor", false);
}

////////////////////////////
// Run when entering map
void OnEnter()
{
}

////////////////////////////
// Run when leaving map
void OnLeave()
{
}

Im confused how this can be so confusing and hard... I dont never learn scripting i just love this game and just wanna make one beautiful map :I


RE: How to unlock door with key? - jens - 12-11-2010

these is a , missing in
AddUseItemCallback("", "key_1", "door_1" "UsedKeyOnDoor", true);

make it
AddUseItemCallback("", "key_1", "door_1", "UsedKeyOnDoor", true);


RE: How to unlock door with key? - HumiliatioN - 12-11-2010

(12-11-2010, 01:06 PM)jens Wrote: these is a , missing in
AddUseItemCallback("", "key_1", "door_1" "UsedKeyOnDoor", true);

make it
AddUseItemCallback("", "key_1", "door_1", "UsedKeyOnDoor", true);

Holy shit! It works thanks u are my savior!! Blush


RE: How to unlock door with key? - Frontcannon - 12-11-2010

Quote:There's a comma missing in your callback.

Dodgy

This could've been solved much earlier.. well, nice that you got it working.


RE: How to unlock door with key? - HumiliatioN - 12-11-2010

(12-11-2010, 04:54 PM)Frontcannon Wrote:
Quote:There's a comma missing in your callback.

Dodgy

This could've been solved much earlier.. well, nice that you got it working.

Yeah i know okay only one thing now... How i am missing the "name of key" and description of key? Tell me codes and im good Smile


RE: How to unlock door with key? - Frontcannon - 12-11-2010

Why should you miss anything when it works?


RE: How to unlock door with key? - HumiliatioN - 12-11-2010

(12-11-2010, 05:22 PM)Frontcannon Wrote: Why should you miss anything when it works?

Now it only works when i use the key on door and it unlocks and that sound, but it only says when i picked up key "Picked up" and now description in the key? Thats my problem..


RE: How to unlock door with key? - Tirilno - 07-06-2011

Can you guys please look at my script? Smile I have tried everyting and looked through every 'how to' and tutorial videos I find but I can't unlock my door -.- I want my door to be open when I use the key, but It's still locked after I use it :/ (I'm using a level door) Tongue

void OnStart()
{
AddUseItemCallback("", "Storagekey_1", "Storagedoor", "KeyOnDoor", true);
}
void KeyOnDoor(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked("Storagedoor", false, true);
PlaySoundAtEntity("", "Unlock_door", "Storagedoor", 0, false);
}
void OnLeave()
{

}


RE: How to unlock door with key? - Kyle - 07-06-2011

(07-06-2011, 10:18 PM)Tirilno Wrote: Can you guys please look at my script? Smile I have tried everyting and looked through every 'how to' and tutorial videos I find but I can't unlock my door -.- I want my door to be open when I use the key, but It's still locked after I use it :/ (I'm using a level door) Tongue

void OnStart()
{
AddUseItemCallback("", "Storagekey_1", "Storagedoor", "KeyOnDoor", true);
}
void KeyOnDoor(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked("Storagedoor", false, true);
PlaySoundAtEntity("", "Unlock_door", "Storagedoor", 0, false);
}
void OnLeave()
{

}

For level doors you have to use this:

SetLevelDoorLocked(string& asName, bool abLocked);

Try this:

Code:
void OnStart()
{
   AddUseItemCallback("", "Storagekey_1", "Storagedoor", "KeyOnDoor", true);
}
void KeyOnDoor(string &in asItem, string &in asEntity)
{
     SetLevelDoorLocked("Storagedoor", false);
     PlaySoundAtEntity("", "unlock_door", "Storagedoor", 0, false);
}
void OnLeave()
{

}