Can I randomize the title music with SNDINFO?

Ask about ACS, DECORATE, ZScript, or any other scripting questions here!

Moderator: GZDoom Developers

Forum rules
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. If you still don't understand how to use a feature, then ask here.

Please bear in mind that the people helping you do not automatically know how much you know. You may be asked to upload your project file to look at. Don't be afraid to ask questions about what things mean, but also please be patient with the people trying to help you. (And helpers, please be patient with the person you're trying to help!)
Post Reply
User avatar
SiFi270
Posts: 451
Joined: Tue Feb 10, 2015 2:51 am
Location: Does anyone put a serious answer here?

Can I randomize the title music with SNDINFO?

Post by SiFi270 »

I'm working on a mapinfo patch for the Serenity trilogy that can be loaded with all three wads and their music addons, but each one uses its own track for D_INTRO, D_INTER and D_VICTOR. After copying the relevant music files into the patch and replacing the D at the start of each with the first letter of the wad it's meant for, the intermission and victory music are easily handled with mapinfo, and for the title music I thought I'd use $musicalias and $random to play either Eternity's or Infinity's (since Serenity's is just the same as Doom's) but it doesn't seem to be that simple. Is there a workaround I can use to get the result I want?
ZzZombo
Posts: 315
Joined: Mon Jul 16, 2012 2:02 am

Re: Can I randomize the title music with SNDINFO?

Post by ZzZombo »

I remember back then trying to do the same only to find out that music can't be randomized. Maybe things have changed, but unlikely.
User avatar
Apeirogon
Posts: 1605
Joined: Mon Jun 12, 2017 12:57 am

Re: Can I randomize the title music with SNDINFO?

Post by Apeirogon »

I know how do so using acs

Code: Select all

#include "zcommon.acs"

str songs_name[amount of songs] = { "song name 1", "song name 2", "song name 3", .....};
int pick_what_song_play;
        
script jukebox open
{
pick_what_song_play= random(0, amount of songs - 1);
SetMusic(songs_name[pick_what_song_play]);
}
User avatar
Gato303
Posts: 36
Joined: Wed Mar 30, 2016 6:14 pm
Location: Colombia
Contact:

Re: Can I randomize the title music with SNDINFO?

Post by Gato303 »

Apeirogon wrote:I know how do so using acs

Code: Select all

#include "zcommon.acs"

str songs_name[amount of songs] = { "song name 1", "song name 2", "song name 3", .....};
int pick_what_song_play;
        
script jukebox open
{
pick_what_song_play= random(0, amount of songs - 1);
SetMusic(songs_name[pick_what_song_play]);
}
That's cool, thanks for the script help.
Tho... how do you set the script to be executed when the Title Screen shows up?
User avatar
Gato303
Posts: 36
Joined: Wed Mar 30, 2016 6:14 pm
Location: Colombia
Contact:

Re: Can I randomize the title music with SNDINFO?

Post by Gato303 »

Thanks! Had a bit of tough time creating a simple map on Slade3 cause of my inexperience and creating a WAD file containing the Titlemap inside the PK3. But finally I could figure it out and it's working, thanks :) :D
Post Reply

Return to “Scripting”