Frictional Games Forum (read-only)
Scripting 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: Scripting help (/thread-22175.html)



Scripting help - EvilDeadPunk - 07-19-2013

So I'm incredibly new at scripting and I can't help but jump right in - I've been working on the same issue for a few hours now and searched the web to no avail - if anyone can figure out why I'm getting the "Unexpected Token" error, I would be greatly appreciative.

Here is the full script:
////////////////////////////
// Run when the map starts
void OnStart()
{
AddEntityCollideCallback("Player", "PlayerCollide", "MonsterFunction", true, 1);
}

void MonsterFunction(string &in asParent, string &in asChild, int alState)
{
AddEnemyPatrolNode("brute_1", "PathNodeArea_1", 0, "");
AddEnemyPatrolNode("brute_1", "PathNodeArea_5", 0, "");
AddEnemyPatrolNode("brute_1", "PathNodeArea_10", 0, "");
SetEntityActive("brute_1", true);
}

{
AddUseItemCallback("", "cellar_key_1", "cellar_1", "UsedKeyOnDoor", true);
}
void FUNCTION(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked("cellar_1", false, true);
PlaySoundAtEntity("", "unlock_door", "cellar_1", 0, false);
RemoveItem("cellar_key_1");
}


EDIT: I figured out what was wrong...there were some things mixed up everywhere, including in the bit of script that I didn't think was essential or doing anything.

void FUNCTION(string &in asItem, string &in asEntity) was supposed to be 'void UsedKeyOnDoor(string &in asItem, string &in asEntity)


RE: Scripting help - Tomato Cat - 07-19-2013

This is also an issue:

PHP Code:
{
AddUseItemCallback("""cellar_key_1""cellar_1""UsedKeyOnDoor"true);


A callback needs to be declared in another function (onstart, etc) for it to work.

I don't think writing it like above generates a compiler error (provided there are no curly braces), but the AddUseItemCallback function itself won't ever be called.


RE: Scripting help - EvilDeadPunk - 07-19-2013

(07-19-2013, 05:05 AM)Tomato Cat Wrote: This is also an issue:

PHP Code:
{
AddUseItemCallback("""cellar_key_1""cellar_1""UsedKeyOnDoor"true);


A callback needs to be declared in another function (onstart, etc) for it to work.

I don't think writing it like above generates a compiler error (provided there are no curly braces), but the AddUseItemCallback function itself won't ever be called.

It was actually not a part of the coding that I posted, except I was missing a function. The error was being caused by a semi-colon and missing braces in the "OnEnter" section.


RE: Scripting help - No Author - 07-19-2013

Is this thread is solved already ?


RE: Scripting help - EvilDeadPunk - 07-19-2013

(07-19-2013, 10:21 AM)No Author Wrote: Is this thread is solved already ?

Yes