Frictional Games Forum (read-only)
Script Unlocking Door [HELP] - 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 Unlocking Door [HELP] (/thread-12976.html)



Script Unlocking Door [HELP] - wretic91 - 01-30-2012

Hello,

ok so.. i got the key working with all the names and things... problem is.. i cant unlock the door now.. i will place my .HPS file and .lang file here..maybe you can guys help me out !

HPS FILE
////////////////////////////
// Run when entering map
void OnEnter()
{
AddUseItemCallback("", "Housedoorkey", "housedoor", "UsedKeyOnDoor", true);
}

void MyFunc(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked("housedoor", false, true);
PlaySoundAtEntity("", "unlock_door", "housedoor", 0, false);
RemoveItem(Housedoorkey);
}

////////////////////////////
// Run when leaving map
void OnLeave()
{

}

---------------------------------------------------------

.LANG file

<LANGUAGE>
<CATEGORY Name="CustomStoryMain">
<Entry Name="Description"> A young adult searching for his missing dad ENJOY!!</Entry>
</CATEGORY>
<CATEGORY Name ="Inventory">
<Entry Name="ItemDesc_Housedoorkey">"Our main key of our House"</Entry>
<Entry Name="ItemName_Housedoorkey">" Main House key"</Entry>

</CATEGORY>

</LANGUAGE>

Wretic.



RE: Script Unlocking Door [HELP] - trollox - 01-30-2012

////////////////////////////
// Run when entering map
void OnEnter()
{
AddUseItemCallback("", "Housedoorkey", "housedoor", "UsedKeyOnDoor", true);
}

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

////////////////////////////
// Run when leaving map
void OnLeave()
{
}









That should work.


RE: Script Unlocking Door [HELP] - Unearthlybrutal - 01-30-2012


Try this Smile////////////////////////////
// Run when entering map
void OnEnter()
{
AddUseItemCallback("", "Housedoorkey", "housedoor", "UsedKeyOnDoor", true);
}

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

////////////////////////////
// Run when leaving map
void OnLeave()
{

}


RE: Script Unlocking Door [HELP] - wretic91 - 01-30-2012

it still says Can't Use this item this way! ;[



RE: Script Unlocking Door [HELP] - PerkeleTappaa - 01-30-2012

Tongue im sorry but i dont know anything about scripts sorry!


RE: Script Unlocking Door [HELP] - trollox - 01-30-2012

And you named the key housedoorkey in the level editor aswell in the subitemtypename i think it's called aswell?


RE: Script Unlocking Door [HELP] - wretic91 - 01-30-2012

(01-30-2012, 08:04 PM)trollox Wrote: And you named the key housedoorkey in the level editor aswell in the subitemtypename i think it's called aswell?
yes



RE: Script Unlocking Door [HELP] - Your Computer - 01-30-2012

Never suggest to manually type the name of the door and item for the UsedKeyOnDoor function. That's bad programming. One of the reasons for the existence of functions is to not repeat yourself.

A proper function definition would be:
PHP Code:
void UsedKeyOnDoor(string &in asItemstring &in asEntity)
{
    
SetSwingDoorLocked(asEntityfalsetrue);
    
PlaySoundAtEntity("""unlock_door"asEntity0false);
    
RemoveItem(asItem); // though this is unnecessary given the current use of AddUseItemCallback




RE: Script Unlocking Door [HELP] - trollox - 01-30-2012

(01-30-2012, 08:16 PM)wretic91 Wrote:
(01-30-2012, 08:04 PM)trollox Wrote: And you named the key housedoorkey in the level editor aswell in the subitemtypename i think it's called aswell?
yes
Then i have no ideas mate :/ i'm sort of new to scripting aswell try asking flamez3 he's a pro on scripts.