Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

Background Message System

Background Message System
Version: 1.0


Introduction

This script allows you to display text onscreen without interrupting the action. This is useful for cutscenes, minigames, etc. This has several advantages over the default message system.
  1. It does not interrupt the action. Events and characters can still move around and things can blow up while a message is onscreen.
  2. The player can still input, move the character, use items, etc. while the text is onscreen. This is useful for minigames where you don't want to interrupt the action.
  3. You can set the message to disappear exactly when you want it to in the events. This will make it much easier to make cutscenes by reducing the amount of trial and error.
  4. You can format the text of each individual line. You can change the face, size, color, outline, shadow, bold and italic status.
Screenshot

Included in attachment

Script


Give credit to KGC for this script!
Code:
 

#_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/

#_/    â—†ç¸å–り・影文字描画 - KGC_FrameShadowTextâ—†

#_/----------------------------------------------------------------------------

#_/  draw_text を強化し、縁取りや影文字の描画機能を追加します。

#_/  Provides functions to draw texts which framed or dropped shadow.

#_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/

 

<span style="color:#000080; font-style:italic;">=begin

<span style="color:#000080; font-style:italic;">┏━━━━ 搭載メソッド - Methods ━━━━━━━━━━━━━━━━━━━━━━━

<span style="color:#000080; font-style:italic;">┠─── Class - Bitmap ────────────────────────────

<span style="color:#000080; font-style:italic;">┃ draw_frame_text(x, y, width, height, string[, align, frame_color])

<span style="color:#000080; font-style:italic;">┃ draw_frame_text(rect, string[, align, frame_color])

<span style="color:#000080; font-style:italic;">┃   x, y          : 描画先座標    [Integer]

<span style="color:#000080; font-style:italic;">┃                   Destination.

<span style="color:#000080; font-style:italic;">┃   width, height : 描画サイズ    [Integer]

<span style="color:#000080; font-style:italic;">┃                   Size.

<span style="color:#000080; font-style:italic;">┃   rect          : 描画領域      [Rect]

<span style="color:#000080; font-style:italic;">┃                   Rectangle.

<span style="color:#000080; font-style:italic;">┃   string        : 描画文字列    [String]

<span style="color:#000080; font-style:italic;">┃                   Output text.

<span style="color:#000080; font-style:italic;">┃   align         : 文字整列形式  [Integer]

<span style="color:#000080; font-style:italic;">┃                   Alignment.

<span style="color:#000080; font-style:italic;">┃   frame_color   : 縁取り色      [Color]

<span style="color:#000080; font-style:italic;">┃                   Frame color.

<span style="color:#000080; font-style:italic;">┃ 周りを frame_color で縁取りした文字列を描画します。

<span style="color:#000080; font-style:italic;">┃ Draws a character string framed in 'frame_color'.

<span style="color:#000080; font-style:italic;">┃

<span style="color:#000080; font-style:italic;">┃ draw_shadow_text(x, y, width, height, string[, align, frame_color])

<span style="color:#000080; font-style:italic;">┃ draw_shadow_text(rect, string[, align, frame_color])

<span style="color:#000080; font-style:italic;">┃   x, y          : 描画先座標    [Integer]

<span style="color:#000080; font-style:italic;">┃                   Destination.

<span style="color:#000080; font-style:italic;">┃   width, height : 描画サイズ    [Integer]

<span style="color:#000080; font-style:italic;">┃                   Size.

<span style="color:#000080; font-style:italic;">┃   rect          : 描画領域      [Rect]

<span style="color:#000080; font-style:italic;">┃                   Rectangle.

<span style="color:#000080; font-style:italic;">┃   string        : 描画文字列    [String]

<span style="color:#000080; font-style:italic;">┃                   Output text.

<span style="color:#000080; font-style:italic;">┃   align         : 文字整列形式  [Integer]

<span style="color:#000080; font-style:italic;">┃                   Alignment.

<span style="color:#000080; font-style:italic;">┃   frame_color   : 縁取り色      [Color]

<span style="color:#000080; font-style:italic;">┃                   Frame color.

<span style="color:#000080; font-style:italic;">┃ 右下に影を落とした文字列を描画します。

<span style="color:#000080; font-style:italic;">┃ Draws a character string which drops shadow to lower right.

<span style="color:#000080; font-style:italic;">┃

