Radio "THING" playing music?

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
Hidden Hands
Posts: 1053
Joined: Tue Sep 20, 2016 8:11 pm
Location: London, England
Contact:

Radio "THING" playing music?

Post by Hidden Hands »

I have a THING which is a radio. It stands on the side and I want it to be playing music. I want this music ONLY resonating from the THING on a loop. How can I achieve this please? Do I do the same A_PLAYSOUND code in the decorate?

Code: Select all

ACTOR Radio 298 
{
//$Category Decoration
//$Title Radio
//$Sprite RDIOA0
  Scale 0.4
  Radius 20
  Height 14
  ProjectilePassHeight -16
  States
  {
  Spawn:
    RDIO A -1 A_PlaySoundEx ("RadioRap/Loop", "SoundSlot5", 1, -1)
    Stop
  }
}
Here's my code, but it don't work.

Updated the code to this:

Code: Select all

ACTOR Radio 298 
{
//$Category Decoration
//$Title Radio
//$Sprite RDIOA0
  Scale 0.4
  Radius 20
  Height 14
  ProjectilePassHeight -16
  States
  {
  Spawn:
    RDIO A 5 NoDelay A_PlaySoundEx ("RadioRap/Loop", "SoundSlot5", 1, -1)
	RDIO A 5
    Loop
  }
}
Now it works fine, but the volume of the music is too loud. How can I fix this.

Thanks in advance.
User avatar
ramon.dexter
Posts: 1529
Joined: Tue Oct 20, 2015 12:50 pm
Graphics Processor: nVidia with Vulkan support
Location: Kozolupy, Bohemia

Re: Radio "THING" playing music?

Post by ramon.dexter »

A_playsoundex() is deprecated, use a_playsound() instead.
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49066
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Re: Radio "THING" playing music?

Post by Graf Zahl »

Like ramon.dexter said, A_PlaySoundEx is deprecated. Use A_PlaySound which does have a volume argument.
User avatar
Hidden Hands
Posts: 1053
Joined: Tue Sep 20, 2016 8:11 pm
Location: London, England
Contact:

Re: Radio "THING" playing music?

Post by Hidden Hands »

Ah I see. OK. So

Code: Select all

RDIO A 5 NoDelay A_PlaySound ("RadioRap/Loop", "SoundSlot5", 1, -1 "volume", 0.7)
Something like this will work better?

EDIT: Well I tried this version but it didn't work. I know I'm putting that volume code in wrong or something.
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49066
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Re: Radio "THING" playing music?

Post by Graf Zahl »

Did you even read the Wiki?
User avatar
Enjay
 
 
Posts: 26534
Joined: Tue Jul 15, 2003 4:58 pm
Location: Scotland
Contact:

Re: Radio "THING" playing music?

Post by Enjay »

I think that we can do better than it just being a dumb thing sitting playing a sound forever...
RadioGaGa.pk3
But, yeah, the wiki helps - a lot. [wiki]A_PlaySound[/wiki]

BTW, if you only want the radio to be heard when you are quite close to it, change ATTN_NORM to ATTN_STATIC in the DECOARATE code.
User avatar
Hidden Hands
Posts: 1053
Joined: Tue Sep 20, 2016 8:11 pm
Location: London, England
Contact:

Re: Radio "THING" playing music?

Post by Hidden Hands »

Enjay wrote:I think that we can do better than it just being a dumb thing sitting playing a sound forever...
RadioGaGa.pk3
But, yeah, the wiki helps - a lot. [wiki]A_PlaySound[/wiki]

BTW, if you only want the radio to be heard when you are quite close to it, change ATTN_NORM to ATTN_STATIC in the DECOARATE code.
What a beautiful, beautiful code. It works perfectly. Only thing I'm not understanding with this is your code says its a switchable thing. I assumed this meant you could turn it on or off by interacting with it. But it seems it can't be interacted with. Am I missing something? Either way it works perfect volume wise and everything else. Thank you so much for this.
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49066
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Re: Radio "THING" playing music?

Post by Graf Zahl »

It can be switched by using Thing_Activate and Thing_Deactivate action specials. The means to call them have yet to be implemented
User avatar
Enjay
 
 
Posts: 26534
Joined: Tue Jul 15, 2003 4:58 pm
Location: Scotland
Contact:

Re: Radio "THING" playing music?

Post by Enjay »

Did you try the switch in the map? It turns the radio off and on.

Inheriting from "SwitchableDecoration" allows the thing to be activated/deactivated via scripts and/or appropriate line defs. I used a script (visible in the scripts lump for the level).
User avatar
Hidden Hands
Posts: 1053
Joined: Tue Sep 20, 2016 8:11 pm
Location: London, England
Contact:

Re: Radio "THING" playing music?

Post by Hidden Hands »

Enjay wrote:Did you try the switch in the map? It turns the radio off and on.

Inheriting from "SwitchableDecoration" allows the thing to be activated/deactivated via scripts and/or appropriate line defs. I used a script (visible in the scripts lump for the level).
Ahh... I forgot to add that in. Thank you!
Post Reply

Return to “Scripting”