06-11-2025, 02:25 AM
(This post was last modified: 06-11-2025, 02:26 AM by DerVVulfman.)
Talking Messages:
Audio playback for Message Windows
Version: 1.0
Audio playback for Message Windows
Version: 1.0
Introduction
This is an add-on for the default message systems, or for those custom message systems that are compliant. It permits the game developer to render messages whilst simultaneously playing a specified audio file.
As the default system has no letter-by-letter option, the audio file will only play once. It will not repeat.
Screenshots
Its AUDIO! Rofl!
Script
script
Code:
#==============================================================================
# ** Talking Messages: Audio playback for Message Windows
#------------------------------------------------------------------------------
# by DerVVulfman
# Version 1.0
# 06-09-2025 (MM/DD/YYYY)
# RGSS / RPGMaker XP
#==============================================================================
#
# INTRODUCTION:
# =============
#
# This is an add-on for the default message systems, or for those custom mes-
# sage systems that are compliant. It permits the game developer to render
# messages whilst simultaneously playing a specified audio file.
#
# As the default system has no letter-by-letter option, the audio file will
# only play once. It will not repeat.
#
#
#------------------------------------------------------------------------------
#
# INSTALLATION:
# =============
#
# Place this script below Scene_Debug and above Main.
#
# If Animated Message Profiles is in use, place this script below it. This is
# due to the similarity in the \ab and \a message codes in use.
#
# There are no configuration values. It is strictly plug-and-play insofar
# as installation is concerned.
#
#
#------------------------------------------------------------------------------
#
# SETTING THE AUDIO:
# ==================
#
# in this, there are two ways to define the audiofile that plays the moment
# a message appears: directly using message codes or by a script call:
#
# MESSAGE CODE:
#
# You may set an audio file that plays the moment a message is displayed by
# by using the Message Code: \A[filename].
#
# EX: @>Text: \a[BigLaugh]That is so funny!!!
#
# The above example assumes you have an audio file named 'BigLaugh' within
# the Audio\SE folder '(whether it be .wav, .Ogg, MP3, etc). The filename
# in this instance does not use or require quotes.
#
# SCRIPT CALL:
#
# You may set an audio file that plays the moment a message is displayed by
# by using the message call: set_message_audio(filename)
#
# EX: @>Script set_message_audio('BigLaugh')
# @>Text: That is so funny!!!
#
# Like the previous example, this one assumes you have an audio file named
# 'BigLaugh' within the Audio\SE folder. However, the script call must be
# executed before the message is shown, and the filename does need quotes.
#
#
# SPECIAL: It can be combined with Animated Message Profiles. With that,
# you can use both message codes within a message like so:
#
# EX: @>Text: \AB[ZeldaLaugh]\a[BigLaugh]That is so funny!!!
#
#
#------------------------------------------------------------------------------
#
# COMPATABILITY:
# ==============
#
# Designed for message systems compliant with RPGMaker XP's default system.
# All default scripts aliased.
#
# Compatible with Animated Message Profiles. The script must be below the
# profile script to be fully compliant.
#
#
#==============================================================================
#
# TERMS AND CONDITIONS:
# =====================
#
# Free to use, even in commercial projects. However, I will need some form
# of due credit.
#
#
#==============================================================================
#==============================================================================
# ** Game_Temp
#------------------------------------------------------------------------------
# This class handles temporary data that is not included with save data.
# Refer to "$game_temp" for the instance of this class.
#==============================================================================
class Game_Temp
#--------------------------------------------------------------------------
# * Public Instance Variables
#--------------------------------------------------------------------------
attr_accessor :audio # Audio Click Effect
#--------------------------------------------------------------------------
# * Alias Listings
#--------------------------------------------------------------------------
alias message_audio_game_temp_initialize initialize
#--------------------------------------------------------------------------
# * Initialize
#--------------------------------------------------------------------------
def initialize
#
message_audio_game_temp_initialize
@audio = nil
#
end
end
#==============================================================================
# ** Window_Message
#------------------------------------------------------------------------------
# This message window is used to display text.
#==============================================================================
class Window_Message < Window_Selectable
#--------------------------------------------------------------------------
# * Alias Listings
#--------------------------------------------------------------------------
alias message_audio_window_refresh refresh
alias message_audio_window_update update
#--------------------------------------------------------------------------
# * Refresh
#--------------------------------------------------------------------------
def refresh
#
refresh_message_audio # Perform profile refresh
message_audio_window_refresh # Run the original method
#
end
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
def update
#
update_message_audio if @contents_showing # Perform update if showing
message_audio_window_update # Run the original method
#
end
#--------------------------------------------------------------------------
# * Refresh : Acquiring and setting profile data name and updating message
#--------------------------------------------------------------------------
def refresh_message_audio
#
return unless $game_temp.audio.nil? # Exit unless no audio set
return if $game_temp.message_text.nil? # Exit if there's no message
text = $game_temp.message_text.clone # Get the message text
text.gsub!(/\\[Aa]\[(.*?)\]/) do # Substitute the \a code
$game_temp.audio = $1 # ..and set the profile name
""
end
$game_temp.message_text = text # Replace the message text
#
end
#--------------------------------------------------------------------------
# * Frame Update : Playing audio
#--------------------------------------------------------------------------
def update_message_audio
#
return if $game_temp.audio.nil? # Exit if no audio file
return if $game_temp.audio == '' # Exit if blank audio file
filename = "Audio/SE/" + $game_temp.audio # Set audio filename
Audio.se_play(filename, 100, 100) # Play the audio file
$game_temp.audio = nil # Clear audio file
#
end
end
#==============================================================================
# ** Interpreter
#------------------------------------------------------------------------------
# This interpreter runs event commands. This class is used within the
# Game_System class and the Game_Event class.
#==============================================================================
class Interpreter
#--------------------------------------------------------------------------
# * Set Message audio for playback
# filename : filename of audio in the Audio\SE folder
#--------------------------------------------------------------------------
def set_message_audio(filename=nil)
#
if filename.nil? # If no valid filename
$game_temp.audio = nil # ..set erased audio
return # ..and exit method.
end
if filename == "" # If filename is blank
$game_temp.audio = nil # ..set erased audio
return # ..and exit method.
end
$game_temp.audio = filename # Set the audio
#
end
end
Instructions
Its in the script, but its mainly adding a new message code or script call to set the audio.
Compatibility
Designed for message systems compliant with RPGMaker XP's default system. All default scripts aliased.
Compatible with Animated Message Profiles. The script must be below the profile script to be fully compliant.
Terms and Conditions
Free to use, even in commercial projects. However, I will need some form of due credit.
Up is down, left is right and sideways is straight ahead. - Cord "Circle of Iron", 1978 (written by Bruce Lee and James Coburn... really...)
Above are clickable links