Frictional Games Forum (read-only)
problems with sound script (solved) - 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: problems with sound script (solved) (/thread-15541.html)



problems with sound script (solved) - Nice - 05-20-2012

Hello all i've started with map editing in scripting yesterday so i'm a 100% beginner. Anyway i've manage to add 2 succesfull scripts so far (that work as intended). One that door closes behind me and one for unlocking the door with a key..

Now i decided to make a sound one.. ( If a player steps into area he hears a sound). I've tried messing around a bit with the script but i cant get it to work. Whenever i run my CS the game crashes with a fatal error. Heres my sound script :

{
AddEntityCollideCallback("player", "Music_1", "start", true, 1);
}

void start(string &in asParent, string &in AsChild, int alState)
{
PlaySoundAtEntity("", "amb_idle03.ogg", "Player", 0, false);
}

So can you tell me what i did wrong ? Smile And i know the mistake is probably obvious and i did all horribly wrong but cut me some slack, i've only just begun with map making/scripting yesterday Smile


RE: problems with sound script - SilentStriker - 05-20-2012

void OnStart()
{
AddEntityCollideCallback("Player", "Music_1", "start", true, 1);
}

void start(string &in asParent, string &in asChild, int alState)
{
PlaySoundAtEntity("", "amd_idle03.ogg", "Player", 0, false);
}

So the problem may be that you wrote player, it must be Player in the AddEntityCollideCallback

and usually the error says where in the script the error is


RE: problems with sound script - Nice - 05-20-2012

Done, now the error says * A function with the same name and parameters already exists*

edit: heres the whole error message -- FATAL ERROR: Could not load script file /maps/00_testmap.hps"!main (29,1) : ERR : A function with the same name and parameters already exist


RE: problems with sound script - SilentStriker - 05-20-2012

That means that some where in your script a function or parameter is called the same thing. Can I see your whole script? Smile


RE: problems with sound script - Nice - 05-20-2012

////////////////////////////
// Run first time starting map
void OnStart()
{
AddEntityCollideCallback("Player", "RoomTwoArea", "CollideRoomTwo", true, 1);
}

void CollideRoomTwo(string &in asParent, string &in asChild, int alState)
{
SetSwingDoorClosed("mansion_1", true, true);
}

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

// Run when entering map

void OnEnter()

{
AddUseItemCallback("mansion_1", "awesomekey_1", "mansion_1", "KeyOnDoor", true);
}

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

{
SetSwingDoorLocked("mansion_1", false, true); PlaySoundAtEntity("02_puzzle.ogg", "unlock_door", "mansion_1", 1, false); RemoveItem("awesomekey_1");
}

void OnStart()
{
AddEntityCollideCallback("Player", "Music_1", "start", true, 1);
}

void start(string &in asParent, string &in asChild, int alState)
{
PlaySoundAtEntity("", "amd_idle03.ogg", "Player", 0, false);
}


RE: problems with sound script - SilentStriker - 05-20-2012

Your problem is that you have 2 void OnStart. You can only have 1 void OnStart 1 void OnEnter and 1 OnLeave.

This is how it should look like Smile

PHP Code:
////////////////////////////
// Run first time starting map
void OnStart()
{
AddEntityCollideCallback("Player""RoomTwoArea""CollideRoomTwo"true1);
AddEntityCollideCallback("Player""Music_1""start"true1);
AddUseItemCallback("mansion_1""awesomekey_1""mansion_1""KeyOnDoor"true);
}

void CollideRoomTwo(string &in asParentstring &in asChildint alState)
{
SetSwingDoorClosed("mansion_1"truetrue);
}

void KeyOnDoor(string &in asItemstring &in asEntity)
{
SetSwingDoorLocked("mansion_1"falsetrue); 
PlaySoundAtEntity("02_puzzle.ogg""unlock_door""mansion_1"1false);
RemoveItem("awesomekey_1");
}

void start(string &in asParentstring &in asChildint alState)
{
PlaySoundAtEntity("""amd_idle03.ogg""Player"0false);
}

////////////////////////////
// Run when entering map
void OnEnter()
{



Also OnEnter is for scripts that you want to be called every time the player enters the map. OnStart is the one you will use most since you usually only want scares and other events to happen first time the player enters the map Smile

OnEnter is most used for playing music and preload stuff


RE: problems with sound script - Nice - 05-20-2012

i want to hug you and never let you go!

The error is gone! 1 more question.. Can sounds be .ogg or is .snt a must ? cuz when i enter the area where its supposed to play nothing happens.


RE: problems with sound script - Adny - 05-20-2012

Ogg is the file type, and .snt is a configuration for the sound. You can edit it w/ notepad


RE: problems with sound script - SilentStriker - 05-21-2012

(05-20-2012, 10:05 PM)CowardlyDog Wrote: i want to hug you and never let you go!

The error is gone! 1 more question.. Can sounds be .ogg or is .snt a must ? cuz when i enter the area where its supposed to play nothing happens.
When it comes to sound, PlaySoundAtEntity needs a .snt file to be able to work and PlayMusic is using .ogg files and dont need a.snt to work.

.snt is, as andyrockin said, a file that can be made and configured in a text editor. It's purpose is to give the .ogg file some sound settings like volume and the distance you can hear it etc and .ogg is a filetype Smile