<span style="color:#000080; font-style:italic;">┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

<span style="color:#000080; font-style:italic;">=end

 

$imported = {} if $imported == nil

$imported["FrameShadowText"] = true

 

#==============================================================================

# â–  Bitmap

#==============================================================================

 

class Bitmap

  #--------------------------------------------------------------------------

  # ● 縁取り文字描画

  #     x, y, width, height, string[, align, frame_color]

  #     rect, string[, align, frame_color]

  #--------------------------------------------------------------------------

  def draw_frame_text(*args)

    # 引数判定

    if args[0].is_a?(Rect)

      if args.size >= 2 && args.size <= 4

        # 引数を処理用のローカル変数へコピー

        x, y = args[0].x, args[0].y

        width, height = args[0].width, args[0].height

        string = args[1]

        align = args[2].equal?(nil) ? 0 : args[2]

        frame_color = args[3].equal?(nil) ? Color.new(0, 0, 0) : args[3]

      else

        # 引数が不正ならエラーを吐く

        raise(ArgumentError, "wrong number of arguments(#{args.size} of #{args.size < 2 ? 2 : 4})")

        return

      end

    else

      if args.size >= 5 && args.size <= 7

        # 引数を処理用のローカル変数へコピー

        x, y, width, height = args

        string = args[4]

        align = args[5].equal?(nil) ? 0 : args[5]

        frame_color = args[6].equal?(nil) ? Color.new(0, 0, 0) : args[6]

      else

        # 引数が不正ならエラーを吐く

        raise(ArgumentError, "wrong number of arguments(#{args.size} of #{args.size < 5 ? 5 : 7})")

        return

      end

    end

    # 元の色を保存

    origin_color = font.color.dup

    # 縁取り

    font.color = frame_color

    draw_text(x - 1, y - 1, width, height, string, align)

    draw_text(x - 1, y + 1, width, height, string, align)

    draw_text(x + 1, y - 1, width, height, string, align)

    draw_text(x + 1, y + 1, width, height, string, align)

    # 元の色に戻す

    font.color = origin_color

    draw_text(x, y, width, height, string, align)

  end

  #--------------------------------------------------------------------------

  # ● 影文字描画

  #     x, y, width, height, string[, align, shadow_color]

  #     rect, string[, align, shadow_color]

  #--------------------------------------------------------------------------

  def draw_shadow_text(*args)

    # 引数判定

    if args[0].is_a?(Rect)

      if args.size >= 2 && args.size <= 4

        # 引数を処理用のローカル変数へコピー

        x, y = args[0].x, args[0].y

        width, height = args[0].width, args[0].height

        string = args[1]

        align = args[2].equal?(nil) ? 0 : args[2]

        shadow_color = args[3].equal?(nil) ? Color.new(0, 0, 0) : args[3]

      else

        # 引数が不正ならエラーを吐く

        raise(ArgumentError, "wrong number of arguments(#{args.size} of #{args.size < 2 ? 2 : 4})")

        return

      end

    else

      if args.size >= 5 && args.size <= 7

        # 引数を処理用のローカル変数へコピー

        x, y, width, height = args

        string = args[4]

        align = args[5].equal?(nil) ? 0 : args[5]

        shadow_color = args[6].equal?(nil) ? Color.new(0, 0, 0) : args[6]

      else

        # 引数が不正ならエラーを吐く

        raise(ArgumentError, "wrong number of arguments(#{args.size} of #{args.size < 5 ? 5 : 7})")

        return

      end

    end

    # 元の色を保存

    origin_color = font.color.dup

    # 影描画

    font.color = shadow_color

    draw_text(x + 2, y + 2, width, height, string, align)

    # 元の色に戻す

    font.color = origin_color

    draw_text(x, y, width, height, string, align)

  end

end

 
Code:
 

<span style="color:#000080; font-style:italic;">=begin

<span style="color:#000080; font-style:italic;">These are strings to be used in JesseG88's Background

<span style="color:#000080; font-style:italic;">Message System.

<span style="color:#000080; font-style:italic;"> 

<span style="color:#000080; font-style:italic;">You can easily modify the strings or create new ones.

<span style="color:#000080; font-style:italic;">Just put them inside module STRINGS.

<span style="color:#000080; font-style:italic;"> 

<span style="color:#000080; font-style:italic;">Refer to [Background Message] for instructions.

