Frictional Games Forum (read-only)
[SCRIPT] Key Unlock Door script won't work :( - 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] Key Unlock Door script won't work :( (/thread-18691.html)



Key Unlock Door script won't work :( - Rowzter - 10-08-2012

Hello everyone, i am new here on this forum an i need some help with my script.
PS: If this thread is on the wrong board then just move it and i know this is a common problem

i want my key to unlock "the door", But as everyone else i get "could't not use item this way" i think its called, I have checked many tutorials and read some threads here on the forum and tried their way, but it wont work =(

Here's my script:

void OnStart()
{
AddUseItemCallback("", "basementkey_1", "basementdoor_1", "UsedKeyOnDoor", true);
}

void UsedKeyOnDoor(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked(asEntity, false, true);
PlaySoundAtEntity("", "unlock_door","basementdoor_1", 0.0f, false);
RemoveItem(basementkey_1);
}


Now, if you find whats wrong or if there are some errors then please help me, That would mean alot
i have checked so the names are the same and so, and i also tried to change the names of the door and key and see if that worked, but no positive feedback i got from it Sad

sorry for my bad english, i get nervous when writing in english :O


RE: Key Unlock Door script won't work :( - craven7 - 10-08-2012

If it says "could not use item this way", then the problem is definitly in this line, otherwise you wouldn't get this message:

AddUseItemCallback("", "basementkey_1", "basementdoor_1", "UsedKeyOnDoor", true);


Also you might want to replace
Code:
PlaySoundAtEntity("", "unlock_door","basementdoor_1", 0.0f, false);
RemoveItem(basementkey_1);
with
Code:
PlaySoundAtEntity("", "unlock_door","asEntity", 0.0f, false);
RemoveItem(asItem);
. This won't solve your problem, but now you can use this method for every key-door callback.


RE: Key Unlock Door script won't work :( - 4WalledKid - 10-08-2012

You didn't specify the door you want to unlock with the key in
SetSwingDoorLocked(asEntity, false, true);

Code:
void UsedKeyOnDoor(string &in asItem, string &in asEntity)
{ SetSwingDoorLocked("basementdoor_1", false, true);
   PlaySoundAtEntity("", "unlock_door","basementdoor_1", 0.0f, false);
   RemoveItem(basementkey_1);
}

Let me know if it worked!


RE: Key Unlock Door script won't work :( - Your Computer - 10-09-2012

(10-08-2012, 10:55 PM)4WalledKid Wrote: You didn't specify the door you want to unlock with the key in
SetSwingDoorLocked(asEntity, false, true);

That would be how you specify it, given the parameters. craven7 pointed out one of the errors in the script, but also committed another (i.e. placing asEntity within quotation marks for PlaySoundAtEntity). However, the fact that the user is still able to load the map implies that the script is named differently than the map. The user would have received an undeclared variable error, unless the operating system is giving the game the wrong file.


RE: Key Unlock Door script won't work :( - Rowzter - 10-09-2012

Well, Thx for the help anyway, it just don't want to work Sad .

Whatever, i skip those locked doors, but are there some other alternatives instead of unlocking door with key? Tongue


And i have a new question, i want a grunt to spawn when i pick up a health potion and i added som pathnodes i think they called, But is this scriptcode right?:


void OnStart()
{
SetEntityPlayerInteractCallback("potion_health_2", "ActivateMonster", true);

}






void ActivateMonster(string &in item)
{
SetEntityActivate("basementgrunt_1", true);
AddEnemyPatrolNode("basementgrunt_1","PathNodeArea_1", 0,"idle");
AddEnemyPatrolNode("basementgrunt_1","PathNodeArea_2", 0,"idle");
AddEnemyPatrolNode("basementgrunt_1","PathNodeArea_3", 0,"idle");
AddEnemyPatrolNode("basementgrunt_1","PathNodeArea_4", 0,"idle");
AddEnemyPatrolNode("basementgrunt_1","PathNodeArea_5", 0,"idle");
AddEnemyPatrolNode("basementgrunt_1","PathNodeArea_6", 0,"idle");
}

void Onstart()
{
CallBackFunction ("Syntaxfeeble", true);



the syntaxfeeble have i never spotted before? :O


RE: Key Unlock Door script won't work :( - Robby - 10-09-2012

First, let me show you this.

(10-09-2012, 07:26 PM)Rowzter Wrote: void OnStart()
{
SetEntityPlayerInteractCallback("potion_health_2", "ActivateMonster", true);

}






void ActivateMonster(string &in item)
{
SetEntityActivate("basementgrunt_1", true);
AddEnemyPatrolNode("basementgrunt_1","PathNodeArea_1", 0,"idle");
AddEnemyPatrolNode("basementgrunt_1","PathNodeArea_2", 0,"idle");
AddEnemyPatrolNode("basementgrunt_1","PathNodeArea_3", 0,"idle");
AddEnemyPatrolNode("basementgrunt_1","PathNodeArea_4", 0,"idle");
AddEnemyPatrolNode("basementgrunt_1","PathNodeArea_5", 0,"idle");
AddEnemyPatrolNode("basementgrunt_1","PathNodeArea_6", 0,"idle");
}

void OnEnter()
{
CallBackFunction ("Syntaxfeeble", true);
}

"CallBackFunction"? Don't think something like that exists.

For scripts, go to the Script Functions Page .


RE: Key Unlock Door script won't work :( - Rowzter - 10-10-2012

Did some changes now, but it still don't work, i checked the wiki and everything.


void OnStart()
{


SetEntityPlayerInteractCallback("potion_health_2", "ActivateMonster", true);

}



SetEntityActive("servant_grunt_1", true);
AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_1", 2, "");
AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_2", 0, "");
AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_3", 0, "");
AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_4", 0, "");
AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_5", 0, "");
AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_6", 0, "");
}
void OnEnter()
{



}


void OnLeave()
{


RE: Key Unlock Door script won't work :( - Dutton - 10-10-2012

you forgot to start your void ActivateMonster(String &in Item)


RE: Key Unlock Door script won't work :( - Rowzter - 10-10-2012

damn, if someone could correct my scripts and then post em here so i can use them, i tried all solutions here but it won't work, I doublechecked everything but nothing is working Sad


RE: Key Unlock Door script won't work :( - The chaser - 10-10-2012

Errr... it think it should be:

Code:
void OnStart()

{

SetEntityPlayerInteractCallback("potion_health_2", "ActivateMonster", true);
}



void ActivateMonster (string &in asEntity);

{

SetEntityActive("servant_grunt_1", true);

    AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_1", 2, "");

    AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_2", 0, "");

    AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_3", 0, "");

    AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_4", 0, "");

    AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_5", 0, "");

    AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_6", 0, "");

}

void OnEnter()

{







}





void OnLeave()

{
            

}