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
Need help with scripting!
Zaapeer Offline
Junior Member

Posts: 32
Threads: 9
Joined: Dec 2011
Reputation: 0
#1
Need help with scripting!

So I'm making my map in amnesia level editor, everything's just fine. But then I wanna start my scripting. So I add a function, and it's works perfectly fine, but when I try to add a new function there's an error when I start up my custom story! D: I dunno what the problem is D:
Here's the error message:

[Image: amnesiaerror.png]

Uploaded with ImageShack.us

Here's my script:

void OnStart()

{
AddEntityCollideCallback("Player", "door_slamHousekeeper", "func_slam", true, 1);
}

void func_slam(string &in asParent, string &in asChild, int alState)
{
SetSwingDoorClosed("HousekeeperDoor", true, false);
PlaySoundAtEntity("DoorSlamSound", "scare_slam_door.snt", "Player", 0, false);
PlaySoundAtEntity("", "react_pant.snt", "Player", 0, false);
PlaySoundAtEntity("", "react_scare.snt", "Player", 0, false);
GiveSanityDamage(5.0f, true);
}

{
AddEntityCollideCallback("Player", "NoOil", "Collide_Area", true, 1);
}

void Collide_Area(string &in asParent, string &in asChild, int alState)
{
SetPlayerLampOil(0.0f);
}

{
AddUseItemCallback("", "FirstRoomKey_1", "BedroomDoorFirst_1", "unlock_door", true);
}

void unlock_door(string &in FirstRoomKey_1, string &in BedroomDoorFirst_1)
{
SetSwingDoorLocked(BedroomDoorFirst_1, false, true);
PlaySoundAtEntity("", "unlock_door", BedroomDoorFirst_1, 0, false);
RemoveItem(FirstRoomKey_1);
}

void OnEnter()
{


}

void OnLeave()
{

}

Please help me!
12-27-2011, 07:56 PM
Find
Your Computer Offline
SCAN ME!

Posts: 3,456
Threads: 32
Joined: Jul 2011
Reputation: 235
#2
RE: Need help with scripting!

It's telling you have you two dangling code blocks. Were they supposed to be functions, or are you new to scripting in general?

Tutorials: From Noob to Pro
12-27-2011, 09:25 PM
Website Find
Zaapeer Offline
Junior Member

Posts: 32
Threads: 9
Joined: Dec 2011
Reputation: 0
#3
RE: Need help with scripting!

Well I am new to scripting Tongue
12-28-2011, 09:53 AM
Find
ferryadams10 Offline
Senior Member

Posts: 288
Threads: 40
Joined: Apr 2011
Reputation: 19
#4
RE: Need help with scripting!

these once aren't announced with a special function.

When should they use them.

Most likely it'll have to be connected with AddEntityCollideCallback or AddUseItemCallback but now the game doesn't know WHEN to use those things so I think you'll have to place those two scripts (without the brackets "{}") into void OnStart()



PHP Code: (Select All)

AddEntityCollideCallback("Player""NoOil""Collide_Area"true1);
}

