Frictional Games Forum (read-only)
[SCRIPT] Wake up script - 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: [SCRIPT] Wake up script (/thread-15188.html)

Pages: 1 2 3 4 5 6 7 8


RE: Wake up script - Saren - 05-04-2012

(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:
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


RE: Wake up script - Homicide13 - 05-04-2012

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.


RE: Wake up script - Saren - 05-04-2012

(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...


RE: Wake up script - FragdaddyXXL - 05-04-2012

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 "}".


RE: Wake up script - Saren - 05-05-2012

Still nope, Unexected token blablabla.....


RE: Wake up script - Homicide13 - 05-05-2012

(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


RE: Wake up script - Saren - 05-05-2012

(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);
}


RE: Wake up script - Homicide13 - 05-05-2012

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.


RE: Wake up script - Saren - 05-05-2012

(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


RE: Wake up script - Cranky Old Man - 05-05-2012

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


Code:
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);
}