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


Thread Rating:
  • 1 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Spoiler Some Script-Problems
BlueRsX Offline
Junior Member

Posts: 5
Threads: 1
Joined: Feb 2013
Reputation: 0
#1
Sad  Some Script-Problems

Hey Guys!
Im working on a custom story in Amnesia.
So I've watched tutorials and guides, on the wiki too.
So... For my map I need some scripts and functions. And I dont find it so easy to write them, so I've copied the "Door-Smash"-Code from the Wiki. Thanks for it!

So heres my question: I have a code. How can I write 2 codes one after another? I tried just to seperate them with a } one after another,
but I got every time an error like "ERROR" "Unexpected end of file" or something. I will post the code here for you:
Quote:////////////////////////////
// Run first time starting map
void OnStart()
{
AddEntityCollideCallback("Player", "script_slam", "func_slam", true, 1);
}

void func_slam(string &in asParent, string &in asChild, int alState)
{
SetSwingDoorClosed("door2", true, true);

PlaySoundAtEntity("", "react_breath_slow.snt", "Player", 0, false);

PlaySoundAtEntity("", "react_scare", "Player", 0, false); PlaySoundAtEntity("", "close_door.snt", "Player", 0, false);

GiveSanityDamage(5.0f, true);
}
(HERES THE 2ND CODE v v v v v v v)
{
SetEntityPlayerInteractCallback("door1", "func_slam", true);
}


void func_slam(string &in asParent, string &in asChild, int alState)
{
SetPropHealth("door1", 0.0f);


PlaySoundAtEntity("", "react_breath_slow.snt", "Player", 0, false);


PlaySoundAtEntity("", "react_scare", "Player", 0, false);


PlaySoundAtEntity("", "close_door.snt", "Player", 0, false);


GiveSanityDamage(5.0f, true);
}
////////////////////////////
// Run when entering map
void OnEnter()
{

}
////////////////////////////
// Run when leaving map
void OnLeave()
{

}


So heres the error, if i dont put the } between[/quote]:
http://prntscr.com/s3vwb

Can someone tell me what is wrong or how can i save to scripts without an error?

Thank you!

-Blue Smile
02-09-2013, 03:41 PM
Find
NaxEla Offline
Senior Member

Posts: 415
Threads: 5
Joined: Dec 2012
Reputation: 28
#2
RE: Some Script-Problems

You can also put
SetEntityPlayerInteractCallback("door1", "func_slam", true);
in OnStart.