{
AddEntityCollideCallback("Player""NoOil""Collide_Area"true1);



Got a nice sofa
Please come and have a seat for a while

(This post was last modified: 12-28-2011, 10:08 AM by ferryadams10.)
12-28-2011, 10:07 AM
Find
Zaapeer Offline
Junior Member

Posts: 32
Threads: 9
Joined: Dec 2011
Reputation: 0
#5
RE: Need help with scripting!

Okay so I looked a little more at the error, and it says unexpected token. So I removed the unexpected token (wich was the: { ) and start up my map again. But then I get an error saying that the ending bracket is an unexpected token too. And it also says that it expected an identifier AddEntityCollideCallback--->here<---("Player", "door_slamHousekeeper", "func_slam", true, 1); D:
12-28-2011, 11:42 AM
Find
Tripication Offline
Member

Posts: 172
Threads: 19
Joined: Dec 2011
Reputation: 6
#6
RE: Need help with scripting!

Im just skimming ur script, and im not really concentrating on what your problem is, but try this

GiveSanityDamage(5, true); rather than GiveSanityDamage(5.0f, true);

same with the oil, remove the .0f

[Image: speedart__2___yoshimitsu_by_kamofudge-d4yo6kk.png]
(This post was last modified: 12-28-2011, 11:48 AM by Tripication.)
12-28-2011, 11:47 AM
Find
Zaapeer Offline
Junior Member

Posts: 32
Threads: 9
Joined: Dec 2011
Reputation: 0
#7
RE: Need help with scripting!

(12-28-2011, 11:47 AM)Tripication Wrote: Im just skimming ur script, and im not really concentrating on what your problem is, but try this

GiveSanityDamage(5, true); rather than GiveSanityDamage(5.0f, true);

same with the oil, remove the .0f
yeah I tried that too...
12-28-2011, 12:07 PM
Find
flamez3 Offline
Posting Freak

Posts: 1,281
Threads: 48
Joined: Apr 2011
Reputation: 57
#8
RE: Need help with scripting!

(12-28-2011, 11:42 AM)Zaapeer Wrote: Okay so I looked a little more at the error, and it says unexpected token. So I removed the unexpected token (wich was the: { ) and start up my map again. But then I get an error saying that the ending bracket is an unexpected token too. And it also says that it expected an identifier AddEntityCollideCallback--->here<---("Player", "door_slamHousekeeper", "func_slam", true, 1); D:


The message doesn't specify where the error is. It tells you what block it is in. If it says (for e.g) main (45,5), it doesn't directly mean there is something wrong with that line and character. It means in the entire block; something's wrong. Post your script again and I'll see if I can help.

12-28-2011, 02:31 PM
Find
ferryadams10 Offline
Senior Member

Posts: 288
Threads: 40
Joined: Apr 2011
Reputation: 19
#9
RE: Need help with scripting!

Add me and I'll help you with all your problems xD

Much easier.

Skype: ferryadams10

Steam: ferryadams10

Msn: ferry_hooligan@live.nl

Got a nice sofa
Please come and have a seat for a while

12-28-2011, 02:47 PM
Find
SilentStriker Offline
Posting Freak

Posts: 950
Threads: 26
Joined: Jul 2011
Reputation: 43
#10
RE: Need help with scripting!

Have you got it to work? Smile becuse i think i know what the problem is Smile

If im not mistaken it should look like this:
(12-27-2011, 07:56 PM)Zaapeer Wrote: void OnStart()

{
AddEntityCollideCallback("Player", "door_slamHousekeeper", "func_slam", true, 1);
AddUseItemCallback("", "FirstRoomKey_1", "BedroomDoorFirst_1", "unlock_door", true);
AddEntityCollideCallback("Player", "NoOil", "Collide_Area", true, 1);

}

void func_slam(string &in asParent, string &in asChild, int alState)
{
SetSwingDoorClosed("HousekeeperDoor", true, false);
PlaySoundAtEntity("DoorSlamSound", "scare_slam_door.snt", "Player", 0, false);
PlaySoundAtEntity("", "react_pant.snt", "Player", 0, false);
PlaySoundAtEntity("", "react_scare.snt", "Player", 0, false);
GiveSanityDamage(5.0f, true);
}

void Collide_Area(string &in asParent, string &in asChild, int alState)
{
SetPlayerLampOil(0.0f);
}

void unlock_door(string &in FirstRoomKey_1, string &in BedroomDoorFirst_1)
{
SetSwingDoorLocked(BedroomDoorFirst_1, false, true);
PlaySoundAtEntity("", "unlock_door", BedroomDoorFirst_1, 0, false);
RemoveItem(FirstRoomKey_1);
}

void OnEnter()
{


}

void OnLeave()
{

}
the bolded ones is the ones I moved Smile You need to have them in either void onstart, void onenter or void onleave


Correct me if i'm mistaken Smile

12-28-2011, 02:53 PM
Find




Users browsing this thread: 4 Guest(s)