Frictional Games Forum (read-only)
well..I'm stuck again on 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 - Development (https://www.frictionalgames.com/forum/forum-38.html)
+---- Forum: Development Support (https://www.frictionalgames.com/forum/forum-39.html)
+---- Thread: well..I'm stuck again on doors (/thread-21078.html)

Pages: 1 2


well..I'm stuck again on doors - megsb927 - 04-07-2013

Hi guys well here's the problem: You go into map3, a door in the room is locked, you leave this room to get a key, but when you come back the door is unlocked before you can use a key on it... here's the script for map3:
void OnStart()
{
AddUseItemCallback("", "Key3", "castle_1", "UsedKeyOnDoor", true);
AddUseItemCallback("", "Key4", "castle_2", "UsedKeyOnDoor", true);
}

void UsedKeyOnDoor(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked("castle_1", false, false);
PlaySoundAtEntity("", "unlock_door", "castle_1", 0, false);
RemoveItem("Key3");
SetSwingDoorLocked("castle_2", false, false);
PlaySoundAtEntity("", "unlock_door", "castle_2", 0, false);
RemoveItem("Key4");
}
void OnEnter()
{

}

void OnLeave()
{

}


RE: well..I'm stuck again on doors - PutraenusAlivius - 04-07-2013

void OnStart()
{
SetEntityCallbackFunc("KEYNAME", "FUNCTION");
}

void FUNCTION(string &in asEntity, string &in Type)
{
SetSwingDoorLocked("DOORNAME", false, false);
}

(NOTE: This is the script that you've mentioned -- which is making the door to unlock BEFORE you can use it. Although it's unlocked when you pick the key up.)


RE: well..I'm stuck again on doors - megsb927 - 04-07-2013

(04-07-2013, 06:11 AM)JustAnotherPlayer Wrote: void OnStart()
{
SetEntityCallbackFunc("KEYNAME", "FUNCTION");
}

void FUNCTION(string &in asEntity, string &in Type)
{
SetSwingDoorLocked("DOORNAME", false, false);
}

(NOTE: This is the script that you've mentioned -- which is making the door to unlock BEFORE you can use it. Although it's unlocked when you pick the key up.)

I'm still confused what do I change?:/


RE: well..I'm stuck again on doors - noovra - 04-07-2013

Hm.. try this!

void OnStart()
{
AddUseItemCallback("", "Key3", "castle_1", "UsedKeyOnDoor", true);
AddUseItemCallback("", "Key4","castle_2", "UsedKeyOnDoor", true);
}

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

That was it. Be sure, that in the void funct stay the same, as I wrote.
I hope, It's a solution for your problem Smile.


RE: well..I'm stuck again on doors - megsb927 - 04-07-2013

(04-07-2013, 08:02 AM)noovra Wrote: Hm.. try this!

void OnStart()
{
AddUseItemCallback("", "Key3", "castle_1", "UsedKeyOnDoor", true);
AddUseItemCallback("", "Key4","castle_2", "UsedKeyOnDoor", true);
}

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

That was it. Be sure, that in the void funct stay the same, as I wrote.
I hope, It's a solution for your problem Smile.

Hmm that didn't work either:/ I need to be able to have two of the
SetSwingDoorLocked(asEntity, false, false);
PlaySoundAtEntity("","unlock_door", asEntity, 0, false);
RemoveItem(asItem);
But I don't know how it's written and then I need the door to still be locked when I come back into the room


RE: well..I'm stuck again on doors - FlawlessHappiness - 04-07-2013

What? Why?

Listen. You need to understand how the script functions work.

Look.

When you write this line:
AddUseItemCallback("", "Key3", "castle_1", "UsedKeyOnDoor", true);



It means, "When i use Key3 on castle_1 it should call the function UsedKeyOnDoor."
Then you create the function:

void UsedKeyOnDoor(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked("castle_1", false, false);
PlaySoundAtEntity("", "unlock_door", "castle_1", 0, false);
RemoveItem("Key3");
SetSwingDoorLocked("castle_2", false, false);
PlaySoundAtEntity("", "unlock_door", "castle_2", 0, false);
RemoveItem("Key4");
}



This function says: "Unlock castle_1 and castle_2! Play two sound! Remove Key1 and Key4"


Do you see there's something wrong? When you use 1 key on a door, both doors will unlock.
THat's a problem!


You have to create 2 functions!



void UsedKeyOnDoor1(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked("castle_1", false, false);
PlaySoundAtEntity("", "unlock_door", "castle_1", 0, false);
RemoveItem("Key3");
}


void UsedKeyOnDoor2(string &in asItem, string &in asEntity)
{

SetSwingDoorLocked("castle_2", false, false);
PlaySoundAtEntity("", "unlock_door", "castle_2", 0, false);
RemoveItem("Key4");
}


I have called them: UsedKeyOnDoor1 and UsedKeyOnDoor2.


Now the void OnStart() looks like this:


void OnStart()
{
AddUseItemCallback("", "Key3", "castle_1", "UsedKeyOnDoor1", true);
AddUseItemCallback("", "Key4","castle_2", "UsedKeyOnDoor2", true);
}



Do you see? They call each their function.


Key3 on castle_1 calls UsedKeyOnDoor1
Key4 on caslte_2 calls UsedKeyOnDoor2


RE: well..I'm stuck again on doors - noovra - 04-07-2013

(04-07-2013, 08:58 AM)megsb927 Wrote:
(04-07-2013, 08:02 AM)noovra Wrote: Hm.. try this!

void OnStart()
{
AddUseItemCallback("", "Key3", "castle_1", "UsedKeyOnDoor", true);
AddUseItemCallback("", "Key4","castle_2", "UsedKeyOnDoor", true);
}

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

That was it. Be sure, that in the void funct stay the same, as I wrote.
I hope, It's a solution for your problem Smile.

Hmm that didn't work either:/ I need to be able to have two of the
SetSwingDoorLocked(asEntity, false, false);
PlaySoundAtEntity("","unlock_door", asEntity, 0, false);
RemoveItem(asItem);
But I don't know how it's written and then I need the door to still be locked when I come back into the room

Actually u don't have to write 2 functions.. or what ever. With the function that I've posted it should probably work.
U just want two locked doors and two different keys? Yes?
Like "KeyA" for "DoorA" and "KeyB" for "DoorB".
I don't even found any problems with the script =/.
Maybe u wrote something wrong?


RE: well..I'm stuck again on doors - FlawlessHappiness - 04-07-2013

(04-07-2013, 09:33 AM)noovra Wrote:
(04-07-2013, 08:58 AM)megsb927 Wrote:
(04-07-2013, 08:02 AM)noovra Wrote: Hm.. try this!

void OnStart()
{
AddUseItemCallback("", "Key3", "castle_1", "UsedKeyOnDoor", true);
AddUseItemCallback("", "Key4","castle_2", "UsedKeyOnDoor", true);
}

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

That was it. Be sure, that in the void funct stay the same, as I wrote.
I hope, It's a solution for your problem Smile.

Hmm that didn't work either:/ I need to be able to have two of the
SetSwingDoorLocked(asEntity, false, false);
PlaySoundAtEntity("","unlock_door", asEntity, 0, false);
RemoveItem(asItem);
But I don't know how it's written and then I need the door to still be locked when I come back into the room

Actually u don't have to write 2 functions.. or what ever. With the function that I've posted it should probably work.
U just want two locked doors and two different keys? Yes?
Like "KeyA" for "DoorA" and "KeyB" for "DoorB".
I don't even found any problems with the script =/.
Maybe u wrote something wrong?

No, it looks like he wants KeyA for DoorA and KeyB for DoorB
Key3 for castle_1
Key4 for castle_2


RE: well..I'm stuck again on doors - noovra - 04-07-2013

(04-07-2013, 09:45 AM)BeeKayK Wrote:
(04-07-2013, 09:33 AM)noovra Wrote:
(04-07-2013, 08:58 AM)megsb927 Wrote:
(04-07-2013, 08:02 AM)noovra Wrote: Hm.. try this!

void OnStart()
{
AddUseItemCallback("", "Key3", "castle_1", "UsedKeyOnDoor", true);
AddUseItemCallback("", "Key4","castle_2", "UsedKeyOnDoor", true);
}

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

That was it. Be sure, that in the void funct stay the same, as I wrote.
I hope, It's a solution for your problem Smile.

Hmm that didn't work either:/ I need to be able to have two of the
SetSwingDoorLocked(asEntity, false, false);
PlaySoundAtEntity("","unlock_door", asEntity, 0, false);
RemoveItem(asItem);
But I don't know how it's written and then I need the door to still be locked when I come back into the room

Actually u don't have to write 2 functions.. or what ever. With the function that I've posted it should probably work.
U just want two locked doors and two different keys? Yes?
Like "KeyA" for "DoorA" and "KeyB" for "DoorB".
I don't even found any problems with the script =/.
Maybe u wrote something wrong?

No, it looks like he wants KeyA for DoorA and KeyB for DoorB
Key3 for castle_1
Key4 for castle_2

Exactly what I meant. Both scripts should work fine.


RE: well..I'm stuck again on doors - FlawlessHappiness - 04-07-2013

Oh sorry then.

Ah, yes i see how your script works now! Wink

Great job. We'll just hope he understands it.