music does not change
Forum rules
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. This forum is archived - please use this set of forums to ask new questions.
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. This forum is archived - please use this set of forums to ask new questions.
- WARCHILD_89
- Posts: 452
- Joined: Sun Nov 17, 2013 12:27 pm
- Graphics Processor: nVidia with Vulkan support
- Location: MIA between doomed dimensions
music does not change
Hi Guys, merry Christmas !
I`ve got a script with many "IF"s and "ELSE IF"s and it should work properly but for an unknown reason it doesn´t....
The script manages, which music is played, the trigger is a linedef. (e.g. player walks over line, activates script 3 with a number set in the first script argument)
here´s the code:
Script 3 (int selectmusic) //music switching
{
if(selectmusic==0)
{
print(s:"THE DUNGEON");
SetMusic("Sounds/dungeon.lmp",127);
}
else if(selectmusic==1)
{
print(s:"THE SPIDER CAVES");
SetMusic("CAVE.lmp",80);
}
else if(selectmusic==2)
{
SetMusic("AITDsong2128khz.mp3");
}
}
My aim is to make the music change in game without having to write a script for every track, I want to have them all in one script
I`ve got a script with many "IF"s and "ELSE IF"s and it should work properly but for an unknown reason it doesn´t....
The script manages, which music is played, the trigger is a linedef. (e.g. player walks over line, activates script 3 with a number set in the first script argument)
here´s the code:
Script 3 (int selectmusic) //music switching
{
if(selectmusic==0)
{
print(s:"THE DUNGEON");
SetMusic("Sounds/dungeon.lmp",127);
}
else if(selectmusic==1)
{
print(s:"THE SPIDER CAVES");
SetMusic("CAVE.lmp",80);
}
else if(selectmusic==2)
{
SetMusic("AITDsong2128khz.mp3");
}
}
My aim is to make the music change in game without having to write a script for every track, I want to have them all in one script
Re: music does not change
Hi, merry xmas to you as well!
If you are working with a pk3 file, then music name should always be the full path to your music, eg:
This will search for a dungeon.lmp named file in the Sounds folder within your pk3 file.
If you are working with a wad file, then music name should be the corresponding entry in your wad, eg:

If you are working with a pk3 file, then music name should always be the full path to your music, eg:
Code: Select all
SetMusic("Sounds/dungeon.lmp");
If you are working with a wad file, then music name should be the corresponding entry in your wad, eg:
Code: Select all
SetMusic("D_RUNNIN");
- WARCHILD_89
- Posts: 452
- Joined: Sun Nov 17, 2013 12:27 pm
- Graphics Processor: nVidia with Vulkan support
- Location: MIA between doomed dimensions
Re: music does not change
Thank´s for the answer, but:
My problem is not, that the music is not found, all the music stuff works properly, but I want to have ONE music switching script and not to activate an extra script for every single track THIS does not work.
I´m using a PK3 file by the way, and the code is taken from my GZDOOMBUILDER, I have the sounds directory as Resource directory in my editor so I don´t need to give it the whole directory path at the moment.
THIS WORKS:
I walk over a line and activate a script with a given number, it plays the music properly.
Walking over another line, activating another script with a different track does also work. The music changes properly.
The disturbing thing is: every music track has its own script and the ACS gets too many lines to read....
THIS DOES NOT WORK:
I walk over a line (Activate Script 3 with Script argument 1 = 0, "when player walks over"), so the integer "selectmusic" will be set to 1 (example) . Because of that, "Cave.lmp" should be played.
Depending on the first script argument, the script checks the value of the variable "selectmusic" and jumps to the " IF " statement with the right value. So I got every Music track in ONE script (it works as music changer, depending on given value)
The code is taken from the idea Chubzdoomer gave me with his example wad
"three switches activate same script with different results".
I want to do the same effect with music.
I hope my problem is more clear now...
My problem is not, that the music is not found, all the music stuff works properly, but I want to have ONE music switching script and not to activate an extra script for every single track THIS does not work.
I´m using a PK3 file by the way, and the code is taken from my GZDOOMBUILDER, I have the sounds directory as Resource directory in my editor so I don´t need to give it the whole directory path at the moment.
THIS WORKS:
I walk over a line and activate a script with a given number, it plays the music properly.
Walking over another line, activating another script with a different track does also work. The music changes properly.
The disturbing thing is: every music track has its own script and the ACS gets too many lines to read....
THIS DOES NOT WORK:
I walk over a line (Activate Script 3 with Script argument 1 = 0, "when player walks over"), so the integer "selectmusic" will be set to 1 (example) . Because of that, "Cave.lmp" should be played.
Depending on the first script argument, the script checks the value of the variable "selectmusic" and jumps to the " IF " statement with the right value. So I got every Music track in ONE script (it works as music changer, depending on given value)
The code is taken from the idea Chubzdoomer gave me with his example wad
"three switches activate same script with different results".
I want to do the same effect with music.
I hope my problem is more clear now...
Re: music does not change
When you activate the script, is it just the music that fails (indicating a problem with finding/playing the music) or does the "print" command also fail (indicating something wrong with the script or its execution/parameters)?
- WARCHILD_89
- Posts: 452
- Joined: Sun Nov 17, 2013 12:27 pm
- Graphics Processor: nVidia with Vulkan support
- Location: MIA between doomed dimensions
Re: music does not change
At the beginning I had one script per music track and all scripts worked totally fine.
But As soon as I change the whole thing to have ONE script managing ALL the music tracks, there´s absolutely nothing happening...
I don´t even get any message in the console while playing, so I don´t know where the problem is. The ACS is compiled without errors. Music was found until now, so this does not seem to be the problem.
It seems like somehow it does not enter the script at all, although I´ve got the line set to "when Player walks over" or something´s wrong with the value given to the script by the line....
But As soon as I change the whole thing to have ONE script managing ALL the music tracks, there´s absolutely nothing happening...
I don´t even get any message in the console while playing, so I don´t know where the problem is. The ACS is compiled without errors. Music was found until now, so this does not seem to be the problem.
It seems like somehow it does not enter the script at all, although I´ve got the line set to "when Player walks over" or something´s wrong with the value given to the script by the line....
Re: music does not change
When I am trying to figure out why a script doesn't work, I put "print" messages into the script to help me debug it. If you put a "print" instruction before any of the "if" statements, does it get printed? If you use the console command "puke" to run the script, does anything happen? (i.e. puke 3).
How exactly have you set up the line parameters in your editor? (got a screenshot or example map?)
I'm not very familiar with DoomBuilder or UDMF but I think it should look something like this:

