Frictional Games Forum (read-only)
Amnesia Level Editor Key Script Not Working - 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: Amnesia Level Editor Key Script Not Working (/thread-17606.html)

Pages: 1 2


Amnesia Level Editor Key Script Not Working - youngblood128 - 08-08-2012

Hey I was really looking for some help on my script, I used a layout to make it so that a key works on a certain door I've seen tutorials and tried it using that layout but it didn't work i revised it and fixed some errors but it still doesn't work(in depth explanation at bottom)and I also tried typing it from scratch and looking at various videos and searching the forums I am still stuck here is my coding.
extra_english.lang file:

<LANGUAGE>
<CATEGORY Name="CustomStoryMain">
<Entry Name="Description">You awake in your room to discover that some form of darkness followed you one night you had a case of amnesia and connot remember the horrors of that night whatever it is...it wants you, it is your job to discover his secret and stop the darkness.</Entry>
</CATEGORY>
<CATEGORY Name="inventory">
<Entry Name="ItemName_Key1">Main Hall Key</Entry>
<Entry Name="ItemDesc_Key1">Opens Main Hall Door.</Entry>
</CATEGORY>
<CATEGORY Name="Journal">
<Entry Name="Note_01_Name">Danger!</Entry>
<Entry Name="Note_01_Text">Brother! Are you ok I hope you are we heard noises outside and when we went to investigate you were lying on the the floor screaming "man and chain" we took you upstairs to your room so that you could rest about 30 minutes later a death was reported people said they were being attacked by a man covered in chains you know something about this...everybody is dying!...I want you to be save I'm going to barracade the door to protect you I'm going out I want to help the people who I hear with distant screams don't worry about me just be safe and stop whatever this is! </Entry>
<Entry Name="Note_02_Name">Escape!</Entry>
<Entry Name="Note_02_Text">Trapped in this room monster outside he seems to be blocking everyone from leaving I had a plan but its too late due to over growth of bushes, trees and plants half of the castle is covered in plants so we boarded up the windows weeks ago to prevent plants from coming into the castle; with some kind of dagger and a crowbar you might be able to escape I had a crowbar but I dropped it in the prison...I hear him! Good luck to whom ever reads this...you'll need it.</Entry>
</CATEGORY>
</LANGUAGE>
my maps.hps file

void OnEnter()
{
AddUseItemCallback("", "Key_1", "Main1", "UsedKeyOnDoor", true);
}


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


void OnLeave()
{

}
--------------------------------
That's the coding I just started, with my key name is key_1 and its sub name is key1 and the door is called
Main1 what happens is that when I pick up the key it says "picked up" but it has no name and no description and it doesn't unlock the door and help would be great thanks.





RE: Amnesia Level Editor Key Script Not Working - Melvin - 08-09-2012

//////////////////////////////////////////////////AddUseItemCallback("", "Awesomekey","AwesomeDoor", "KeyOnDoor", true);


void KeyOnDoor(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked("AwesomeDoor", false, true);
PlaySoundAtEntity("", "unlock_door", "AwesomeDoor", 0, false);
RemoveItem("Awesomekey");
}
///////////////////////////
this is my own usage of the keyscript, I've got no idea whats wrong with yours bro :O


RE: Amnesia Level Editor Key Script Not Working - Seragath - 08-09-2012

I've always found the .LANG to be silly and not able to listen to you even though everything is correct. I checked the "AddUseItemCallback" And the last one is a bool. (True/false) for auto destroying the item when used. I guess that means it's removed after it's been used or breaks up like the crowbar does. So having another script to remove the key when you've put this to true could confuse the engine. Or it has nothing to do with it at all..I've not really tested locked doors myself yet. (Yeah I know stupid, huh ?)



And I believe you must have:
void OnStart()
{
}

I think.. Blush


RE: Amnesia Level Editor Key Script Not Working - youngblood128 - 08-09-2012

Thanks for the replies guys and I did perform some edits based on the ideas you guys had but still no result when I pick up the key it just says "picked up" I'm going to create another locked door in another map with another key and see how that goes, I'll post my results any more suggestions I would love to hear them thanks again.


RE: Amnesia Level Editor Key Script Not Working - Melvin - 08-09-2012

(08-09-2012, 09:26 AM)Seragath Wrote: I've always found the .LANG to be silly and not able to listen to you even though everything is correct. I checked the "AddUseItemCallback" And the last one is a bool. (True/false) for auto destroying the item when used. I guess that means it's removed after it's been used or breaks up like the crowbar does. So having another script to remove the key when you've put this to true could confuse the engine. Or it has nothing to do with it at all..I've not really tested locked doors myself yet. (Yeah I know stupid, huh ?)



And I believe you must have:
void OnStart()
{
}

I think.. Blush
OnStart means something will happen when the player first enters the map
OnEnter mean something will happen when the player enters the map (so, everytime)

