Simple sound scripting issue with 3D floor

Ask about ACS, DECORATE, ZScript, or any other scripting questions here!
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
IgnyteZero
Posts: 64
Joined: Thu Jan 16, 2025 12:17 pm
Operating System Version (Optional): Windows 10

Simple sound scripting issue with 3D floor

Post by IgnyteZero »

So, I am trying to have a standard sound effect when a specific 3D platform (a bridge) is raised, and since it's a 3D platform I need to script that defining it in SNDSEQ and then playing it as part of the script that raises the bridge. The script activates through a button just by the bridge.

I want the sound to loop until it hits the target height, but when trying to define this in SNDSEQ I either get an infinite loop of the sound that never ends, or it doesn't play at all. Also, I am unsure if the sound comes from the button now, or from the 3D sector (which would be preferable ofc). I can't seem to get the solution I seek. I know there's something crucial I am missing here ofc, but if the solution is somewhere in the zdoom wiki I do not seem to be able to find it.

My SNDSEQ definition

Code: Select all

:BridgeR
	playrepeat  plats/pt1_mid
	stopsound	plats/pt1_stop

end
The initial script:

Code: Select all

script 33 (void) {  // bridge raise
	SoundSequence ("BridgeR");
	Floor_RaiseByValue(32,8,120);
	Ceiling_RaiseByValue(32,8,120);

}
Now looking around on google, here and Doomworld I found a solution using PlaySound instead that would do exactly what I wanted, except this new script stil doesn't give me any sound in the sector I want it. I figured it might confuse the tag for the 3D sector and the actual sector, but changing tags around doesn't seem to help at all. I even tried to make it play repeatedly in another unrelated sector, but the PlaySound script doesn't seem to create any sound at all despite my SNDSEQ working with SoundSequence (just never ending it's loop).

Code: Select all

script 34 (void) {  // bridge raise t2
	PlaySound(31,"BridgeR",CHAN_BODY,10.0,true,ATTN_NORM,false);

	Floor_RaiseByValue(32,8,120);
	Ceiling_RaiseByValue(32,8,120);

	TagWait(32);

	StopSound(31,CHAN_BODY);

}

So any help or advice would as usual be highly appreciated.
User avatar
Enjay
 
 
Posts: 27610
Joined: Tue Jul 15, 2003 4:58 pm
Location: Scotland
Contact:

Re: Simple sound scripting issue with 3D floor

Post by Enjay »

OK, these are my guesses at what's going on because I rarely, if ever, play sound sequences vie a script.

Possibly your sound sequence doesn't work. I would suggest testing it using the playsequence console command, but I have never been able to get that to work (it's always silent when I try it). Edit: I have tried with 4.14.3 and now with UZDoom 5.0 WiP. I still can't get it to work in the older version, but it does in the newer one (5.0) You have to type "playsequence Sequencename" at the console, and then close the console, at which point the sequence plays - but only in 5.0, not earlier versions.


It might be worth setting up a simple script that only has the sound sequence in it. e.g. I just tried:

Code: Select all

Script 1 (void)
{
	SoundSequence("DoorOpenNormal");
}
and that worked. However, your scripts are already quite simple.


PlaySound is intended for sounds (from SNDINFO), not sound sequences. So, it probably wont work. I also note that you have used a volume of 10.0. The maximum is 1.0. So, you might have more success with:

Code: Select all

script 34 (void) {  // bridge raise t2
	PlaySound(31,"plats/pt1_mid",CHAN_BODY,1.0,true,ATTN_NORM,false);

	Floor_RaiseByValue(32,8,120);
	Ceiling_RaiseByValue(32,8,120);

	TagWait(32);

	StopSound(31,CHAN_BODY);

	PlaySound(31,"plats/pt1_stop",CHAN_BODY,1.0,false,ATTN_NORM,false);
}
I just tested that, and it worked in the way I expected. (make sure the map spot that you are playing the sounds from is near enough to the player to be heard)

Another option, if your map allows it, is to place the 3D control sector near to where the player activates the script, give your sound sequence a number in the SNDSEQ lump and place a sound sequence thing in the control sector. Of course, seeing as how your sequence is just using default sounds, you could probably get away with just moving the sector near to the player and removing the sound sequence entirely (again, only if that is feasible in your map).
IgnyteZero
Posts: 64
Joined: Thu Jan 16, 2025 12:17 pm
Operating System Version (Optional): Windows 10

Re: Simple sound scripting issue with 3D floor

Post by IgnyteZero »

Enjay wrote: Fri Apr 03, 2026 6:03 am OK, these are my guesses at what's going on because I rarely, if ever, play sound sequences vie a script.

Possibly your sound sequence doesn't work. I would suggest testing it using the playsequence console command, but I have never been able to get that to work (it's always silent when I try it).
Yeah, tried that but was facing the same issues as you sadly.

Enjay wrote: Fri Apr 03, 2026 6:03 amPlaySound is intended for sounds (from SNDINFO), not sound sequences. So, it probably wont work. I also note that you have used a volume of 10.0. The maximum is 1.0.
Yeah, the volume thing was a typo. But changing it t 1.0 made no difference.
Enjay wrote: Fri Apr 03, 2026 6:03 am

Code: Select all

