Spoiler:
Acs Script won't run. (Changing music)
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!)
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!)
- Hor1zon Str1der
- Posts: 21
- Joined: Sat Aug 21, 2021 9:09 am
- Location: forgotten in space.
Acs Script won't run. (Changing music)
I'm trying to make a crude music shuffler, but when the game starts, the script doesn't run. I've even tried executing it with a line, and nothing. Help please?
Re: Acs Script won't run. (Changing music)
If this is all the code, it's not surprising - Scripts 2 to 4 have no way to be executed, since they need to be activated manually.
I am not sure how this is exactly supposed to work in your case, but i believe this would suffice:
(Untested) This will select one of the files on map start, and after the delay, will choose again. This is probably not the best or cleanest ways, but it should do what you want. 
PS: Avoid using numbered scripts if possible, that is an easy way to break compatibility in surprising ways. Instead, use named scripts.
I am not sure how this is exactly supposed to work in your case, but i believe this would suffice:
Code: Select all
#INCLUDE "Zcommon.acs"
int TrackNum;
script "Music" enter
{
TrackNum = random(1,3);
while (1)
{
if (TrackNum == 1)
{
SetMusic ("VAN1");
Delay(8400);
TrackNum = random(1,3);
}
if (TrackNum == 2)
{
SetMusic ("VAN2");
Delay(8400);
TrackNum = random(1,3);
}
if (TrackNum == 3)
{
SetMusic ("VAN3");
Delay(8400);
TrackNum = random(1,3);
}
}
}

PS: Avoid using numbered scripts if possible, that is an easy way to break compatibility in surprising ways. Instead, use named scripts.
- Hor1zon Str1der
- Posts: 21
- Joined: Sat Aug 21, 2021 9:09 am
- Location: forgotten in space.
Re: Acs Script won't run. (Changing music)
That works. Thanks. I feel like I should've know what the problem was.
And I will keep naming scripts in mind.

- MFG38
- Posts: 414
- Joined: Sun Apr 14, 2019 8:26 am
- Graphics Processor: nVidia (Modern GZDoom)
- Location: Finland
- Contact:
Re: Acs Script won't run. (Changing music)
You can truncate your code a tiny bit by shoving all of the if statements into a single switch/case statement, like so:
Code: Select all
#INCLUDE "Zcommon.acs"
int TrackNum;
script "Music" enter
{
TrackNum = random(1,3);
str trackName;
while (1)
{
switch(TrackNum)
{
case 1:
trackName = "VAN1";
break;
case 2:
trackName = "VAN2";
break;
case 3:
trackName = "VAN3";
break;
}
SetMusic(trackName);
Delay(8400);
TrackNum = random(1,3);
}
}
}
- Hor1zon Str1der
- Posts: 21
- Joined: Sat Aug 21, 2021 9:09 am
- Location: forgotten in space.
Re: Acs Script won't run. (Changing music)
MFG38, Is it possible to add individual delays to the cases?
- MFG38
- Posts: 414
- Joined: Sun Apr 14, 2019 8:26 am
- Graphics Processor: nVidia (Modern GZDoom)
- Location: Finland
- Contact:
Re: Acs Script won't run. (Changing music)
It should be to my knowledge.Hor1zon Str1der wrote:MFG38, Is it possible to add individual delays to the cases?