Facebook Twitter YouTube Frictional Games | Forum | Newsletter | Dev Blog | Dev Wiki | Support | Shelf | Store

Privacy Policy


Post Reply 
 
Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Script Help Unexpected Token "{"
Author Message
BadCoverMan Offline
Junior Member

Posts: 27
Joined: Feb 2012
Reputation: 0
Post: #1
Unexpected Token "{"
I've looked up and down this thing a lot, but I can't find the problem. I'm new to scripting.
Any help would be much appreciated! Blush

Spoiler below!

Void Intro(string &in asTimer)
{
if(asTimer == "FadeIn_1")
{
FadeIn(3);
}
if(asTimer == "Music_1")
{
PlayMusic("09_amb_safe.ogg", true, 1.00, 1, 5, true);
}
if(asTimer == "Stop_1")
{
StopMusic(2, 5);
}
}

void OnStart()
{
FadeOut(0);
AddTimer("FadeIn_1", 1, "Intro");
AddTimer("Music_1", 4, "Intro");
AddTimer("Stop_1", 64, "Intro");
}

{
AddEntityCollideCallback("Player", "StudyArea", "CollideStudy", true, 1);
}

void CollideStudy(string &in asParent, string &in asChild, int alState)
{
SetSwingDoorClosed("LockedDoor_1", true, true);
PlaySoundAtEntity("DoorClose_1", "10_close_door.snt", "StudyArea", 2, false);
}

////////////////////////////
// Run when entering map
void OnEnter()
{
AddUseItemCallback("", "LockedDoorKey_1", "LockedDoor_1", "UsedLockedDoorKey_1", true);
}

void UsedLockedDoorKey_1(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked("LockedDoor_1", false, true);
PlaySoundAtEntity("", "unlock_door", "LockedDoor_1", 0, false);
RemoveItem("LockedDoorKey_1");
}

02-20-2012 09:54 PM
Find all posts by this user Quote this message in a reply
Your Computer Offline
SCAN ME!

Posts: 3,267
Joined: Jul 2011
Reputation: 223
Post: #2
RE: Unexpected Token "{"
Code blocks should only be as part of a function definition or conditional statement, an array or enum declaration, or be a nested code block (and anything else i may have missed). The code block the error is pointing to does not follow those rules. Also, void shouldn't be capitalized.

Tutorials: From Noob to Pro
(This post was last modified: 02-20-2012 10:15 PM by Your Computer.)
02-20-2012 10:14 PM
Visit this user's website Find all posts by this user Quote this message in a reply
BadCoverMan Offline
Junior Member

Posts: 27
Joined: Feb 2012
Reputation: 0
Post: #3
RE: Unexpected Token "{"
(02-20-2012 10:14 PM)Your Computer Wrote:  Code blocks should only be as part of a function definition or conditional statement, an array or enum declaration, or be a nested code block (and anything else i may have missed). The code block the error is pointing to does not follow those rules. Also, void shouldn't be capitalized.
Ok so, I apologize if this seems annoying or naive, but... what?
02-21-2012 01:08 AM
Find all posts by this user Quote this message in a reply
Juby Away
Senior Member

Posts: 285
Joined: May 2011
Reputation: 5
Post: #4
RE: Unexpected Token "{"
(02-21-2012 01:08 AM)BadCoverMan Wrote:  Ok so, I apologize if this seems annoying or naive, but... what?
Well, basically you capitalized "void" in the very first function and you put a "AddEntityCollideCallback" in a no-good spot.

Spoiler below!


void Intro(string &in asTimer)
{
if(asTimer == "FadeIn_1") FadeIn(3);

if(asTimer == "Music_1") PlayMusic("09_amb_safe.ogg", true, 1.00f, 1, 5, true);

if(asTimer == "Stop_1") StopMusic(2, 5);
}

void OnStart()
{
AddEntityCollideCallback("Player", "StudyArea", "CollideStudy", true, 1);
FadeOut(0);
AddTimer("FadeIn_1", 1, "Intro");
AddTimer("Music_1", 4, "Intro");
AddTimer("Stop_1", 64, "Intro");
}

void CollideStudy(string &in asParent, string &in asChild, int alState)
{
SetSwingDoorClosed("LockedDoor_1", true, true);
PlaySoundAtEntity("DoorClose_1", "10_close_door.snt", "StudyArea", 2, false);
}

void OnEnter()
{
AddUseItemCallback("", "LockedDoorKey_1", "LockedDoor_1", "UsedLockedDoorKey_1", true);
}

void UsedLockedDoorKey_1(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked("LockedDoor_1", false, true);
PlaySoundAtEntity("", "unlock_door", "LockedDoor_1", 0, false);
RemoveItem("LockedDoorKey_1");
}



Forever passing judgement compared to a fraud.
(This post was last modified: 02-21-2012 02:37 AM by Juby.)
02-21-2012 02:35 AM
Find all posts by this user Quote this message in a reply
BadCoverMan Offline
Junior Member

Posts: 27
Joined: Feb 2012
Reputation: 0
Post: #5
RE: Unexpected Token "{"
(02-21-2012 02:35 AM)Juby Wrote:  Well, basically you capitalized "void" in the very first function and you put a "AddEntityCollideCallback" in a no-good spot.

Spoiler below!


void Intro(string &in asTimer)
{
if(asTimer == "FadeIn_1") FadeIn(3);

if(asTimer == "Music_1") PlayMusic("09_amb_safe.ogg", true, 1.00f, 1, 5, true);

if(asTimer == "Stop_1") StopMusic(2, 5);
}

void OnStart()
{
AddEntityCollideCallback("Player", "StudyArea", "CollideStudy", true, 1);
FadeOut(0);
AddTimer("FadeIn_1", 1, "Intro");
AddTimer("Music_1", 4, "Intro");
AddTimer("Stop_1", 64, "Intro");
}

void CollideStudy(string &in asParent, string &in asChild, int alState)
{
SetSwingDoorClosed("LockedDoor_1", true, true);
PlaySoundAtEntity("DoorClose_1", "10_close_door.snt", "StudyArea", 2, false);
}

void OnEnter()
{
AddUseItemCallback("", "LockedDoorKey_1", "LockedDoor_1", "UsedLockedDoorKey_1", true);
}

void UsedLockedDoorKey_1(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked("LockedDoor_1", false, true);
PlaySoundAtEntity("", "unlock_door", "LockedDoor_1", 0, false);
RemoveItem("LockedDoorKey_1");
}


Thank you very much, I really appreciate it. It's working now.
02-21-2012 02:44 AM
Find all posts by this user Quote this message in a reply
Post Reply 




User(s) browsing this thread: 1 Guest(s)