script 34 (void) {  // bridge raise t2
	PlaySound(31,"plats/pt1_mid",CHAN_BODY,1.0,true,ATTN_NORM,false);

	Floor_RaiseByValue(32,8,120);
	Ceiling_RaiseByValue(32,8,120);

	TagWait(32);

	StopSound(31,CHAN_BODY);

	PlaySound(31,"plats/pt1_stop",CHAN_BODY,1.0,false,ATTN_NORM,false);
}
I just tested that, and it worked in the way I expected. (make sure the map spot that you are playing the sounds from is near enough to the player to be heard)
That script definitely looks like it would solve my problem. I'll try it out, and yeah, the button is right next to the sound source so crossing my fingers this fixes it.
Enjay wrote: Fri Apr 03, 2026 6:03 amAnother option, if your map allows it, is to place the 3D control sector near to where the player activates the script, give your sound sequence a number in the SNDSEQ lump and place a sound sequence thing in the control sector. Of course, seeing as how your sequence is just using default sounds, you could probably get away with just moving the sector near to the player and removing the sound sequence entirely (again, only if that is feasible in your map).
Kinda tried a variant of that too, but I probably didn't do it correctly as the soundsequence thing didn't seem to produce any sound anyway.
IgnyteZero
Posts: 64
Joined: Thu Jan 16, 2025 12:17 pm
Operating System Version (Optional): Windows 10

Re: Simple sound scripting issue with 3D floor

Post by IgnyteZero »

Enjay wrote: Fri Apr 03, 2026 6:03 am

Code: Select all

script 34 (void) {  // bridge raise t2
	PlaySound(31,"plats/pt1_mid",CHAN_BODY,1.0,true,ATTN_NORM,false);

	Floor_RaiseByValue(32,8,120);
	Ceiling_RaiseByValue(32,8,120);

	TagWait(32);

	StopSound(31,CHAN_BODY);

	PlaySound(31,"plats/pt1_stop",CHAN_BODY,1.0,false,ATTN_NORM,false);
}
I just tested that, and it worked in the way I expected. (make sure the map spot that you are playing the sounds from is near enough to the player to be heard)
I have tested it with my map now, and no luck sadly. Quite frustrating.
User avatar
Enjay
 
 
Posts: 27610
Joined: Tue Jul 15, 2003 4:58 pm
Location: Scotland
Contact:

Re: Simple sound scripting issue with 3D floor

Post by Enjay »

That's weird, because it works perfectly for me. Try the attached (replaces map01 of Doom2).
Attachments
Bridge.zip
(2.71 KiB) Downloaded 3 times
IgnyteZero
Posts: 64
Joined: Thu Jan 16, 2025 12:17 pm
Operating System Version (Optional): Windows 10

Re: Simple sound scripting issue with 3D floor

Post by IgnyteZero »

Enjay wrote: Fri Apr 03, 2026 6:54 am That's weird, because it works perfectly for me. Try the attached (replaces map01 of Doom2).
Yeah, that worked great in that example. But still not in my level. Hmmm... I wonder... I wonder... Maybe the issue is the similar to as when I tried to do this just by using linedef action 95 and 96 to lower and raise the floor.

See, this is still for my Riddle Of the Vacant Baron mod I released in december, but I'm working on a version 2.0 which has some extra stuff, including some extra face lifts on certain early levels. So on map 1 (VACANT01) in the published version there's a platform that lowers quite immediately and abruptly as you enter the level. And then you raised it later on (which wassupposedly meant to make it easier if you played coop) by pressing a button.

Now to make this "trap" more in your face and look better, as well as letting me remove another button (which served to prevent a softlock) adding a 3D floor to replace that platform just kinda made sense to me. But as I did this it played the sound normally as it sank to the floor below using linedef action 95, but when pressing the button (which I now moved immediately on the other side this trap) to raise it using linedef action 96 it was just muted, soundless. And testing around it seemed it like that if I made it rise first, it played the rise sound, but would not play the sound when it lowered. So that's why I thought I'd force it to do this by doing it by script instead.

It seems like such an easy thing to do, but no luck.
User avatar
Enjay
 
 
Posts: 27610
Joined: Tue Jul 15, 2003 4:58 pm
Location: Scotland
Contact:

Re: Simple sound scripting issue with 3D floor

Post by Enjay »

It has to be something to do with how you've set it up in your map because clearly both the script and the basic map setup work.

If you're getting absolute silence, that implies to me something wrong with the spot from where the sound is being played so:
Does it have the correct tid/tag?
Is it set to appear on all difficulty levels and with all classes?
Do you have another script that maybe accidentally has "Thing_Remove" taking away the map spot or "ChangeTid" changing the map spot tag before script 34 gets run?

You can also double check that the sounds mentioned in the script are working on your system (using "playsound SoundName" at the console).
However, because these are standard, built-in sounds, that seems unlikely to be the problem.

If you continue to have problems, you could post your map (preferably with a player start spot near the problem area).
IgnyteZero
Posts: 64
Joined: Thu Jan 16, 2025 12:17 pm
Operating System Version (Optional): Windows 10

Re: Simple sound scripting issue with 3D floor

Post by IgnyteZero »

Enjay wrote: Fri Apr 03, 2026 8:14 am Do you have another script that maybe accidentally has "Thing_Remove" taking away the map spot or "ChangeTid" changing the map spot tag before script 34 gets run?
Ah, this was the issue. When I tried to run your version of the script I must have accidentally removed the MapSpot thing I was using. (Which you can see if you look at the map I sent you, which is btw not necessary now). I double checked now and noticed this. Put it back and now it works as it should!

Super thanks!
User avatar
Enjay
 
 
Posts: 27610
Joined: Tue Jul 15, 2003 4:58 pm
Location: Scotland
Contact:

Re: Simple sound scripting issue with 3D floor

Post by Enjay »

Cool. I figured it had to be something reasonably simple but easy to overlook. Glad it's sorted.
Post Reply

Return to “Scripting”