Galv’s Message Background V.1.3

Demo – Version 1.3 >

#------------------------------------------------------------------------------#
#  Galv's Message Background
#------------------------------------------------------------------------------#
#  For: RPGMAKER VX ACE
#  Version 1.3
#------------------------------------------------------------------------------#
#  2013-04-01 - version 1.2 - added option to disable script in battle
#  2013-02-10 - version 1.1 - dim and transparent settings work with image now
#  2012-12-02 - version 1.0 - release
#------------------------------------------------------------------------------#
#  This script displays an image file for a message background instead of using
#  the windowskin. If you are using Galv's Message Busts put this script ABOVE.
#
#  This image background will not stretch to fit, that's not it's purpose.
#  I encourage you to make your own message background images, the ones in the
#  demo are just quick examples!
#------------------------------------------------------------------------------#
#  INSTRUCTIONS:
#  Put in script list below Materials and above Main.
#
#  Read the instructions
#------------------------------------------------------------------------------#
#  SCRIPT CALL
#------------------------------------------------------------------------------#
#
#  msgbg("ImageName", y_offset)     # To change message background during game
#                                   # "ImageName" is the new file name to use
#                                   # y_offset is the new IMAGE_Y for that bg
#  EXAMPLE
#  msgbg("MsgImage", -98)
#
#------------------------------------------------------------------------------#

($imported ||= {})["Galvs_Message_Background"] = true
module Galv_Msgbg

#------------------------------------------------------------------------------#
#  SCRIPT SETTINGS
#------------------------------------------------------------------------------#

  # DEFAULT MESSAGE #

  MESSAGE_IMAGE = "MsgImage"   # Name of image in /Graphics/System to use for
                               # the message background.

  IMAGE_Y = -98                # Y offset of image

  DISABLE_SWITCH = 1   # Turn swith ON to disable image background

  DISABLE_IN_BATTLE = true  # Disable this script when in battle.

#------------------------------------------------------------------------------#
#  END SCRIPT SETTINGS
#------------------------------------------------------------------------------#

end

class Window_Message < Window_Base
  alias galv_msgbg_window_create_back_bitmap create_back_bitmap
  def create_back_bitmap
    @bg ||= Sprite.new
    if !$game_message.message_bg.nil?
      @bg.bitmap = Cache.system($game_message.message_bg)
      @current_bg = $game_message.message_bg
    end
    @bg.z = z - 1
    @bg.opacity = 0
    galv_msgbg_window_create_back_bitmap
  end

  alias galv_msgbg_window_dispose dispose
  def dispose
    galv_msgbg_window_dispose
    dispose_msgbg if !@bg.nil?
  end

  def dispose_msgbg
    @bg.dispose
    @bg.bitmap.dispose
  end

  alias galv_msgbg_window_update_back_sprite update_back_sprite
  def update_back_sprite
    if !$game_switches[Galv_Msgbg::DISABLE_SWITCH] && !$game_temp.msg_off
      update_msgbg if openness > 0
      @bg.opacity = 0 if openness == 0
    else
      galv_msgbg_window_update_back_sprite
      @bg.opacity = 0
    end
    @bg.update
    @back_sprite.update
  end

  def update_msgbg
    if $game_message.message_bg != @current_bg
      if !$game_message.message_bg.nil?
        @bg.bitmap = Cache.system($game_message.message_bg)
        @current_bg = $game_message.message_bg
      end
    end
    @bg.y = self.y + $game_message.message_bg_y
    case @background
    when 0; @bg.opacity = openness
    when 1; @bg.opacity = openness * 0.5
    when 2; @bg.opacity = 0
    end
    @back_sprite.visible = false
    self.opacity = 0
  end

end # Window_Message < Window_Base

class Game_Message
  attr_accessor :message_bg
  attr_accessor :message_bg_y

  alias galv_msgbg_message_initialize initialize
  def initialize
    galv_msgbg_message_initialize
    @message_bg = Galv_Msgbg::MESSAGE_IMAGE
    @message_bg_y = Galv_Msgbg::IMAGE_Y
  end
