Change the Text Sound Effect

Argami

Veteran
Veteran
Joined
Jun 22, 2012
Messages
130
Reaction score
10
First Language
Spanish
Primarily Uses
Hi! I'm using the Zerbu's Text Sound Effect Script and I want to know if it's possible to modify the script to add the feature to change the sound using Variables.

Here is the original script:

#==============================================================================
# Text Sound Effect (version 2)
# NEW FEATURE: Switch to turn off sound effect
#------------------------------------------------------------------------------
# by Zerbu
#==============================================================================
module Text_Sound_Effect
#--------------------------------------------------------------------------
# Options
#--------------------------------------------------------------------------
# The sound effect to play
MESSAGE_SOUND = RPG::SE.new("Knock", 70, 80)

# The number of characters to display before each time the sound plays
# The default is 3, it's recommended you keep it as this unless you
# know what you're doing
MESSAGE_SOUND_FRAMES = 3

# Switch to disable sound effect
# If you need to turn off the sound effect for any part of the game,
# turn this switch on
MESSAGE_SOUND_DISABLE = 2

end

class Window_Base < Window
include Text_Sound_Effect
#--------------------------------------------------------------------------
# alias method: process_characer
#--------------------------------------------------------------------------
alias textsound_process_character_normal process_character
def process_character(c, text, pos)
if !$game_switches[MESSAGE_SOUND_DISABLE]
#---
if !defined?(@sound_frames)
@sound_frames = 0
end
#---
if @sound_frames == 0
MESSAGE_SOUND.play
end
#---
@sound_frames+=1
#---
if @sound_frames == MESSAGE_SOUND_FRAMES
@sound_frames = 0
end
#---
end
textsound_process_character_normal(c, text, pos)
end
#---
end

Code:
Thanks in advance! :D
 
Last edited by a moderator:

mobychan

CodeMaster
Veteran
Joined
Mar 23, 2012
Messages
297
Reaction score
45
First Language
German
Primarily Uses
It's not that hard, here it is:

If you want the knock sound set the variable to 0, for Cursor1 to 1...

you can add as many as you want ^^



Code:
#==============================================================================
# Text Sound Effect (version 2)
# NEW FEATURE: Switch to turn off sound effect
#------------------------------------------------------------------------------
# by Zerbu
#==============================================================================
module Text_Sound_Effect
  #--------------------------------------------------------------------------
  # Options
  #--------------------------------------------------------------------------
  # The sound effect to play
  MESSAGE_SOUND = {
    0 => RPG::SE.new("Knock", 70, 80),
    1 => RPG::SE.new("Cursor1", 70, 80),
    2 => RPG::SE.new("Cursor2", 70, 80),
  }

  # ID of the Variable that stores the current sound
  SOUND_VAR = 1
  # The number of characters to display before each time the sound plays
  # The default is 3, it's recommended you keep it as this unless you
  # know what you're doing
  MESSAGE_SOUND_FRAMES = 3
  # Switch to disable sound effect
  # If you need to turn off the sound effect for any part of the game,
  # turn this switch on
  MESSAGE_SOUND_DISABLE = 2
end
class Window_Base < Window
  include Text_Sound_Effect
  #--------------------------------------------------------------------------
  # alias method: process_characer
  #--------------------------------------------------------------------------
  alias textsound_process_character_normal process_character
  def process_character(c, text, pos)
    if !$game_switches[MESSAGE_SOUND_DISABLE]
	   #---
	   if !defined?(@sound_frames)
	   @sound_frames = 0
	   end
	   #---
	   if @sound_frames == 0
	   MESSAGE_SOUND[$game_variables[SOUND_VAR]].play
	   end
	   #---
	   @sound_frames+=1
	   #---
	   if @sound_frames == MESSAGE_SOUND_FRAMES
	   @sound_frames = 0
	   end
	   #---
    end
    textsound_process_character_normal(c, text, pos)
  end
  #---