(08-08-2012, 11:28 PM)youngblood128 Wrote: Hey I was really looking for some help on my script, I used a layout to make it so that a key works on a certain door I've seen tutorials and tried it using that layout but it didn't work i revised it and fixed some errors but it still doesn't work(in depth explanation at bottom)and I also tried typing it from scratch and looking at various videos and searching the forums I am still stuck here is my coding.
extra_english.lang file:



You awake in your room to discover that some form of darkness followed you one night you had a case of amnesia and connot remember the horrors of that night whatever it is...it wants you, it is your job to discover his secret and stop the darkness.


Main Hall Key
Opens Main Hall Door.


Danger!
Brother! Are you ok I hope you are we heard noises outside and when we went to investigate you were lying on the the floor screaming "man and chain" we took you upstairs to your room so that you could rest about 30 minutes later a death was reported people said they were being attacked by a man covered in chains you know something about this...everybody is dying!...I want you to be save I'm going to barracade the door to protect you I'm going out I want to help the people who I hear with distant screams don't worry about me just be safe and stop whatever this is!
Escape!
Trapped in this room monster outside he seems to be blocking everyone from leaving I had a plan but its too late due to over growth of bushes, trees and plants half of the castle is covered in plants so we boarded up the windows weeks ago to prevent plants from coming into the castle; with some kind of dagger and a crowbar you might be able to escape I had a crowbar but I dropped it in the prison...I hear him! Good luck to whom ever reads this...you'll need it.


my maps.hps file

void OnEnter()
{
AddUseItemCallback("", "Key_1", "Main1", "UsedKeyOnDoor", true);
}


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


void OnLeave()
{

}
--------------------------------
That's the coding I just started, with my key name is key_1 and its sub name is key1 and the door is called
Main1 what happens is that when I pick up the key it says "picked up" but it has no name and no description and it doesn't unlock the door and help would be great thanks.






///////////////////////////// try this

</LANGUAGE>


<CATEGORY Name ="Inventory">
<Entry Name="ItemName_Key_1">YourKeyName</Entry>
<Entry Name="ItemDesc_Key_1">"YourKeyDescription"</Entry>
</CATEGORY>

</LANGUAGE>


If this doesn't work, try to run the leveleditor as admin and edit it.
Also, make sure you save the lang and the script.


RE: Amnesia Level Editor Key Script Not Working - youngblood128 - 08-13-2012

I've been busting my head open trying to get this to work but I still have no result I've tried to re-write the code in different ways I found but I still get no result I've tried it on a different map yet no change hm.....so I'm here to ask if anyone knows how to use a crowbar to open a door instead of a key if anyone wants to check out my map and the coding and see if they can give it a shot that would be beyond awesome thanks again please reply soon.


RE: Amnesia Level Editor Key Script Not Working - GrAVit - 08-14-2012

You need to name the key in the level editor as Key_1 and you also have to add a CustomSubItemTypeName in the Entity options of the key. You need that so the .lang file will pick it up and it will have a name and description ingame. In this case it should be Key_1 aswell.


RE: Amnesia Level Editor Key Script Not Working - youngblood128 - 01-30-2013

Hey guys its been a while and just so you know I've become an incredible good script-er in my opinion of course and I am 2 months into a custom story, thanks for all your help guys if you guys are interested in my story please post replies or if you need help with scripting I have become really good.(My Dream)


RE: Amnesia Level Editor Key Script Not Working - Wolfpa - 08-03-2013

(08-09-2012, 03:22 PM)youngblood128 Wrote: Thanks for the replies guys and I did perform some edits based on the ideas you guys had but still no result when I pick up the key it just says "picked up" I'm going to create another locked door in another map with another key and see how that goes, I'll post my results any more suggestions I would love to hear them thanks again.

I saw your problem and I know how to help!

Go the LANG. file and write this: (Just replace "key" with your key name and name and desc!)

<CATEGORY Name="Inventory">
<Entry Name="ItemDesc_key">It's a key for a cellar door</Entry>
<Entry Name="ItemName_key">Cellar Key</Entry>
</CATEGORY>


RE: Amnesia Level Editor Key Script Not Working - PutraenusAlivius - 08-03-2013

(08-03-2013, 09:38 AM)Wolfpa Wrote:
(08-09-2012, 03:22 PM)youngblood128 Wrote: Thanks for the replies guys and I did perform some edits based on the ideas you guys had but still no result when I pick up the key it just says "picked up" I'm going to create another locked door in another map with another key and see how that goes, I'll post my results any more suggestions I would love to hear them thanks again.

I saw your problem and I know how to help!

Go the LANG. file and write this: (Just replace "key" with your key name and name and desc!)

<CATEGORY Name="Inventory">
<Entry Name="ItemDesc_key">It's a key for a cellar door</Entry>
<Entry Name="ItemName_key">Cellar Key</Entry>
</CATEGORY>

....Did you see his (or her) latest post before?
[EDIT: Mis-read it. I mean look at GrAVit's post]