Frictional Games Forum (read-only)
Can't make an unlockable door - 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: Can't make an unlockable door (/thread-54073.html)



Can't make an unlockable door - 1402News - 01-22-2018

I've been trying all the solutions I can but nothing works! Here's my script.

void OnStart()
{
AddUseItemCallback("", "CSBedroomKey", "CSBedroomDoor", "UseKeyOnCSBedroomDoor", true);
}
void FUNCTION(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked(asEntity, false, true);
PlaySoundAtEntity("", "unlock_door", asEntity, 0, false);
RemoveItem(asItem);
}


RE: Can't make an unlockable door - Romulator - 01-22-2018

You need to rename your FUNCTION parameter to match the one in your UseItem Callback. In this case, you need to name your function like this:

PHP Code:
void UseKeyOnCSBedroomDoor(string &in asItemstring &in asEntity)
{
SetSwingDoorLocked(asEntityfalsetrue);
PlaySoundAtEntity("""unlock_door"asEntity0false);
RemoveItem(asItem);


Provided your key and door names are correct in your map, then this script should work correctly now. Smile


RE: Can't make an unlockable door - 1402News - 01-23-2018

(01-22-2018, 06:17 PM)Romulator Wrote: You need to rename your FUNCTION parameter to match the one in your UseItem Callback. In this case, you need to name your function like this:

PHP Code:
void UseKeyOnCSBedroomDoor(string &in asItemstring &in asEntity)
{
SetSwingDoorLocked(asEntityfalsetrue);
PlaySoundAtEntity("""unlock_door"asEntity0false);
RemoveItem(asItem);


Provided your key and door names are correct in your map, then this script should work correctly now. Smile

So in other words, remove the FUNCTION part?

(01-23-2018, 01:13 AM)1402News Wrote:
(01-22-2018, 06:17 PM)Romulator Wrote: You need to rename your FUNCTION parameter to match the one in your UseItem Callback. In this case, you need to name your function like this:

PHP Code:
void UseKeyOnCSBedroomDoor(string &in asItemstring &in asEntity)
{
SetSwingDoorLocked(asEntityfalsetrue);
PlaySoundAtEntity("""unlock_door"asEntity0false);
RemoveItem(asItem);


Provided your key and door names are correct in your map, then this script should work correctly now. Smile

So in other words, remove the FUNCTION part?

Actually, I've tried it with the function saying FUNCTION and the door still wouldn't unlock.


RE: Can't make an unlockable door - 1402News - 01-23-2018

(01-22-2018, 06:17 PM)Romulator Wrote: You need to rename your FUNCTION parameter to match the one in your UseItem Callback. In this case, you need to name your function like this:

PHP Code:
void UseKeyOnCSBedroomDoor(string &in asItemstring &in asEntity)
{
SetSwingDoorLocked(asEntityfalsetrue);
PlaySoundAtEntity("""unlock_door"asEntity0false);
RemoveItem(asItem);


Provided your key and door names are correct in your map, then this script should work correctly now. Smile
I attempted it. It doesn't work. It still says "Cannot use item this way".


RE: Can't make an unlockable door - Mudbill - 01-24-2018

Can you screenshot the names of the objects in your level editor and upload them to https://imgur.com and link them here?


RE: Can't make an unlockable door - Neelke - 01-26-2018

(01-23-2018, 04:27 PM)1402News Wrote:
(01-22-2018, 06:17 PM)Romulator Wrote: You need to rename your FUNCTION parameter to match the one in your UseItem Callback. In this case, you need to name your function like this:

PHP Code:
void UseKeyOnCSBedroomDoor(string &in asItemstring &in asEntity)
{
SetSwingDoorLocked(asEntityfalsetrue);
PlaySoundAtEntity("""unlock_door"asEntity0false);
RemoveItem(asItem);


Provided your key and door names are correct in your map, then this script should work correctly now. Smile
I attempted it. It doesn't work. It still says "Cannot use item this way".

As far as I know you've flipped the two string parameters? I could be wrong but the function is programmed to have the entity first, then the item parameter. This won't help your current issue but it would help later on I imagine since your code is dependant on the parameters.

Code:
void UseKeyOnCSBedroomDoor(string &in asEntity, string &in asItem)
{
SetSwingDoorLocked(asEntity, false, true);
PlaySoundAtEntity("", "unlock_door", asEntity, 0, false);
RemoveItem(asItem);
}



RE: Can't make an unlockable door - Mudbill - 01-27-2018

No, the item comes first.

[Image: uGyZChQ.png]