<span style="color:#000080; font-style:italic;">=end

 

module STRINGS

  BLANK = ""

  HELLO1 = "If you were hoping to see World, preceded by Hello, too bad!"

  HELLO2 = "Putting that in would be detrimental to my sanity."

  RED_ALERT = "Red Alert!  Red Alert!  Enemy forces detected!"

  BATTLE_STATIONS = "All hands to battle stations!"

end

 
Code:
 

<span style="color:#000080; font-style:italic;">=begin

<span style="color:#000080; font-style:italic;">#=======================================

<span style="color:#000080; font-style:italic;"># ** Background Message System

<span style="color:#000080; font-style:italic;">#------------------------------------------------------------------------------

<span style="color:#000080; font-style:italic;"># JesseG88

<span style="color:#000080; font-style:italic;"># 1.0

<span style="color:#000080; font-style:italic;"># 2006-06-06

<span style="color:#000080; font-style:italic;">#=======================================

<span style="color:#000080; font-style:italic;"># This allows text to show up onscreen during the game

<span style="color:#000080; font-style:italic;"># without interrupting events.  All event processing, 

<span style="color:#000080; font-style:italic;"># including player input and "normal" messages will

<span style="color:#000080; font-style:italic;"># continue uninterrupted while text is displayed.  This

<span style="color:#000080; font-style:italic;"># is useful for cutscenes, minigames, etc.

<span style="color:#000080; font-style:italic;">#=======================================

<span style="color:#000080; font-style:italic;"> 

<span style="color:#000080; font-style:italic;">#=====================================

<span style="color:#000080; font-style:italic;">#  Instructions 

<span style="color:#000080; font-style:italic;">#=====================================

<span style="color:#000080; font-style:italic;"> 

<span style="color:#000080; font-style:italic;"> - Installation -

<span style="color:#000080; font-style:italic;">Place the strings file and the BMS file (this one) between

<span style="color:#000080; font-style:italic;">[Scene_Debug] and [Main].  Make sure to place the

<span style="color:#000080; font-style:italic;">strings ABOVE this file.

<span style="color:#000080; font-style:italic;"> 

<span style="color:#000080; font-style:italic;">In addition, make sure to install [KGC_FrameShadowText]

<span style="color:#000080; font-style:italic;">or you will get an error.

<span style="color:#000080; font-style:italic;"> 

<span style="color:#000080; font-style:italic;"> - Making text strings -

<span style="color:#000080; font-style:italic;">Go into [BMS Strings] and look at the existing strings to see what

<span style="color:#000080; font-style:italic;">they should look like.  You can create new strings easile by following

<span style="color:#000080; font-style:italic;">the format and keeping them in the strings module.

<span style="color:#000080; font-style:italic;"> 

<span style="color:#000080; font-style:italic;">For example:

<span style="color:#000080; font-style:italic;"> 

<span style="color:#000080; font-style:italic;">module STRINGS

<span style="color:#000080; font-style:italic;">  STRING_NAME = "Text inside string"

<span style="color:#000080; font-style:italic;">end

<span style="color:#000080; font-style:italic;"> 

<span style="color:#000080; font-style:italic;"> 

<span style="color:#000080; font-style:italic;">=end

#------------------------------------------------------------------------------

# * SDK Log Script

#------------------------------------------------------------------------------

SDK.log('Background Message System', 'JesseG88', '1.0', '2006-06-06')

#------------------------------------------------------------------------------

# Begin SDK Enabled Check

#------------------------------------------------------------------------------