end # Game_Message

class Game_Temp
  attr_accessor :msg_off
end # Game_Temp

class Scene_Battle < Scene_Base
  alias galv_msgbg_sb_start start
  def start
    $game_temp.msg_off = true if Galv_Msgbg::DISABLE_IN_BATTLE
    galv_msgbg_sb_start
  end

  alias galv_msgbg_sb_terminate terminate
  def terminate
    $game_temp.msg_off = nil
    galv_msgbg_sb_terminate
  end
end # Scene_Battle < Scene_Base

class Game_Interpreter
  def msgbg(image,y_offset)
    $game_message.message_bg = image
    $game_message.message_bg_y = y_offset
  end
end # Game_Interpreter

Leave a comment

  1. I have some problems in battles and other scripts: (

    I do not speak English, so I don’t quite understand, but I translate with Google :)

    • I added a setting at the top of the script ‘DISABLE_IN_BATTLE’.
      If that setting is true then it will use default message windows in battles. Copy the script from this page again (not the demo, I have not updated it).

  2. Sorry to bother you, I found this error, I have activated the option “DISABLE_IN_BATTLE ‘. I get this:

    appears when I give ” run”

    Thanks

  3. Is there a way to make the picture (Show Picture) appear over the message box, I’ve been trying to tweak things but nothing seems to work, I’m a total noob at scripting.
    Long story short; Is there a way to change the priority of the message box image?

    • Look for where it says: @bg.z = z – 1
      change it to @bg.z = z + 1
      That will make the image appear above the text if that’s what you meant. Else you can try other values.

      • Thank you very much, it worked!
        Great script by the way and good luck with Pirate Rush, I can’t wait for it to be finished, It took me a long while to beat the Plant boss.

    • What you need to do now is check to see if a script is conflicting. Also try putting this script below any other message scripts you are using to see if it fixes the issue

  4. can you make a way to add the name of the npc? only put an customizable text and customizable coodinates to where the text will appear

      • can i change the background priority? i found an script that add name but the background appear in front of the name

      • Look in the script for where it says:
        @bg.z = z – 1
        and try changing that to something lower. Depends how the other script works if that will work or not.

  5. I seem to be having a problem with the script. When I add this script into my game I get the following error message upon starting up my game:

    Script ‘Game_Switches’ line 19: TypeError occurred
    can’t convert true into Integer

    I used the older version in the demo and it worked perfectly fine, but the newest version does not work. Any ideas?

    • Hmm, in your settings do you have
      DISABLE_SWITCH = 1

      Or the number 1 could be any number that refers to an in-game switch you use Control Switches to turn on and off. I think you might have put true there instead of a number?

      • Seems to of been my own mistake. I was treating the disable switch like your Busts script and getting rid of the number if I did not want it to be disabled by a switch. Not sure why it works in one, but not the other. Anyways I thank you for taking the time to look at my comment. :)

      • Actually the switch settings work the same way for both scripts. They must be numbers. Make the switch setting 0 if you don’t want to use it.

        One has another setting unrelated to switches which is true or false, though. Different setting type that required a true or false rather than number.

  6. if i combine the script you written on the message background and the bust.
    The bust will disappear when message background working. i don’t know why.

  7. Hello there, I have the following error:

    Script ‘Galv’s Message Background’ line 104: TypeError occurred.
    nil can’t be coerced into Fixnum

    anyone knows how to fix it???

  8. Hi Galv

    I tried to change the background image for books and, when I use the call script you wrote in the script, it doesn’t work. I put “msgbg(“MsgImage2″, -98)” and when I press Z, there is still the same background, the default one. How could I fix this?

    Thank you.

  9. I don’t know how to do any scripting and I feel confused. Do I copy and paste EVERYTHING here, or just select parts? Also, what does image_y mean?

    • As with any script you might try, copy the whole thing and put it below materials and above main in your script list.

      IMAGE_Y = -98 # Y offset of image

      the y value is the position of the image on the screen vertically. A good way to learn is to play around to see what it does.

  10. Thank you for this script, Galv, but I’ve unfortunately also come across a problem.

    When I activate a message box, the window skin appears first and then whatever background I’ve set in the script for the message box will appear for half a second after.

    Your script is the only one I have in my game aside from the default ones.

  11. If I use bigger resolution (640×480), the placement of message background become messed up… The bottom part of message background gets cut off, and if I change the Y offset, the text also changes position… Can you help?

    • The text should not change position if you change the IMAGE_Y setting (or use the y offset in the script call). It should only affect the position of the background image.

  12. Hi Galv, sorry to bother you, but i’ve got a weird issue with this script. When i use this combined with Killozapit – Cache Back (Found on the menu’s one) my image goes trasparent. Like this: http://puu.sh/kcuNv/6a51f0f735.jpg
    I think the script clean the image, and since i don’t get how it works, here i am. Do you know what the problem could be?

  13. Greetings Galv , pardom me if it has been already asked but I noticed that this script wasn’t compatible with “Yanfly Engine Ace – Ace Message System v1.05” .
    Isn’t there any possible way to make it work ?
    If not , then nevermind , I shall be at least grateful for your amazing scripts .
    Have a good day !

    • Try placing the plugins in a different order. For example, this plugin after Yanfly’s script.

      Not all functionality will be compatible but most should be.

  14. Hi Galv. I am very new to scripts, so I apologize if I’m being very nooby :P I put this scipt into the editor, changed the appropriate line to use my custom image but when I start the game is get this error;

    Script ‘Galv’s Message Background’ line 61: NameError occurred

    undefined method ‘create_back_bitmap’ for class ‘Window_Message’

    Any idea how to fix it? Thanks for the help.

    Kieran.

  15. Ah, I must have skip it haha. Thanks anyway. I figured out a way around by exported the default images and editing it in photoshop.

    Sorry for the waste of time :p

    Thanks.

    Kiearn.

  16. I tried using this script, but I was having issues that I just couldn’t seem to get around, so I tried downloading the demo. I opened it, and sure enough, it worked.

    I figured I’d try exporting the image you used for the example, uploading it into my own little test-game’s resource manager, and then just copy and paste the entire script without changing anything.
    … For some reason, I got the same error as I did before. Specifically with line 104, which someone else had an issue with, it seems.
    I placed the script below materials and above main, on a brand new, blank page. I also have your message bust system, and I actually tried placing it both above and below it, just in case I misunderstood which one was supposed to go on top. I have no other existing scripts. What the hell am doing wrong? I am in fact using Ace, by the way.

    • Unfortunately with not enough info, I don’t know what you are doing wrong without having the project to examine. The only thing I can do is offer a checklist that you can try to error trap:

      Errors Using VX/VX Ace Scripts


      These are checks I would do to work out the issue. Particularly start a new game and check for script conflicts (which I just re-read you didn’t have any other scripts).

      The demo download on this page used an old version, I have updated it now to use the most recent version that you could also copy from this page.

      • Thank you so much for the reply.

        Despite the fact that pretty much all I had done to my other project was import one walksprite, import one autotile, and a window to be used for other things like menus, the completely clean project did work out. Clearly something must be conflicting with it, then- but I haven’t the slightest clue what that could be.

  17. Sorry for troubling you ahaha
    I don’t know why but sometimes the script doesn’t work. When I enter a new map the image I’ve made for the Msg Bg doesn’t show up. I tried to mess up a little with the switch but it just doesn’t work.
    It’s prolly my fault btw

    • It could potentially be that you are turning ON the same switch id as the ‘Disable_Switch’ you specified in the script settings. (Note that switch might be changed in another plugin as well. Try changing which switch id it uses).

  18. hi galv! is it possible to change the font and font size while still using your message background script? i had previously changed my font and font size before using your script, and once i implemented the script, everything reverted back to a new default font and font size. thank you!