Trouble With Scripting Sounds To Play

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!)
ogwatto
Posts: 12
Joined: Tue Dec 26, 2023 10:38 pm
Operating System Version (Optional): Win 10
Graphics Processor: nVidia (Modern GZDoom)

Trouble With Scripting Sounds To Play

Post by ogwatto »

Hi Lads,

I have hit a road block, I would like to trigger a sound to play in a script but have had trouble doing so.

I receive an "identifying has not been declared" error when trying to play the sound through the script when "#include SNDINFO.txt" is not included. That changes to an "Invalid Declarator" error when I do include it.

Sorry for my poor explanation, I have a tenuous grip of scripting as is.

Thanks for any help :)


Attached are the errors I receive when trying to compile.
You do not have the required permissions to view the files attached to this post.
User avatar
ramon.dexter
Posts: 1562
Joined: Tue Oct 20, 2015 12:50 pm
Graphics Processor: nVidia with Vulkan support
Location: Kozolupy, Bohemia

Re: Trouble With Scripting Sounds To Play

Post by ramon.dexter »

Please, take a look on how you should use the LocalAmbientSound() function. The first argument is a string. Strings have to be enclosed inside "double qoutes", otherwise will not work.
ogwatto
Posts: 12
Joined: Tue Dec 26, 2023 10:38 pm
Operating System Version (Optional): Win 10
Graphics Processor: nVidia (Modern GZDoom)

Re: Trouble With Scripting Sounds To Play

Post by ogwatto »

ramon.dexter wrote: Wed Dec 27, 2023 12:16 am Please, take a look on how you should use the LocalAmbientSound() function. The first argument is a string. Strings have to be enclosed inside "double qoutes", otherwise will not work.
Thanks for the reply,
I'm still getting the same error regardless of double quoting.
Any other suggestions?
You do not have the required permissions to view the files attached to this post.
User avatar
ramon.dexter
Posts: 1562
Joined: Tue Oct 20, 2015 12:50 pm
Graphics Processor: nVidia with Vulkan support
Location: Kozolupy, Bohemia

Re: Trouble With Scripting Sounds To Play

Post by ramon.dexter »

You have it in front of your eyes! Just take a look at the other sounds defined and try to find a difference. Lets check, for example, THUD2.

The first line has way too many quotes...
ogwatto
Posts: 12
Joined: Tue Dec 26, 2023 10:38 pm
Operating System Version (Optional): Win 10
Graphics Processor: nVidia (Modern GZDoom)

Re: Trouble With Scripting Sounds To Play

Post by ogwatto »

ramon.dexter wrote: Wed Dec 27, 2023 2:09 am You have it in front of your eyes! Just take a look at the other sounds defined and try to find a difference. Lets check, for example, THUD2.

The first line has way too many quotes...
I removed the other lines just to test if quoting fixes it does.
The error pointed to the first line, so I presumed that it was still the issue.

Writing it like this does not give me an error, but it does not play a sound when the script is triggered.
Any ideas?

I am very new to scripting...
You do not have the required permissions to view the files attached to this post.
User avatar
ramon.dexter
Posts: 1562
Joined: Tue Oct 20, 2015 12:50 pm
Graphics Processor: nVidia with Vulkan support
Location: Kozolupy, Bohemia

Re: Trouble With Scripting Sounds To Play

Post by ramon.dexter »

Yes, you are still making an error. Study the following link, since it seems like you don't know what you're doing.
https://zdoom.org/wiki/SNDINFO

The thing is, you either define the sound like this:
soundname soundlump
Or
soundname "path to lump/in pk3"

So yours
Thud1 "thud1" is just wrong. If you're using a wad file, just do it like:
Thud1 thud1
And it should work.
When using pk3, I prefer to use the following:
soundname "sounds/sound.ogg"
ogwatto
Posts: 12
Joined: Tue Dec 26, 2023 10:38 pm
Operating System Version (Optional): Win 10
Graphics Processor: nVidia (Modern GZDoom)

Re: Trouble With Scripting Sounds To Play

Post by ogwatto »

ramon.dexter wrote: Wed Dec 27, 2023 4:51 am Yes, you are still making an error. Study the following link, since it seems like you don't know what you're doing.
https://zdoom.org/wiki/SNDINFO

The thing is, you either define the sound like this:
soundname soundlump
Or
soundname "path to lump/in pk3"

So yours
Thud1 "thud1" is just wrong. If you're using a wad file, just do it like:
Thud1 thud1
And it should work.
When using pk3, I prefer to use the following:
soundname "sounds/sound.ogg"
Thanks for replying.
No longer getting any errors when the SNDINFO is written as you've shown.
However, I'm not hearing any sound when the script is triggered. I've copied your example verbatim but still no luck.
I read in another thread it may be an issue with GZDoom builder: viewtopic.php?t=58294

Could it be a technical error, or am I still just stupid?
Any extra help would be appreciated :)
You do not have the required permissions to view the files attached to this post.
ogwatto
Posts: 12
Joined: Tue Dec 26, 2023 10:38 pm
Operating System Version (Optional): Win 10
Graphics Processor: nVidia (Modern GZDoom)

Re: Trouble With Scripting Sounds To Play

Post by ogwatto »

Grasping at straws here, could the issue be the map and sounds not being the same PK3?
You do not have the required permissions to view the files attached to this post.
User avatar
ramon.dexter
Posts: 1562
Joined: Tue Oct 20, 2015 12:50 pm
Graphics Processor: nVidia with Vulkan support
Location: Kozolupy, Bohemia

Re: Trouble With Scripting Sounds To Play

Post by ramon.dexter »

Yes, the sound should be in hte same archive...when using pk3, why multiple archives?
ogwatto
Posts: 12
Joined: Tue Dec 26, 2023 10:38 pm
Operating System Version (Optional): Win 10
Graphics Processor: nVidia (Modern GZDoom)

Re: Trouble With Scripting Sounds To Play

Post by ogwatto »

ramon.dexter wrote: Wed Dec 27, 2023 12:56 pm Yes, the sound should be in hte same archive...when using pk3, why multiple archives?
It was just how everything was organised
Regardless, I've placed the sounds into the same .wad as the map and still nothing...

Return to “Scripting”