Frictional Games Forum (read-only)
More scripting errors. Please 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: More scripting errors. Please help! (/thread-14040.html)



More scripting errors. Please help! - EthanLancaster - 03-16-2012

This scripting has been giving me alot of trouble. Im trying to get a key to unlock a door. Can someone please show me whats wrong with it?

void OnStart ()
{
AddUseItemCallback("", "LibraryKey", "mansion_2", "KeyOnDoor", true);
AddEntityCollideCallback("Player", "StartPoint_Quest", "GetStartPoint", true, 1);
AddEntityCollideCallback("Player", "StartPoint_Quest", "FinishStartPoint", true, 1);
}
void KeyOnDoor(string &in asEntity)
{
SetSwingDoorLocked("mansion_2", false, true);
PlaySoundAtEntity("", "unlock_door", "mansion_2", 1, false);
RemoveItem("LibraryKey");
GiveSanityBoostSmall();
}

void GetStartPoint(string &in asParent, string &in asChild, int alState)
{
AddQuest("investigate","Investigate");
PlayGuiSound("react_breath_slow", 0.5f);
}

void FinishStartPoint(string &in asParent, string &in asChild, int alState)
{
CompleteQuest("investigate","Investigate") ;
GiveSanityBoostSmall();
}






RE: More scripting errors. Please help! - palistov - 03-16-2012

Callback functions for item use on an entity require two parameters. Your function KeyOnDoor will need a second parameter. The first is the item reference (which item was used by the player), while the second is the entity reference (the entity the item was used on). Change your parameters -- the statements in the parenthesis directly following your function name (in this case, it is KeyOnDoor) -- to reflect this.