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
Script Help Wake up script
Saren Offline
Member

Posts: 196
Threads: 20
Joined: Jan 2012
Reputation: 1
#21
RE: Wake up script

(05-04-2012, 06:59 PM)Homicide13 Wrote: That's an open bracket. Every '{' needs to have a '}' somewhere to close the block off.

For example, your code
PHP Code: (Select All)
void OnEnter()

{

AddUseItemCallback("""crowbar_1""crowbar_door""UsedCrowbarOnDoor"true);

AddEntityCollideCallback("crowbar_joint_1""ScriptArea_1""CollideAreaBreakDoor"true1);


calls everything between the {} charecters (in this case AddUseItemCallback and AddEntityCollideCallback) whenever the function (OnEnter) is called. The compiler (in this case the game that loads the map file) needs these bracket characters so that it knows what the contents of functions (or some statements such as if then statements or switch statement) are.
Yea ofc, I just mistook them for eachother xD

(This post was last modified: 05-04-2012, 10:18 PM by Saren.)
05-04-2012, 10:17 PM
Find Reply
Homicide13 Offline
Senior Member

Posts: 323
Threads: 41
Joined: Nov 2010
Reputation: 14
#22
RE: Wake up script

But you can't have a closing bracket without an opening bracket either. Smile If you just have a closing bracket by itself it won't know what to do with it.

05-04-2012, 10:20 PM
Find Reply
Saren Offline
Member

Posts: 196
Threads: 20
Joined: Jan 2012
Reputation: 1
#23
RE: Wake up script

(05-04-2012, 10:20 PM)Homicide13 Wrote: But you can't have a closing bracket without an opening bracket either. Smile If you just have a closing bracket by itself it won't know what to do with it.
Can't I just do
{
}
I mean, it does at the start and end so..
Nope... can't do that...

(This post was last modified: 05-04-2012, 10:32 PM by Saren.)
05-04-2012, 10:30 PM
Find Reply
FragdaddyXXL Offline
Member

Posts: 136
Threads: 20
Joined: Apr 2012
Reputation: 7
#24
RE: Wake up script

It's always good practice to close off your brackets, quotes, and parenthesis before doing more coding.

Basically, once you type "{", immediately press enter twice and close it with a "}".

Dark Seclusion Here
05-04-2012, 11:43 PM
Find Reply
Saren Offline
Member

Posts: 196
Threads: 20
Joined: Jan 2012
Reputation: 1
#25
RE: Wake up script

Still nope, Unexected token blablabla.....

05-05-2012, 12:00 AM
Find Reply
Homicide13 Offline
Senior Member

Posts: 323
Threads: 41
Joined: Nov 2010
Reputation: 14
#26
RE: Wake up script

(05-04-2012, 10:30 PM)Saren Wrote: Can't I just do
{
}
I mean, it does at the start and end so..
Nope... can't do that...
You can absolutely do that. If your script still doesn't work, it should give you a line and a char number in the error message. Use that to debug your script. Smile

05-05-2012, 12:35 AM
Find Reply
Saren Offline
Member

Posts: 196
Threads: 20
Joined: Jan 2012
Reputation: 1
#27
RE: Wake up script

(05-05-2012, 12:35 AM)Homicide13 Wrote:
(05-04-2012, 10:30 PM)Saren Wrote: Can't I just do
{
}
I mean, it does at the start and end so..
Nope... can't do that...
You can absolutely do that. If your script still doesn't work, it should give you a line and a char number in the error message. Use that to debug your script. Smile
Okay, if I could do that, it wouldn't say
void wakeUp () {
FadeOut(0); // Instantly fades the screen out. (Good for starting the game)
FadeIn(20); // Amount of seconds the fade in takes
FadeImageTrailTo(2, 2);
FadeSepiaColorTo(100, 4);
SetPlayerActive(false);
FadePlayerRollTo(0, 2, 500); // "Tilts" the players head
FadeRadialBlurTo(0.15, 2);
SetPlayerCrouching(true);
AddTimer("trig1", 15.0f, "beginStory"); // Change '11.0f' to however long you want the 'unconciousness' to last
}

void beginStory(string &in asTimer){
ChangePlayerStateToNormal();
SetPlayerActive(true);
FadePlayerRollTo(65, 20, 20); // Change all settings to defaults
FadeRadialBlurTo(0.0, 1);
FadeSepiaColorTo(0, 4);
SetPlayerCrouching(false);
FadeImageTrailTo(0,1);
}

//Run at the start of the game.
void OnGameStart()
{
}

//Callbacks
{ <-- That 1 was unexpected...
AddEntityCollideCallback("Player", "Spawnmusic", "PlayMusic", true, 1);
AddEntityCollideCallback("Player", "Stopmusic", "StopMusic", true, 1);
AddEntityCollideCallback("Player", "Missingstaff", "Message1", true, 1);
AddEntityCollideCallback("Player", "Guarddogthoughts", "Message2", true, 1);
AddUseItemCallback("", "Masterbedroomkey", "masterbedroomdoor", "UsedKeyOnDoor", true);
AddEntityCollideCallback("Player", "PlayerCollide", "MonsterFunction", true, 1);
AddEntityCollideCallback("Player", "PlayerCollide2", "MonsterFunction2", true, 1);
}

05-05-2012, 12:57 AM
Find Reply
Homicide13 Offline
Senior Member

Posts: 323
Threads: 41
Joined: Nov 2010
Reputation: 14
#28
RE: Wake up script

That's because you just have your brackets in the middle of the global scope of the file - that is, you aren't declaring a function or anything else before them. you just have a comment "//callbacks" and then a block of code, which doesn't make any sense to the game when it tries to compile the script.

The error "unexpected token" means that the compiler encountered something that it didn't expect - in this case a bracket. Yes you do have it closed off correctly, but you forgot to name a function or some other keyword for it, and so all the compiler sees is a bracket floating in the middle of the global scope of the script file (anywhere that isn't inside of function or a data structure). To the compiler, it's just a set of code floating off in space, and it doesn't know what to do with it.

(This post was last modified: 05-05-2012, 01:08 AM by Homicide13.)
05-05-2012, 01:08 AM
Find Reply
Saren Offline
Member

Posts: 196
Threads: 20
Joined: Jan 2012
Reputation: 1
#29
RE: Wake up script

(05-05-2012, 01:08 AM)Homicide13 Wrote: That's because you just have your brackets in the middle of the global scope of the file - that is, you aren't declaring a function or anything else before them. you just have a comment "//callbacks" and then a block of code, which doesn't make any sense to the game when it tries to compile the script.

The error "unexpected token" means that the compiler encountered something that it didn't expect - in this case a bracket. Yes you do have it closed off correctly, but you forgot to name a function or some other keyword for it, and so all the compiler sees is a bracket floating in the middle of the global scope of the script file (anywhere that isn't inside of function or a data structure). To the compiler, it's just a set of code floating off in space, and it doesn't know what to do with it.
O_O........... Owwwwwkaaaaaaay

05-05-2012, 01:09 AM
Find Reply
Cranky Old Man Offline
Posting Freak

Posts: 986
Threads: 20
Joined: Apr 2012
Reputation: 38
#30
RE: Wake up script

Magically working code, with pixie dust and sugar flakes on top:


void OnStart()
{

//Callbacks

AddEntityCollideCallback("Player", "Spawnmusic", "PlayMusic", true, 1);
AddEntityCollideCallback("Player", "Stopmusic", "StopMusic", true, 1);
AddEntityCollideCallback("Player", "Missingstaff", "Message1", true, 1);
AddEntityCollideCallback("Player", "Guarddogthoughts", "Message2", true, 1);
AddUseItemCallback("", "Masterbedroomkey", "masterbedroomdoor", "UsedKeyOnDoor", true);
AddEntityCollideCallback("Player", "PlayerCollide", "MonsterFunction", true, 1);
AddEntityCollideCallback("Player", "PlayerCollide2", "MonsterFunction2", true, 1);
}

Noob scripting tutorial: From Noob to Pro

(This post was last modified: 05-05-2012, 02:03 AM by Cranky Old Man.)
05-05-2012, 02:01 AM
Find Reply




Users browsing this thread: 1 Guest(s)