if SDK.state('Background Message System') == true

  module BMS

    #Perform any customizations inside this module.

  

    #Windowskin Opacity

    WINDOW_OPACITY = 0

    

    #Upper Left Corner

    WINDOW_X1 = 0 

    WINDOW_Y1 = 0 #Set to 0 for top, 160 for middle, 320 for bottom.

  

    #Window Size

    WINDOW_X2 = 640

    WINDOW_Y2 = 160

  

    #Line 1 Settings

    LINE1_FONT_FACE = "Arial"

    LINE1_FONT_SIZE = 20

    LINE1_FONT_BOLD = true

    LINE1_FONT_ITALIC = false

    LINE1_FONT_COLOR = Color.new(255, 255, 255, 255)

    LINE1_FST_MODE = 0 # 0-Plain,  1-Frame,  2-Shadow

    LINE1_STRING = STRINGS::BLANK

  

    #Line 2 Settings

    LINE2_FONT_FACE = "Arial"

    LINE2_FONT_SIZE = 20

    LINE2_FONT_BOLD = true

    LINE2_FONT_ITALIC = false

    LINE2_FONT_COLOR = Color.new(255, 255, 255, 255)

    LINE2_FST_MODE = 0 # 0-Plain,  1-Frame,  2-Shadow

    LINE2_STRING = STRINGS::BLANK

  

    #Line 3 Settings

    LINE3_FONT_FACE = "Arial"

    LINE3_FONT_SIZE = 20

    LINE3_FONT_BOLD = true

    LINE3_FONT_ITALIC = false

    LINE3_FONT_COLOR = Color.new(255, 255, 255, 255)

    LINE3_FST_MODE = 0 # 0-Plain,  1-Frame,  2-Shadow

    LINE3_STRING = STRINGS::BLANK

  

    #Line 4 Settings

    LINE4_FONT_FACE = "Arial"

    LINE4_FONT_SIZE = 20

    LINE4_FONT_BOLD = true

    LINE4_FONT_ITALIC = false

    LINE4_FONT_COLOR = Color.new(255, 255, 255, 255)

    LINE4_FST_MODE = 0 # 0-Plain,  1-Frame,  2-Shadow

    LINE4_STRING = STRINGS::BLANK

  

    #Unless you know what you are doing,

    #do not modify anything below this line.

  end

 

  class Window_BGMessage < Window_Base

    #--------------------------------------------------------------------------

    # * Object Initialization

    #--------------------------------------------------------------------------

    def initialize

      super(BMS::WINDOW_X1, BMS::WINDOW_Y1, BMS::WINDOW_X2, BMS::WINDOW_Y2)

      self.contents = Bitmap.new(width - 32, height - 32)

      self.opacity = BMS::WINDOW_OPACITY

      refresh

    end

    #--------------------------------------------------------------------------

    # * Refresh

    #--------------------------------------------------------------------------

    def refresh

      self.contents.clear

      

      #Collect settings from BMS module, then print text.

      #Start of Line 1

      self.contents.font.name = BMS::LINE1_FONT_FACE

      self.contents.font.size = BMS::LINE1_FONT_SIZE

      self.contents.font.bold = BMS::LINE1_FONT_BOLD

      self.contents.font.italic = BMS::LINE1_FONT_ITALIC

      self.contents.font.color = BMS::LINE1_FONT_COLOR

      case BMS::LINE1_FST_MODE

      when 0

        self.contents.draw_text(0, 0, 608, 32, BMS::LINE1_STRING)

      when 1

        self.contents.draw_frame_text(0, 0, 608, 32, BMS::LINE1_STRING)

      when 2

        self.contents.draw_shadow_text(0, 0, 608, 32, BMS::LINE1_STRING)

      end

      #End of Line 1

    

      #Start of Line 2

      self.contents.font.name = BMS::LINE2_FONT_FACE

      self.contents.font.size = BMS::LINE2_FONT_SIZE

      self.contents.font.bold = BMS::LINE2_FONT_BOLD

      self.contents.font.italic = BMS::LINE2_FONT_ITALIC

      self.contents.font.color = BMS::LINE2_FONT_COLOR

      case BMS::LINE2_FST_MODE

      when 0

        self.contents.draw_text(0, 32, 608, 32, BMS::LINE2_STRING)

      when 1

        self.contents.draw_frame_text(0, 32, 608, 32, BMS::LINE2_STRING)

      when 2

        self.contents.draw_shadow_text(0, 32, 608, 32, BMS::LINE2_STRING)

      end

      #End of Line 2

    

      #Start of Line 3

      self.contents.font.name = BMS::LINE3_FONT_FACE

      self.contents.font.size = BMS::LINE3_FONT_SIZE

      self.contents.font.bold = BMS::LINE3_FONT_BOLD

      self.contents.font.italic = BMS::LINE3_FONT_ITALIC

      self.contents.font.color = BMS::LINE3_FONT_COLOR

      case BMS::LINE3_FST_MODE

      when 0

        self.contents.draw_text(0, 64, 608, 32, BMS::LINE3_STRING)

      when 1

        self.contents.draw_frame_text(0, 64, 608, 32, BMS::LINE3_STRING)

      when 2

        self.contents.draw_shadow_text(0, 64, 608, 32, BMS::LINE3_STRING)

      end

      #End of Line 3

    

      #Start of Line 4

      self.contents.font.name = BMS::LINE4_FONT_FACE

      self.contents.font.size = BMS::LINE4_FONT_SIZE

      self.contents.font.bold = BMS::LINE4_FONT_BOLD

      self.contents.font.italic = BMS::LINE4_FONT_ITALIC

      self.contents.font.color = BMS::LINE4_FONT_COLOR

      case BMS::LINE4_FST_MODE

      when 0

        self.contents.draw_text(0, 128, 608, 32, BMS::LINE4_STRING)

      when 1

        self.contents.draw_frame_text(0, 128, 608, 32, BMS::LINE4_STRING)

      when 2

        self.contents.draw_shadow_text(0, 128, 608, 32, BMS::LINE4_STRING)

      end

      #End of Line 4

    

    end #of def refresh

  end #of class Window_BGMessage

  

