Frictional Games Forum (read-only)
Script help for level 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 - Development (https://www.frictionalgames.com/forum/forum-38.html)
+---- Forum: Development Support (https://www.frictionalgames.com/forum/forum-39.html)
+---- Thread: Script help for level door (/thread-20263.html)



Script help for level door - afroduckie - 02-10-2013

This is the script for a locked level door. the key you need is level_4_key.
It is supposed to activate a grunt when the door is unlocked (as a scare).

void UseKey(string &in asItem, string &in asEntity)
{
AddUseItemCallback("", "level_4_key", "level4", "UsedKeyOnDoor", true);
}

void UsedKeyOnDoor(string &in asItem, string &in asEntity)
{
SetLevelDoorLocked("level4", true);
PlaySoundAtEntity("", "unlock_door", "level4", 0, false);
RemoveItem("level_4_key");
SetEntityActive("servant_grunt", true);
}

Where did I go wrong?


RE: Script help for level door - NaxEla - 02-10-2013

Put
Code:
AddUseItemCallback("", "level_4_key", "level4", "UsedKeyOnDoor", true);
in your OnStart function.

Like this:
PHP Code:
void OnStart()
{
    
AddUseItemCallback("""level_4_key""level4""UsedKeyOnDoor"true);




RE: Script help for level door - No Author - 02-10-2013

I thought unlocking level doors use a different script.

EDIT : Never mind.


RE: Script help for level door - NaxEla - 02-10-2013

Oh, I also just realized: In this line of your code:
Code:
SetLevelDoorLocked("level4", true);
you are actually making the door locked. By change true to false, it will unlock it.

@No Author
Swing doors use SetSwingDoorLocked, and level doors use SetLevelDoorLocked. So, yes, they do use slightly different functions.


RE: Script help for level door - No Author - 02-10-2013

(02-10-2013, 02:43 AM)NaxEla Wrote: Oh, I also just realized: In this line of your code:
Code:
SetLevelDoorLocked("level4", true);
you are actually making the door locked. By change true to false, it will unlock it.

@No Author
Swing doors use SetSwingDoorLocked, and level doors use SetLevelDoorLocked. So, yes, they do use slightly different functions.

Lol. I didn't read it clearly in the first place.
I really need to improve my reading.


RE: Script help for level door - afroduckie - 02-10-2013

(02-10-2013, 02:56 AM)No Author Wrote:
(02-10-2013, 02:43 AM)NaxEla Wrote: Oh, I also just realized: In this line of your code:
Code:
SetLevelDoorLocked("level4", true);
you are actually making the door locked. By change true to false, it will unlock it.

@No Author
Swing doors use SetSwingDoorLocked, and level doors use SetLevelDoorLocked. So, yes, they do use slightly different functions.

Lol. I didn't read it clearly in the first place.
I really need to improve my reading.

I did notice that. Thanks for pointing it out.