Facebook Twitter YouTube Frictional Games | Forum | Privacy Policy | Dev Blog | Dev Wiki | Support | Gametee


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Scripting help
EvilDeadPunk Offline
Junior Member

Posts: 3
Threads: 1
Joined: Jul 2013
Reputation: 0
#1
Scripting help

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)
(This post was last modified: 07-19-2013, 04:58 PM by EvilDeadPunk.)
07-19-2013, 03:36 AM
Find
Tomato Cat Offline
Senior Member

Posts: 287
Threads: 2
Joined: Sep 2012
Reputation: 20
#2
RE: Scripting help

This is also an issue:

PHP Code: (Select All)
{
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.
07-19-2013, 05:05 AM
Find
EvilDeadPunk Offline
Junior Member

Posts: 3
Threads: 1
Joined: Jul 2013
Reputation: 0
#3
RE: Scripting help

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

PHP Code: (Select All)
{
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.
(This post was last modified: 07-19-2013, 07:46 AM by EvilDeadPunk.)
07-19-2013, 07:42 AM
Find
No Author Offline
Posting Freak

Posts: 962
Threads: 10
Joined: Jun 2012
Reputation: 13
#4
RE: Scripting help

Is this thread is solved already ?

[Image: the-cabin-in-the-woods-masked-people.jpg]
07-19-2013, 10:21 AM
Find
EvilDeadPunk Offline
Junior Member

Posts: 3
Threads: 1
Joined: Jul 2013
Reputation: 0
#5
RE: Scripting help

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

Yes
07-19-2013, 04:57 PM
Find




Users browsing this thread: 1 Guest(s)