Frictional Games Forum (read-only)
Scripting multiple levels help - 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 (https://www.frictionalgames.com/forum/forum-35.html)
+--- Thread: Scripting multiple levels help (/thread-5996.html)



Scripting multiple levels help - Equil - 01-01-2011

I couldn't find any other threads about this so the solution to this problem is probably painfully obvious. I already have two maps with working level doors working fine, I can move through both the levels without problems.

However, I want the music to change between the two levels, so I made a script for each map. Here is what I have:

Map 1:
Code:
////////////////////////////
// Run when entering map
void OnEnter()
{
  PlayMusic("12_amb.ogg", true, 1.0f, 0, 0, true);
}

////////////////////////////
// Run when leaving map
void OnLeave()
{
StopMusic(5.0, 0);
}

Map 2:
Code:
////////////////////////////
// Run when entering map
void OnEnter()
{

PlayMusic("08_amb.ogg", true, 1.0f, 3, 0, true);

}

////////////////////////////
// Run when leaving map
void OnLeave()
{
StopMusic(5.0, 0);
}

Once I enter Map2, the music stops, but the new music doesn't play. It DOES play if I re-enter Map1, so I tried using different music files and double checking the code, but it seems to be correct. Any help with this is much appreciated.


RE: Scripting multiple levels help - xiphirx - 01-01-2011

You might want to stop the first music, then play the second.


RE: Scripting multiple levels help - Equil - 01-01-2011

I do have the function StopMusic(5.0, 0); in the OnLeave() section of the first map, which works. The problem is the music not starting on the second map. Do I have the function in the wrong place?


RE: Scripting multiple levels help - xiphirx - 01-01-2011

Code:
PlayMusic("08_amb.ogg", true, 1.0f, 3, 0, true);
void  PlayMusic(string& asMusicFile, bool abLoop, float afVolume, float afFadeTime, int alPrio, bool abResume);

You indicated fadeTime in this one... Try removing the fade time.


RE: Scripting multiple levels help - Equil - 01-01-2011

Quote:Code:
PlayMusic("08_amb.ogg", true, 1.0f, 3, 0, true);
void PlayMusic(string& asMusicFile, bool abLoop, float afVolume, float afFadeTime, int alPrio, bool abResume);

You indicated fadeTime in this one... Try removing the fade time.

I tried what you said.. no luck. So I tried messing around with it, I loaded the map directly, still no music. However, a debug message does appear saying:

Saving check point_auto music: "

Maybe there's something wrong with my script? This is the entire I script I have for Map 2:
Code:
////////////////////////////
// Run first time starting map
void OnStart()
{  

}

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

PlayMusic("08_amb.ogg", true, 1.0f, 0, 0, true);

}

////////////////////////////
// Run when leaving map
void OnLeave()
{
StopMusic(5.0, 0);
}



RE: Scripting multiple levels help - xiphirx - 01-01-2011

I'm sorry, I haven't started scripting yet so I couldn't tell you...

Does it work when you put it in onStart?


RE: Scripting multiple levels help - Equil - 01-01-2011

Nope.. still nothing. Can anyone script savvy come in here and help?


RE: Scripting multiple levels help - ModManDann - 01-01-2011

In my knowledge the last played music automatically stops if you start a new one. Try removing the stop music function

Edit:

or try
Code:
StopMusic(5.0, 10);



RE: Scripting multiple levels help - Equil - 01-01-2011

*headdesk* .. I'm really sorry for troubling you guys, turned out to be a small typo problem in my .hps file. It had a ".map" at the end of it's name, working fine now after I removed it. How embarrassing. Blush

Sorry for the trouble, appreciate the all the help anyway, thanks. Smile


RE: Scripting multiple levels help - Frontcannon - 01-01-2011

That's where AddDebugMessage helps you.. you'd have known that your script file didn't work!