Frictional Games Forum (read-only)
A simple key problem. - 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: A simple key problem. (/thread-13820.html)



A simple key problem. - Asaratha - 03-06-2012

Hey guys!

I used to do scripting a long time ago, and for the past week I've been getting into it again. Although, trying to unlock a door using a key is giving me quite the problem for some reason.

void OnStart()
{
AddUseItemCallback("", "", "key_1", "KeyOnDoor", true);
AddUseItemCallback("", "hidden_key", "hidden_door", "KeyOnHiddenDoor", true);
AddEntityCollideCallback("Player", "PlayerCollide", "MonsterFunction", true, 1); SetEntityPlayerInteractCallback("key_1", "Spawn_Monster", true);
}
void KeyOnDoor(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked("lockedhall", false, true);
PlaySoundAtEntity("", "unlock_door", "lockedhall", 0, false);
RemoveItem("key_1");
}
void Spawn_Monster(string &in entity)
{
SetEntityActive("grunt", true);
AddEnemyPatrolNode("grunt", "PathNodeArea_1", 2, "");
AddEnemyPatrolNode("grunt", "PathNodeArea_2", 0, "");
AddEnemyPatrolNode("grunt", "PathNodeArea_3", 4, "");
}


That's what I have, although, when I get in game it says "Cannot be used this way".

I'm sorry if I'm doing something obviously wrong, I've just lost all of my skill when it comes to this.


RE: A simple key problem. - Mackiiboy - 03-06-2012

(03-06-2012, 10:25 PM)Asaratha Wrote: Hey guys!

I used to do scripting a long time ago, and for the past week I've been getting into it again. Although, trying to unlock a door using a key is giving me quite the problem for some reason.
.

void AddUseItemCallback(string& asName, string& asItem, string& asEntity, string& asFunction, bool abAutoDestroy);

AddUseItemCallback("", "", "key_1", "KeyOnDoor", true);

I think the red-marked spots are wrong and they instead should be:

AddUseItemCallback("", "key_1", "lockedhall", "KeyOnDoor", true);

Add you door (lockedhall) and set the Item (key_1) on the right place. Hope it works Shy


RE: A simple key problem. - Asaratha - 03-06-2012

(03-06-2012, 10:40 PM)Mackiiboy Wrote:
(03-06-2012, 10:25 PM)Asaratha Wrote: Hey guys!

I used to do scripting a long time ago, and for the past week I've been getting into it again. Although, trying to unlock a door using a key is giving me quite the problem for some reason.
.

void AddUseItemCallback(string& asName, string& asItem, string& asEntity, string& asFunction, bool abAutoDestroy);

AddUseItemCallback("", "", "key_1", "KeyOnDoor", true);

I think the red-marked spots are wrong and they instead should be:

AddUseItemCallback("", "key_1", "lockedhall", "KeyOnDoor", true);

Add you door (lockedhall) and set the Item (key_1) on the right place. Hope it works Shy

Thank you so much <3