Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
Sign in to follow this  
Glaice

Playing sounds on linedef use in a script

Recommended Posts

I was thinking of a few lines in a map that play a sound, stop and play again if activated via +use with the sound playing in a specific region (in front of the line) and not everybody in a network game and one being toggleable like a radio. What would I do for this via scripting?

/KnowsNothingAboutACS

Share this post


Link to post
Glaice said:

I was thinking of a few lines in a map that play a sound, stop and play again if activated via +use with the sound playing in a specific region (in front of the line) and not everybody in a network game and one being toggleable like a radio.

Can you please divide this sentence into separate sentences, where each one will describe exactly one problem you have? I'd like to help you out, but I'm confused how do you actually want it to work.

Share this post


Link to post

I want to make a 2 sided linedef to activate a one-time playable but repeatable sound (like a soundboard) and another toggleable sound that can be turned on and off but loops while on.

Share this post


Link to post

I'm still not 100% certain if I understand you right.

I wanted to suggest this script:

int soundIsOn = 0;                                   // A variable that will remember whether the sound is On or Off

script 1 (void) {                                    // Let this script be activated by pressing a linedef, with repeatable action
  if(soundIsOn) {                                    // Variable == 1
    soundIsOn = 0;                                   // Toggle variable
    StopSound(0,0);                                  // Stopping to play the looping sound
  }
  else {                                             // Variable == 0
    soundIsOn = 1;                                   // Toggle variable
    PlaySound(0,"misc/chat2",0,1.0,1,1.0);           // The looping sound
  }
  PlaySound(0,"misc/chat",0,1.0,0,1.0);              // The non-looping sound
}
But when I've tried it myself, neither DB2 nor GZDB can compile this script, because it doesn't know StopSound and PlaySound functions - I guess you need updated configs for that (ZDoom 2.7.1+) (?).

Share this post


Link to post

The thing is I wanted to make my friend giggle from the alterations within Zandronum and activated by a switch (for the looping one), which I don't know if it would be possible to do.

What would I edit in the second one that is non-looping, but repeatable via activating?

Share this post


Link to post

Oh, so in Zandronum, it's going to be much harder, because these nice flexible functions don't exist there (they're ZDoom 2.7.1+ only).

Here you have a list of some sound-related ACS functions you can mess with - ThingSound looks promising, though it cannot handle looping. The looping might be faked by a looping script playing the sound again and again, perhaps using Restart. I'm going to sleep right now, sorry for rushing it and giving just general tips, I might be more helpful again tomorrow, if needed.

Share this post


Link to post

So the easiest part: The non-looping sound. Place a linedef, and place a Map Spot thing in front of the linedef. The linedef will launch script 1 via ACS_ExecuteAlways, if you don't want any delay, or via ACS_Execute, if you want a little delay before the switch can be pressed again. Assign tag 999 to the Map Spot thing. Then write this script to the Scripts window:

script 1 (void) {
  ThingSound(999,"misc/chat",127);      // or use another sound instead of "misc/chat"
  Delay(10);                            // omit this line if you don't want a delay, or feel free change the value
}
I don't know how to do a looping sound easily.

Share this post


Link to post

I guess I can get away with non-looping for the loop one as it's like 15 seconds long.

In DB2, I do not see the Map Spot thing, where/what do I do to put this in?

Share this post


Link to post

With the looping sound, maybe you can spawn a new custom thing (tagged 998, for example) from the 999 thing using SpawnSpot, and make this new thing to play and loop your sound using DECORATE or sound sequences or anything. Then, when you wanted to turn the sound off, you can use Thing_Remove to remove the thing with tag 998.

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  
×