This looks like several questions in one!
Script for Unlocking a Door with a Key
void Unlock_Door(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked("castle_01", false, true);
}
void OnEnter()
{
AddUseItemCallback("", "key_study_01", "castle_01", "Unlock_Door", true);
// "" you can leave this blank, it's okay
//"key_study_01" name of key in level editor
// "castle_01" of the thing you're using the item on (key on castle door, for example), replace with your door's name
// "Unlock_Door" name of function to call when key is used on door
// true - destroys key once used, change to false if you want to keep it
}
To change the name of the key when it's picked up
You need a .lang file for this connected to your CS, in it, you should have the following:
<CATEGORY Name="Inventory">
<Entry Name="ItemName_hatchkey">A Key</Entry>
//"ItemName_hatchkey" should be ItemName_ + name of the key model
// A Key is whatever you want the key to show up as in the "picked up ____" message
<Entry Name="ItemDesc_hatchkey">My key's description</Entry>
//ItemDesc_hatchkey should be ItemDesc_ + name of the key model
// My key's description is whatever you want the key's description to say
</CATEGORY>