I have no experience with scripting, but am still curious about how to make a specific sound (let's say, "11_animal_squeal.snt") play once you enter a certain script area. Also, I have a map started, and I want to play the "05_wall_scratch.snt" sound once the lantern is picked up off of a table I have set. Any information on either of these would be greatly appreciated.

//This function is called the first time the map is loaded
void OnStart()
{
//Add a collision callback between the Player and the area called MyArea
AddEntityCollideCallback("Player", "MyArea", "CollideMyArea", true, 1);

//Add a interaction callback for the lantern called lantern_1
SetEntityPlayerInteractCallback("lantern_1", "LanternTaken", true);
}

/**
* This function is called when the Player collides with the area called MyArea,
* because we added a collision callback.
**/
void CollideMyArea(string &in asParent, string &in asChild, int alState)
{
//Play sound at player
PlaySoundAtEntity("", "11_animal_squeal", "Player", 0, false);
}

/**
* This function is called when the Player interacts with the lantern called lantern_1
* because we added an interaction callback.
**/
void LanternTaken(string &in asEntity)
{
//Play sound at player
PlaySoundAtEntity("", "05_wall_scratch", "Player", 0, false);
}

I get a ""FATAL ERROR" and it shows that at (15,1) there is an "unexpected token'{'". The key script works fine as is, I've tested it, but am I doing something obviously wrong with the scripts you gave?
Sorry, I didn't post the code in a box. :/ I'd like to know how to do that as well.

(09-16-2010 08:18 PM)Cgturner Wrote: I get a ""FATAL ERROR" and it shows that at (15,1) there is an "unexpected token'{'". The key script works fine as is, I've tested it, but am I doing something obviously wrong with the scripts you gave?
Sorry, I didn't post the code in a box. :/ I'd like to know how to do that as well.

MulleDK19, I've added the Callbacks, and the map runs smoothly, and the sound after picking up the lantern works perfectly, but the "animal_squeal.snt" sound only plays every few times I run the map. Here's the script, do you see anything that would cause this to happen?

(09-17-2010 01:00 AM)Cgturner Wrote: MulleDK19, I've added the Callbacks, and the map runs smoothly, and the sound after picking up the lantern works perfectly, but the "animal_squeal.snt" sound only plays every few times I run the map.

(09-17-2010 01:00 AM)Cgturner Wrote: MulleDK19, I've added the Callbacks, and the map runs smoothly, and the sound after picking up the lantern works perfectly, but the "animal_squeal.snt" sound only plays every few times I run the map.

That is because 11_animal_squeal.snt has Random set to 0.1

Use this instead: scare_animal_squeal.snt

You, my friend, are a genius. This works flawlessly. I do have one more question at the moment. Would it be possible to edit the 11_animal_squeal.snt file and change the Random to 0.0?

P.S. Thanks for the great advice.
EDIT: I discovered that you CAN edit it so that there is no randomness, but will that cause one sound out of the pool of sounds to be played everytime, or will it just go in order, then loop?

(09-17-2010 01:00 AM)Cgturner Wrote: MulleDK19, I've added the Callbacks, and the map runs smoothly, and the sound after picking up the lantern works perfectly, but the "animal_squeal.snt" sound only plays every few times I run the map.

That is because 11_animal_squeal.snt has Random set to 0.1

Use this instead: scare_animal_squeal.snt

You, my friend, are a genius. This works flawlessly. I do have one more question at the moment. Would it be possible to edit the 11_animal_squeal.snt file and change the Random to 0.0?

P.S. Thanks for the great advice.
EDIT: I discovered that you CAN edit it so that there is no randomness, but will that cause one sound out of the pool of sounds to be played everytime, or will it just go in order, then loop?

Random sounds are always chosen from the pool.

The Random setting is rather "Probability of occurance". 1 means that the sound will always be played when it's triggered using eg. PlaySoundAtEntity, while 0 means it would never be played.

From what I've understood by just looking at the .snt files, at least.

Ah, that makes sense! Sorry for all of the questions, but this is the first scripting I've ever done. Ever. I just made a custom .snt file with all of the squeals together, and the Random at 1.0 so that a sound always plays when you walk over the script area. Thanks for all of the help! If I have any other script-related problems, I hope it's alright to come back to you. You've helped a lot more that anything else.