Message Banner
Version: 1.0
Author: Marc of Fall From Eden
Date: April 3, 2012
Version History
- <Version 1.0> 2012.04.03 - Original Release
Description
This script creates a one-line banner at the top of the screen for displaying any text desired by the designer. At present, a number of default messages have been added to the script for automatic messaging when the party moves to a new map, whenever items are gained or lost, HP or MP is lost or gained, and so on. Just about any action you can perform on the party from event commands has had a banner message defined for it.
Note: the message queue works on a
single message at a time, and operates in a "first-in, first-out" manner. Basically, messages are displayed in the order that they were added to the queue.
Features
- Shows a simple banner for non-critical game information to the player.
- Any desired text can be added as a banner message.
- The effect is entirely automatic for many things. (No coding required by the designer!)
- Writing new automatic banner messages is easy if you know a little scripting.
Screenshots Instructions
Detailed instructions are provided in the script itself.
Something to note, however: by default, this script will show messages whenever the player enters a new map. You can comment-out text in map names by surrounding the part you want as a comment in brackets, [like this]. As well, the banner will only show up if the name of the map has
changed since the last time a message was displayed (so the map name will not show up every time the player goes to their menu and back to the map). With this in mind, you can create sequences of maps that all have the same name so that the banner won't display on every single map (such as an inn with multiple floors named "Inn[1F]" and "Inn[2F]"). Just use the brackets to comment out parts of the map name that you don't want displayed. If you don't want the banner to show up for a single map, simply comment out the entire name, and the banner message will be suppressed.
Script
# ============================================================================ #
# Message Queue v1.0 by Marc (of Fall From Eden) #
# This script is licensed under the Creative Commons BY-SA 3.0 license. #
# ============================================================================ #
# DESCRIPTION #
# ---------------------------------------------------------------------------- #
# This script creates a "message banner" at the top of the screen for showing #
# non-critical (but useful) information to the player during gameplay. This #
# banner can contain any messages you wish to place in it. These messages are #
# handled in a "first-in, first-out" manner, creating a queue of messages to #
# show to the player. Only one message is displayed at a time, but others can #
# be added to the queue to display after the first message has faded out. #
# ============================================================================ #
# USAGE INSTRUCTIONS #
# ---------------------------------------------------------------------------- #
# This script comes with its own assortment of "add-ons." The message banner #
# does not show any messages ITSELF, but adding or creating methods which ADD #
# to the banner can be incredibly easy. #
# #
# By default, the add-ons included in this script are automatic. There is no #
# coding needed on your part to get them to work. You can find a list of these #
# add-ons in the Marc::Queue module below and set them as you desire. Setting #
# an add-on to "true" will show the message while setting it to "false" will #
# keep the message from displaying and run the original method the add-on #
# aliased. #
# #
# NOTE: Messages shown for map names exclude text written between brackets. #
# Map names will only show on the banner if the name of the new map is not the #
# same as the previous map. This keeps the banner from showing up more than #
# once for the map if the player goes to the menu, and lets you define whole #
# sections where you want the name shown only once. For instance, you could #
# create an inn with two floors, one named "Inn[1F]" and the other "Inn[2F]". #
# The banner would only display if the player entered from a location that is #
# not named "Inn" in that case (like the town where the inn is located). ;) #
# #
# Also, by default, the banner will NOT show duplicate messages. If two of the #
# messages in the queue are identical, the duplicate message will be removed #
# from the queue. You can change this behavior in the Marc::Queue module below #
# if that is not desired. #
# #
# If you want to add messages to the banner yourself, you can easily do so in #
# an event's Script command. Simply add the following: #
# #
# $game_map.queue.push("Your message here.") #
# #
# If your message is too long to write on a single line, you can do this to #
# get the same result: #
# #
# m = "Your message here." #
# $game_map.queue.push(m) #
# #
# For scripters: the banner reads messages from the array @queue in $game_map. #
# Adding or modifying methods to show messages is therefore simple, requiring #
# nothing more than pushing a string to the end of the array. You could also #
# write scripts that rearrange or modify the contents of the banner, if you so #
# desire. :) #
# #
# Have fun! :) #
# - Marc #
# ============================================================================ #
module Marc
module Queue
# Set this to the switch you want to activate or deactivate the message
# banner.
SWITCH = 1
# Should this switch be turned on automatically when starting a new game?
ENABLED = true
# The text alignment for the message banner. 0 is left-aligned, 1 is
# centered, and 2 is right-aligned.
ALIGNMENT = 1
# The font you want the banner to display. By default, this is set to
# Font.default_name, but you can specify an array of fonts instead. If the
# first font in the array can't be used, it'll use the next, and so on.
# For example: FONT = ["Verdana", "Arial", "Courier New"]
FONT = Font.default_name
# The background color of the message banner. Must be an instance of Color.
# Write as Color.new(red, green, blue, transparency). Maximum values for
# each are 255 (0 transparency is fully opaque, 255 fully transparent).
BACKGROUND = Color.new(0, 0, 0, 128)
# How much opacity is changed per frame when fading in or out. Increasing
# this will cause messages to fade in and out faster, while decreasing it
# will cause them to fade more slowly.
FADE_STEP = 8
# How long to show the message in frames after the fade-in is completed.
WAIT = 120
# Delete duplicate entries in the queue?
REMOVE_DUPLICATES = true
# Show message when a new map is loaded?
MSG_MAP = true
# Show message when gold is gained or lost?
MSG_GOLD = true
# Show message when items are gained or lost?
MSG_ITEM = true
# Show a message when a member is added or removed from the party?
MSG_PARTY = true
# Show a message when Change HP is used in an event?
MSG_HP = true
# Show a message when Change MP is used in an event?
MSG_MP = true
# Show a message when a state is added or removed in an event?
MSG_STATE = true
# Show a message when Recover All is used in an event?
MSG_RECOVER = true
# Show a message when experience is changed in an event?
MSG_EXP = true
# Show a message when a level is changed in an event?
MSG_LEVEL = true
# Show a message when an actor's parameters are changed in an event?
MSG_PARAMETERS = true
# Show a message when an actor learns or forgets a skill?
MSG_SKILLS = true
# Show a message when an actor's equipment changes in an event?
MSG_EQUIPMENT = true
# Show a message when an actor's name changes in an event?
MSG_NAME = true
# Show a message when an actor's class changes in an event?
MSG_CLASS = true
end
end # module Marc::Queue
# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! #
# ! DO NOT EDIT BEYOND THIS POINT. ! #
# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! #
$imported = {} if $imported == nil
$imported["Marc_Message_Queue"] = true
# ============================================================================ #
# Game_Temp #
# ---------------------------------------------------------------------------- #
# Aliased method: initialize #
# ============================================================================ #
if Marc::Queue::MSG_MAP
class Game_Temp
attr_accessor :old_map_name
alias marc_queue_addons_initialize initialize
def initialize
@old_map_name = nil
marc_queue_addons_initialize
end # initialize
end # class Game_Temp
end
# ============================================================================ #
# Game_Switches #
# ---------------------------------------------------------------------------- #
# Aliased methods: initialize #
# ============================================================================ #
if Marc::Queue::ENABLED
class Game_Switches
alias marc_queue_initialize initialize
def initialize
marc_queue_initialize
@data[Marc::Queue::SWITCH] = true
end # initialize
end # class Game_Switches
end # if Marc::Queue::ENABLED
# ============================================================================ #
# Game_Map #
# ---------------------------------------------------------------------------- #
# Aliased methods: initialize, setup #
# New method: map_name #
# ============================================================================ #
class Game_Map
attr_accessor :queue
alias marc_queue_initialize initialize
def initialize
@queue = []
marc_queue_initialize
end # initialize
if Marc::Queue::MSG_MAP
alias marc_queue_addons_setup setup
def setup(map_id)
marc_queue_addons_setup(map_id)
if $game_temp.old_map_name != map_name
$game_temp.old_map_name = map_name
unless map_name == "" or not $game_switches[Marc::Queue::SWITCH]
@queue.push("You have entered #{map_name}.")
end
end
end # setup
def map_name
data = load_data("Data/MapInfos.rvdata")
return data[@map_id].name.gsub(/\[.*?\]/, "").strip
end # map_name
end
end # class Game_Map
# ============================================================================ #
# Game_Party #
# ---------------------------------------------------------------------------- #
# Aliased methods: gain_gold, gain_item #
# ============================================================================ #
if Marc::Queue::MSG_GOLD or Marc::Queue::MSG_ITEM
class Game_Party < Game_Unit
if Marc::Queue::MSG_GOLD
alias marc_queue_addons_gain_gold gain_gold
def gain_gold(n)
marc_queue_addons_gain_gold(n)
return if not $scene.is_a?(Scene_Map)
return if not $game_switches[Marc::Queue::SWITCH]
if n > 0
if n == 1
$game_map.queue.push("Found a #{Vocab::gold}.")
else
$game_map.queue.push("Found #{n} #{Vocab::gold}s.")
end
else
if n == -1
$game_map.queue.push("Lost a #{Vocab::gold}.")
else
$game_map.queue.push("Lost #{n.abs} #{Vocab::gold}s.")
end
end
end # gain_gold
end
if Marc::Queue::MSG_ITEM
alias marc_queue_addons_gain_item gain_item
def gain_item(item, n, include_equip = false)
queue_item = item.name.to_s unless item.nil?
marc_queue_addons_gain_item(item, n, include_equip = false)
return if not $scene.is_a?(Scene_Map)
return if not $game_switches[Marc::Queue::SWITCH]
unless item.nil?
if n > 0
if n == 1
if queue_item =~ /^[aeiou]/i
$game_map.queue.push("Found an #{queue_item}.")
else
$game_map.queue.push("Found a #{queue_item}.")
end
else
$game_map.queue.push("Found #{n} #{queue_item}s.")
end
else
if n == -1
if queue_item =~ /^[aeiou]/i
$game_map.queue.push("Lost an #{queue_item}.")
else
$game_map.queue.push("Lost a #{queue_item}.")
end
else
$game_map.queue.push("Lost #{n} #{queue_item}s.")
end
end
end
end # gain_item
end
end # class Game_Party
end
# ============================================================================ #
# Game_Interpreter #
# ---------------------------------------------------------------------------- #
# Aliased methods: command_129, command_311, command_312, command_313, #
# command_314, command_315, command_316, command_317, command_318, #
# command_319, command_320 #
# ============================================================================ #
class Game_Interpreter
if Marc::Queue::MSG_PARTY
alias marc_queue_addons_command_129 command_129
def command_129 # Change Party
marc_queue_addons_command_129
if $scene.is_a?(Scene_Map) and $game_switches[Marc::Queue::SWITCH]
actor = $game_actors[@params[0]]
if actor != nil and @params[1] == 0
$game_map.queue.push("#{actor.name} has joined #{$game_party.name}.")
elsif actor != nil and @params[1] != 0
$game_map.queue.push("#{actor.name} has left #{$game_party.name}.")
end
end
end # command_129
end
if Marc::Queue::MSG_HP
alias marc_queue_addons_command_311 command_311
def command_311 # Change HP
marc_queue_addons_command_311
if $scene.is_a?(Scene_Map) and $game_switches[Marc::Queue::SWITCH]
value = operate_value(@params[1], @params[2], @params[3])
actor = $game_actors[@params[0]] unless @params[0] == 0
@params[0] == 0 ? name = $game_party.name : name = actor.name
if value > 0
$game_map.queue.push("#{name} recovered #{value} #{Vocab::hp}.")
elsif value < 0
$game_map.queue.push("#{name} lost #{value.abs} #{Vocab::hp}.")
end
end
end # command_311
end
if Marc::Queue::MSG_MP
alias marc_queue_addons_command_312 command_312
def command_312 # Change MP
marc_queue_addons_command_312
if $scene.is_a?(Scene_Map) and $game_switches[Marc::Queue::SWITCH]
value = operate_value(@params[1], @params[2], @params[3])
actor = $game_actors[@params[0]] unless @params[0] == 0
@params[0] == 0 ? name = $game_party.name : name = actor.name
if value > 0
$game_map.queue.push("#{name} recovered #{value} #{Vocab::mp}.")
elsif value < 0
$game_map.queue.push("#{name} lost #{value.abs} #{Vocab::mp}.")
end
end
end # command_312
end
if Marc::Queue::MSG_STATE
alias marc_queue_addons_command_313 command_313
def command_313 # Change State
marc_queue_addons_command_313
if $scene.is_a?(Scene_Map) and $game_switches[Marc::Queue::SWITCH]
state = $data_states[@params[2]]
actor = $game_actors[@params[0]] unless @params[0] == 0
@params[0] == 0 ? name = $game_party.name : name = actor.name
if @params[1] == 0
$game_map.queue.push("#{name}#{state.message1}")
else
$game_map.queue.push("#{name}#{state.message4}")
end
end
end # command_313
end
if Marc::Queue::MSG_RECOVER
alias marc_queue_addons_command_314 command_314
def command_314 # Recover All
marc_queue_addons_command_314
if $scene.is_a?(Scene_Map) and $game_switches[Marc::Queue::SWITCH]
actor = $game_actors[@params[0]] unless @params[0] == 0
@params[0] == 0 ? name = $game_party.name : name = actor.name
$game_map.queue.push("#{name} has been fully recovered.")
end
end # command_314
end
if Marc::Queue::MSG_EXP
alias marc_queue_addons_command_315 command_315
def command_315 # Change EXP
marc_queue_addons_command_315
if $scene.is_a?(Scene_Map) and $game_switches[Marc::Queue::SWITCH]
value = operate_value(@params[1], @params[2], @params[3])
actor = $game_actors[@params[0]] unless @params[0] == 0
@params[0] == 0 ? name = $game_party.name : name = actor.name
if value > 0
$game_map.queue.push("#{name} gained #{value} experience.")
elsif value < 0
$game_map.queue.push("#{name} lost #{value.abs} experience.")
end
end
end # command_315
end
if Marc::Queue::MSG_LEVEL
alias marc_queue_addons_command_316 command_316
def command_316 # Change Level
marc_queue_addons_command_316
if $scene.is_a?(Scene_Map) and $game_switches[Marc::Queue::SWITCH]
value = operate_value(@params[1], @params[2], @params[3])
actor = $game_actors[@params[0]] unless @params[0] == 0
@params[0] == 0 ? name = $game_party.name : name = actor.name
if @params[0] == 0
if value > 0
if value == 1
$game_map.queue.push("#{name} gained a #{Vocab::level}.")
else
$game_map.queue.push("#{name} gained #{value} #{Vocab::level}s.")
end
elsif value < 0
if value == -1
$game_map.queue.push("#{name} lost a #{Vocab::level}.")
else
$game_map.queue.push
("#{name} lost #{value.abs} #{Vocab::level}s.")
end
end
else
$game_map.queue.push
("#{name} is now #{Vocab::level} #{actor.level + value}.")
end
end
end # command_316
end
if Marc::Queue::MSG_PARAMETERS
alias marc_queue_addons_command_317 command_317
def command_317 # Change Parameters
marc_queue_addons_command_317
if $scene.is_a?(Scene_Map) and $game_switches[Marc::Queue::SWITCH]
value = operate_value(@params[2], @params[3], @params[4])
actor = $game_actors[@params[0]]
name = actor.name
if actor != nil and value != 0
case @params[1]
when 0
$game_map.queue.push
("#{name}'s maximum #{Vocab::hp} is now #{actor.maxhp}.")
when 1
$game_map.queue.push
("#{name}'s maximum #{Vocab::mp} is now #{actor.maxmp}.")
when 2
$game_map.queue.push("#{name}'s #{Vocab::atk} is now #{actor.atk}.")
when 3
$game_map.queue.push("#{name}'s #{Vocab::def} is now #{actor.def}.")
when 4
$game_map.queue.push("#{name}'s #{Vocab::spi} is now #{actor.spi}.")
when 5
$game_map.queue.push("#{name}'s #{Vocab::agi} is now #{actor.agi}.")
end
end
end
end # command_317
end
if Marc::Queue::MSG_SKILLS
alias marc_queue_addons_command_318 command_318
def command_318 # Change Skills
marc_queue_addons_command_318
if $scene.is_a?(Scene_Map) and $game_switches[Marc::Queue::SWITCH]
actor = $game_actors[@params[0]]
if actor != nil
name = actor.name
skill = $data_skills[@params[2]]
if @params[1] == 0
$game_map.queue.push("#{name} learned #{skill.name}.")
else
$game_map.queue.push("#{name} forgot #{skill.name}.")
end
end
end
end # command_318
end
if Marc::Queue::MSG_EQUIPMENT
alias marc_queue_addons_command_319 command_319
def command_319 # Change Equipment
marc_queue_addons_command_319
if $scene.is_a?(Scene_Map) and $game_switches[Marc::Queue::SWITCH]
actor = $game_actors[@params[0]]
if actor != nil
name = actor.name
if @params[1] == 0 or (@params[1] == 1 and actor.two_swords_style)
equipment = $data_weapons[@params[2]]
else
equipment = $data_armors[@params[2]]
end
unless equipment.nil?
$game_map.queue.push("#{name} has equipped #{equipment.name}.")
else
case @params[1]
when 0
$game_map.queue.push("#{name} has unequipped a weapon.")
when 1
$game_map.queue.push("#{name} has unequipped their shield.")
when 2
$game_map.queue.push("#{name} has unequipped their headgear.")
when 3
$game_map.queue.push("#{name} has unequipped their armor.")
when 4
$game_map.queue.push("#{name} has unequipped their accessory.")
end
end
end
end
end # command_319
end
if Marc::Queue::MSG_NAME
alias marc_queue_addons_command_320 command_320
def command_320 # Change Name
if $scene.is_a?(Scene_Map) and $game_switches[Marc::Queue::SWITCH]
actor = $game_actors[@params[0]]
if actor != nil
$game_map.queue.push("#{actor.name} is now known as #{@params[1]}.")
end
end
marc_queue_addons_command_320
end # command_320
end
if Marc::Queue::MSG_CLASS
alias marc_queue_addons_command_321 command_321
def command_321 # Change Class
marc_queue_addons_command_321
if $scene.is_a?(Scene_Map) and $game_switches[Marc::Queue::SWITCH]
actor = $game_actors[@params[0]]
new_class = $data_classes[@params[1]]
if actor != nil and new_class != nil
if new_class.name =~ /^[aeiou]/i
$game_map.queue.push("#{actor.name} is now an #{new_class.name}.")
else
$game_map.queue.push("#{actor.name} is now a #{new_class.name}.")
end
end
end
end # command_321
end
end # class Game_Interpreter
# ============================================================================ #
# Spriteset_Map #
# ---------------------------------------------------------------------------- #
# Aliased methods: initialize, update, dispose #
# ============================================================================ #
class Spriteset_Map
alias marc_queue_initialize initialize
def initialize
marc_queue_initialize
@queue = Marc_Queue.new(@viewport3) if $game_switches[Marc::Queue::SWITCH]
end # initialize
alias marc_queue_update update
def update
if $game_switches[Marc::Queue::SWITCH]
@queue.update unless @queue.nil?
else
$game_map.queue.clear if $game_map.queue != nil
end
marc_queue_update
end # update
alias marc_queue_dispose dispose
def dispose
@queue.dispose unless @queue.nil?
marc_queue_dispose
end # dispose
end # class Spriteset_Map
# ============================================================================ #
# Marc_Queue #
# ---------------------------------------------------------------------------- #
# Methods: initialize, update, dispose #
# ============================================================================ #
class Marc_Queue < Sprite_Base
def initialize(viewport)
super(viewport)
@counter = 0
self.opacity = 0
end # initialize
def update
return if $game_map.queue.empty?
$game_map.queue.uniq! if Marc::Queue::REMOVE_DUPLICATES
if self.bitmap.nil? and @counter == 0
self.bitmap = Bitmap.new(Graphics.width, 24)
self.bitmap.fill_rect(0, 0, Graphics.width, 24, Marc::Queue::BACKGROUND)
self.bitmap.font.name = Marc::Queue::FONT
self.bitmap.draw_text(0, 0, Graphics.width - 4, 24,
$game_map.queue[0].to_s, Marc::Queue::ALIGNMENT)
self.z = 500
end
if self.opacity < 255 and @counter < Marc::Queue::WAIT
self.opacity += Marc::Queue::FADE_STEP
end
if @counter < Marc::Queue::WAIT
@counter += 1
else
self.opacity -= Marc::Queue::FADE_STEP if self.opacity > 0
if self.opacity <= 0
$game_map.queue.shift
self.bitmap = nil
@counter = 0
end
end
end # update
end # class Marc_Queue
Credit
Support
You may receive support for this script in this topic or by sending us a personal message on these forums.
Known Compatibility Issues
This script
assumes that you're using the default RMVX scripts. Little is done in this script to check if the messages being pushed into the banner are accurate if you are using scripts that modify the way such things work.
With that said, creating new scripts or modifying existing ones so that they push accurate messages into the banner is usually very simple. If you have a request for banner integration with another script, simply let us know and Marc will attempt to work something out for you.
Demo
No demo exists for this script, as it did not seem necessary, especially considering the effect of the banner is plug-and-play. Essentially, there isn't much to demonstrate or explain in detail.
We can certainly upload one if it is requested, however.
Author's Notes
Once again, Marc wrote this script for our own nefarious purposes and fixed it up some for public consumption. Basically, the idea behind this script came to us once we noticed how many map name scripts and "item pop-up"-style scripts are out there, which made us ask, "why are these treated separately?" So, we decided to create a
general-purpose message queue that can store and display
any message desired whenever it's needed. As such, we've been using this script for all kinds of things, from debugging to giving the player non-critical (but still important) information in-game.
Terms of Use
This script is licensed under a Creative Commons BY-SA 3.0 license. Essentially, you may use it for commercial games, but proper attribution is required; as well, you may modify the script any way you like as long as the modified version retains attribution to the original author and is released under an
identical license.