end #of if SDK.state('Background Message System') == true

#------------------------------------------------------------------------------

# End SDK Enabled Test

#------------------------------------------------------------------------------

 
Instructions

Installation

Get the SDK, and all the scripts listed above. Place them in the following order in the editor:
  • SDK
  • KGC_FrameShadowText
  • BMS Strings
  • Background Message
Setting up Strings
Go into BMS strings and look at the example strings that are already in there. Adding a new string should be ridiculously easy.

Formatting the window
Go into Background Message and look at module BMS. (Lines 49-101) Simply change the attributes to suit your needs. You can even change the attirbutes in-game. Just add "BMS::", without quotes, to an attribute in an in-game script. It should similar to this:
Code:
 

BMS::LINE1_FST_MODE = 1

BMS::LINE1_FONT_COLOR = Color.new(255, 0, 0, 255)

 
Making the message appear in-game
Run a script like this:
Code:
 

BMS::LINE1_STRING = STRINGS::HELLO1

BMS::LINE2_STRING = STRINGS::HELLO2

@BGMessage = Window_BGMessage.new

 
The line BMS::LINE1_STRING = STRINGS::HELLO1 binds a text string to a line. Change the blue to the line you want to set, and the red text to the string ID you want to use. Note that for very short strings, you may just want to set the string text in the command itself, as in
BMS::LINE1_STRING = "Aluxus"

The line @BGMessage = Window_BGMessage.new causes the message to appear onscreen.

Removing a message
Run this script:
Code:
 

@BGMessage.dispose
Note that if you want to change the message to display a different string, you will need to dispose the current message first before calling a new one. Otherwise, they will both show up at the same time and cause problems.

Compatibility
This script requires the SDK. It also needs KGC's Frame and Shadow Text script, which I included.

Bugs, Errors
If you call a message and dispose of it on a different page or event, you may get an error message. To avoid this, call the message and dispose of it on the same event page.

Credits and Thanks

SDK Team - SDK
KGC Software - Frame and Shadow Text script, as well as the idea of customization modules.

Author's Notes

This is the first script I have posted, so it may not be all that great.
I may post a demo later.
 
does it have to use the SDK ?
sorry to ask but i have mostly non SDK and this would make a good addition but would kill my other Scripts if i have to use the SDK (it screws literally everything)
 
Yeah, SDK-must is not good, as it decreases script usuability instead of increasing it ^_^ I'd also like to see a AMS-version to show text strings over close NPCs.
 
Simply remove the SDK lines. These lines...
Code:
#------------------------------------------------------------------------------
# * SDK Log Script
#------------------------------------------------------------------------------
SDK.log('Background Message System', 'JesseG88', '1.0', '2006-06-06')
#------------------------------------------------------------------------------
# Begin SDK Enabled Check
#------------------------------------------------------------------------------
if SDK.state('Background Message System') == true
And these.
Code:
end #of if SDK.state('Background Message System') == true
#------------------------------------------------------------------------------
# End SDK Enabled Test
#------------------------------------------------------------------------------
 
I Juss' gotta say - you are an amazing person. I've been trying to do something like this for a while now, but just don't have the brains - I hand it to you :D Now ive just got to put it in my game...hmmm....
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top