Frictional Games Forum (read-only)
{SOLVED} Script Error: Item not Declared - 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: {SOLVED} Script Error: Item not Declared (/thread-17111.html)



{SOLVED} Script Error: Item not Declared - Silent Darkness - 07-19-2012

I've been trying to make a custom map, test my skills a bit, learn a few new things, and maybe make a cool map. I followed a tutorial to create the actual map, and that went fine. However, after setting up the script files, when I try to start the map, I get a script error pointing to lines 12 and 14, saying that the key name is undeclared.

Here is what the script file text reads:


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

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


////////////////////////////
// Run when leaving map

void OnLeave()
{

}

Also, the Extra english Language file reads the following:


<LANGUAGE>
<RESOURCES>
</RESOURCES>
<CATEGORY Name="CustomStoryMain">
<Entry Name="Description">Just a test.</Entry>
</CATEGORY>
<CATEGORY Name="Inventory">
<Entry Name="ItemDesc_Closet_Key">"This should open the closet door......what could possibly be making that noise?"</Entry>
<Entry Name="ItemName_Closet_Key">"Closet Door Key"</Entry>
</CATEGORY>
</LANGUAGE>

I've worked with Javascript before, however, I am unsure how to resolve this, and declare the method. Any suggestions would be helpful.


RE: Script Error: Item not Declared - JenniferOrange - 07-20-2012

void OnStart()
{
}
void OnEnter()
{
AddUseItemCallback("", "Closet_Key", "Closet_door","UsedKeyOnDoor",true);
}

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


////////////////////////////
// Run when leaving map

void OnLeave()
{

}
The .lang is fine, though you've forgotten void OnStart() and putting quotes around the key name. Should work now!


RE: Script Error: Item not Declared - Silent Darkness - 07-20-2012

(07-20-2012, 12:54 AM)JenniferOrange Wrote: void OnStart()
{
}
void OnEnter()
{
AddUseItemCallback("", "Closet_Key", "Closet_door","UsedKeyOnDoor",true);
}

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


////////////////////////////
// Run when leaving map

void OnLeave()
{

}
The .lang is fine, though you've forgotten void OnStart() and putting quotes around the key name. Should work now!
.... Exclamation Exclamation Exclamation I AM AN IDIOT.

Works now.