Your OnStart function will look like this:
PHP Code: (Select All)
void OnStart()
{
    
AddEntityCollideCallback("Player""script_slam""func_slam"true1);
    
SetEntityPlayerInteractCallback("door1""func_slam"true);


In Ruins [WIP]
02-09-2013, 06:02 PM
Find
The chaser Offline
Posting Freak

Posts: 2,486
Threads: 76
Joined: Jun 2012
Reputation: 113
#3
RE: Some Script-Problems

The good script should be like this:

////////////////////////////

// Run first time starting map

void OnStart()

{

AddEntityCollideCallback("Player", "script_slam", "func_slam", true, 1);
SetEntityPlayerInteractCallback("door1", "func_slam_1", true);

}



void func_slam(string &in asParent, string &in asChild, int alState)

{

SetSwingDoorClosed("door2", true, true);



PlaySoundAtEntity("", "react_breath_slow.snt", "Player", 0, false);



PlaySoundAtEntity("", "react_scare", "Player", 0, false);  PlaySoundAtEntity("", "close_door.snt", "Player", 0, false);



GiveSanityDamage(5.0f, true);

}

    





void func_slam_1(string &in asParent, string &in asChild, int alState)

{

SetPropHealth("door1", 0.0f);





PlaySoundAtEntity("", "react_breath_slow.snt", "Player", 0, false);





PlaySoundAtEntity("", "react_scare", "Player", 0, false);





PlaySoundAtEntity("", "close_door.snt", "Player", 0, false);





GiveSanityDamage(5.0f, true);

}

////////////////////////////

// Run when entering map

void OnEnter()

{



}

////////////////////////////

// Run when leaving map

void OnLeave()

{



}

THE OTHERWORLD (WIP)
[Image: k6vbdhu]

Aculy iz dolan.
02-09-2013, 06:59 PM
Find
BlueRsX Offline
Junior Member

Posts: 5
Threads: 1
Joined: Feb 2013
Reputation: 0
#4
RE: Some Script-Problems

@NaxEla
Thank you guys very much! But what was the mistake in my code? What is the connection-Problem beteween both?
(This post was last modified: 02-09-2013, 09:47 PM by BlueRsX.)
02-09-2013, 09:43 PM
Find
palistov Offline
Posting Freak

Posts: 1,208
Threads: 67
Joined: Mar 2011
Reputation: 57
#5
RE: Some Script-Problems

You can't do what you're trying to do. The braces { } enclose blocks of code. That second set of code you're trying to include must be put into a new function.

So if you want to run func_slam and then the "second" piece of code separately, put the second piece into "func_slam2" or some other function of your choice, and run it separately from the other code.

02-09-2013, 10:20 PM
Find
BlueRsX Offline
Junior Member

Posts: 5
Threads: 1
Joined: Feb 2013
Reputation: 0
#6
RE: Some Script-Problems

Okay Thx! And a last question: So I can just separate 2 codes, when I leave spaces between them? Is it so easy?
02-09-2013, 10:27 PM
Find
palistov Offline
Posting Freak

Posts: 1,208
Threads: 67
Joined: Mar 2011
Reputation: 57
#7
RE: Some Script-Problems

Yeah everything in a block of code will run unless you direct it otherwise with other statements, which I won't get into.

Just remember that whatever is between the braces will be run when the function is called.

02-09-2013, 10:41 PM
Find
BlueRsX Offline
Junior Member

Posts: 5
Threads: 1
Joined: Feb 2013
Reputation: 0
#8
RE: Some Script-Problems

Thank you, but I think im the stupidest person on the world Big Grin

So I need a bit help with this code...
I wanna make a closed door, wich I have to open with a key.
void OnStart()

{
AddUseItemCallback("", "Schluessel", "Schluesseltuer", "FUNCTION", true);
}

void FUNCTION(string &in asItem, string &in asEntity)

{
    SetSwingDoorLocked(asEntity, false, true);
    PlaySoundAtEntity("", "unlock_door", asEntity, 0, false);
    RemoveItem(asItem);
    SetSwingDoorClosed("door2", true, true);
    }

So everything works... Thank god!

Then I wanna make this "breakdown" of this door for a scary moment.
Ive got the script and everythings fine.
So I tried to insert that "breakdown" code in the .hps file.

Im not sure how to insert it, because I get every time an error!
I tried it like this:
void OnStart()

{
AddUseItemCallback("", "Schluessel", "Schluesseltuer", "FUNCTION", true);
AddEntityCollideCallback("Player", "script_slam", "func_slam", true, 1);
}

void FUNCTION(string &in asItem, string &in asEntity)

{
    SetSwingDoorLocked(asEntity, false, true);
    PlaySoundAtEntity("", "unlock_door", asEntity, 0, false);
    RemoveItem(asItem);
    SetSwingDoorClosed("door2", true, true);
    }
    
    {
void func_slam(string &in asParent, string &in asChild, int alState)
    PlaySoundAtEntity("", "react_breath_slow.snt", "Player", 0, false);
    PlaySoundAtEntity("", "react_scare", "Player", 0, false);  PlaySoundAtEntity("", "close_door.snt", "Player", 0, false);
    GiveSanityDamage(5.0f, true);

}

But I always got an error. The programm says:
Could not load script blablabla: (20,5):ERR: Unexpected token {

So I just deleted this "{" But another error:
(22,5) expected , or ;
(23,22) expected identifier
(23,81) expected identifier
(24,21) expected identifier
(26,1) unexpected token }


Then I just tried to copy the 2nd code just behind the 1st with and without braces, but it allways errors...

I just cant understand why it cant work!

Help again? I know Im annoying Big Grin
(This post was last modified: 02-09-2013, 11:32 PM by BlueRsX.)
02-09-2013, 11:30 PM
Find
BlueRsX Offline
Junior Member

Posts: 5
Threads: 1
Joined: Feb 2013
Reputation: 0
#9
RE: Some Script-Problems

Ok Ive got everything! Thank you!
02-10-2013, 09:29 AM
Find




Users browsing this thread: 1 Guest(s)