Activating a tape-recorder (with animation)

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:

Activating a tape-recorder (with animation)

Post by Hidden Hands »

This is a strange one, but in my game there is an audio-log that can be played on a reel-to-reel tape-recorder. The taperecorder is not animated at first. Here's what I want to happen. Clicking on it (I would assume by running an ACS script to activate the front linedef of the recorder) playes the audio file (which I can do with AmbientSound) but how would I make the tape start spinning on the texture too? I want it to only spin as long as the audio plays then return to being static again.

Thanks in advance for any tips you can share.
Jarewill
 
 
Posts: 1853
Joined: Sun Jul 21, 2019 8:54 am

Re: Activating a tape-recorder (with animation)

Post by Jarewill »

You could make your tape recorder inherit from SwitchableDecoration which will switch to an Active state with an animation.
For example:

Code: Select all

Actor TapeRecorder : SwitchableDecoration
{
  Activation THINGSPEC_Activate //Activate the decoration
  +USESPECIAL  //When it's used
  States
  {
  Spawn:
    TAPE A 10
    Loop
  Active:
    TAPE A 0 A_StartSound("tape/entry1") //Play the tape when activated
    TAPE BCBCBCBCBC 18 //Set it to the duration of the tape
    Goto Spawn
  }
} 
For more info check this wiki page.
User avatar
Hidden Hands
Posts: 1053
Joined: Tue Sep 20, 2016 8:11 pm
Location: London, England
Contact:

Re: Activating a tape-recorder (with animation)

Post by Hidden Hands »

Would this work with a sector object too ? So let's just say I build a sector and texture it to look like a tape recorder, can I do this to make the texture animate and play the sound too?
Jarewill
 
 
Posts: 1853
Joined: Sun Jul 21, 2019 8:54 am

Re: Activating a tape-recorder (with animation)

Post by Jarewill »

No, a switchable decoration can only be an actor.
If you want to change a line's texture, you will have to use SetLineTexture in your script.
User avatar
Hidden Hands
Posts: 1053
Joined: Tue Sep 20, 2016 8:11 pm
Location: London, England
Contact:

Re: Activating a tape-recorder (with animation)

Post by Hidden Hands »

Jarewill wrote:No, a switchable decoration can only be an actor.
If you want to change a line's texture, you will have to use SetLineTexture in your script.
Ah okay, thanks for clearing it up.

Okay so this is my code, heavily based for the most part on your example, and it works great.

Code: Select all

Actor Dictophone : SwitchableDecoration 8423
{
//$Category Interactive
//$Title Dictophone
//$Sprite DICKA0
  Scale 0.3
  Activation THINGSPEC_Activate //Activate the decoration
  +USESPECIAL  //When it's used
  States
  {
  Spawn:
    DICK A 10
    Loop
  Active:
    DICK A 0 A_PlaySound("JackKessler/Audio") //Play the tape when activated
    DICK BCBCBCBCBCBCBCBCBCBCBCBCBCBCBCBCBCBCBCBCBCBCBCBCBCBCBCBCBCBCBCBCBCBCBCBCBCBCBCBCBCBCBCBCBCBCBCBCBCBCBCBCBCBCBCBCBCBCBCBCBC 18 //Set it to the duration of the tape
    Goto Spawn
  }
}
But I do have one last quesstion. How can I make it a repeatable action? After it plays the audio log, it becomes completely inactive. Is there a good way to make it repeatable? So when its completed, you can activate it again?

Thanks in advance.
Jarewill
 
 
Posts: 1853
Joined: Sun Jul 21, 2019 8:54 am

Re: Activating a tape-recorder (with animation)

Post by Jarewill »

Changing the activation property to THINGSPEC_Switch and adding an Inactive state should do the job:

Code: Select all

  Activation THINGSPEC_Switch //Activate the decoration
  +USESPECIAL  //When it's used
  States
  {
  Inactive: //Make the Inactive state the same as the Spawn state
  Spawn:
    DICK A 10 A_StopSound(CHAN_BODY) //Optional: Also make the sound stop
    Loop
However this will let the player stop the recording halfway, so adding the StopSound might be useful.
User avatar
Hidden Hands
Posts: 1053
Joined: Tue Sep 20, 2016 8:11 pm
Location: London, England
Contact:

Re: Activating a tape-recorder (with animation)

Post by Hidden Hands »

This is perfect, thank you again Jarewill for your constant help.
Post Reply

Return to “Scripting”