end
 

Argami

Veteran
Veteran
Joined
Jun 22, 2012
Messages
130
Reaction score
10
First Language
Spanish
Primarily Uses
Wow! You were fast! Thank you very much, It will be very useful to me :)
 

mobychan

CodeMaster
Veteran
Joined
Mar 23, 2012
Messages
297
Reaction score
45
First Language
German
Primarily Uses
no problem ^^
 

Argami

Veteran
Veteran
Joined
Jun 22, 2012
Messages
130
Reaction score
10
First Language
Spanish
Primarily Uses
Sorry Mobychan but I tested the script and it doesn't work. It doesn't appear any message error but it doesn't sound anything :S

Sorry again Mobychan it was my error. Thanks!
 
Last edited by a moderator:

mobychan

CodeMaster
Veteran
Joined
Mar 23, 2012
Messages
297
Reaction score
45
First Language
German
Primarily Uses
how did you configure the sounds (the MESSAGE_SOUND part) and what value does you variable (the one with the id SOUND_VAR) have?

Or did you use VX?

I tried it in VXAce and it worked just fine for me, didn't see that you're using VX before...

EDIT:

Oh, ok then ^^
 
Last edited by a moderator:

Kakis

Villager
Member
Joined
Dec 20, 2018
Messages
13
Reaction score
0
First Language
English
Primarily Uses
RMXP
Hey, I'm trying out this script as well. It works for me, but I need help with the variables/changing the pitch.
How do I do this? I'm pretty new to all of it.
Is it done under events > variable? So that way its assigned to a character? Whenever I try at variables the character disappears for me. Could I have some help?
 

Actual_Isami

Villager
Member
Joined
Jan 17, 2018
Messages
17
Reaction score
0
First Language
English
Primarily Uses
RMVXA
Maybe I'm just being dumb but I copy-pasted the script into the game and there's no sound. Do I have to make event variables and set those or make in-event scripts or....?
 

Roninator2

Gamer
Veteran
Joined
May 22, 2016
Messages
2,647
Reaction score
562
First Language
English
Primarily Uses
RMVXA
I'm surprised the thread wasn't closed due to the necro post before yours @Actual_Isami

If you do not change variable 1 in your game then it should work straight away.
So are you changing the variable somewhere else? Another script that uses it?
Or the switch in the script? Turning the switch on will turn off the script.
You can also use a different variable and switch. just change the numbers for them.
Remember to always assign names to the switches and variables.
to do that open an event, insert a command -> variable, pick one and click in the name box.
 

Actual_Isami

Villager
Member
Joined
Jan 17, 2018
Messages
17
Reaction score
0
First Language
English
Primarily Uses
RMVXA
I'm surprised the thread wasn't closed due to the necro post before yours @Actual_Isami

If you do not change variable 1 in your game then it should work straight away.
So are you changing the variable somewhere else? Another script that uses it?
Or the switch in the script? Turning the switch on will turn off the script.
You can also use a different variable and switch. just change the numbers for them.
Remember to always assign names to the switches and variables.
to do that open an event, insert a command -> variable, pick one and click in the name box.
I ended up using a whole other script in the end but thanks anyway lol.
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

Happy Thanksgiving everyone! What are you thankful for? I'm thankful that I no longer have PTSD, and that I get to enjoy a good meal with my mom and stepdad! It might not be the same as before COVID, but at least I still get to enjoy the holiday!


Made another map, this one even has a cool moving waterfall. I'll have an animated GIF later whenever I'm done adding stuff. :LZSwink:
Back here again?! RPG MAKER, I can't quit you. :kaosigh:
um... why didn't anyone tell how easy it is to add motions to Sideview battlers? I literally copied the last one, changed the name and index, said where it should play, and boom... I've got intro motions.

Forum statistics

Threads
105,542
Messages
1,014,495
Members
137,221
Latest member
TheRozman
Top