How exactly have you set up the line parameters in your editor? (got a screenshot or example map?)
I'm not very familiar with DoomBuilder or UDMF but I think it should look something like this:

- WARCHILD_89
- Posts: 452
- Joined: Sun Nov 17, 2013 12:27 pm
- Graphics Processor: nVidia with Vulkan support
- Location: MIA between doomed dimensions
Re: music does not change
I´m at work at the moment I can´t upload a screenshot sry.
This is exactly how I did it ! You got it right with this screenshot you made.
else if(selectmusic==1)
{
print(s:"THE SPIDER CAVES");
SetMusic("CAVE.lmp",80);
}
this track is being played for example and should print out the message "THE SPIDER CAVES" so the player get´s informed that he gets to a new map area. It is NOT showing up. The music is also not played
This is exactly how I did it ! You got it right with this screenshot you made.
else if(selectmusic==1)
{
print(s:"THE SPIDER CAVES");
SetMusic("CAVE.lmp",80);
}
this track is being played for example and should print out the message "THE SPIDER CAVES" so the player get´s informed that he gets to a new map area. It is NOT showing up. The music is also not played
- WARCHILD_89
- Posts: 452
- Joined: Sun Nov 17, 2013 12:27 pm
- Graphics Processor: nVidia with Vulkan support
- Location: MIA between doomed dimensions
Re: music does not change
going home now, I will upload a screenshot of my ACS code, my map with the line and the window for full clarity.
- WARCHILD_89
- Posts: 452
- Joined: Sun Nov 17, 2013 12:27 pm
- Graphics Processor: nVidia with Vulkan support
- Location: MIA between doomed dimensions
- TheMightyHeracross
- Posts: 2100
- Joined: Sun Aug 18, 2013 9:41 am
- Location: Philadelphia, PA
Re: music does not change
Try checking "front side only"?
- WARCHILD_89
- Posts: 452
- Joined: Sun Nov 17, 2013 12:27 pm
- Graphics Processor: nVidia with Vulkan support
- Location: MIA between doomed dimensions
Re: music does not change
ok dudes thanks for your help, I deleted some things and recoded script 3.
somehow it´s working fine now, but I still don´t understand where the problem was....
somehow it´s working fine now, but I still don´t understand where the problem was....
Re: music does not change
Curious. Oh well, I'm glad it's sorted, even if you don't know why.