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.

Message after loading

This is only a small question: I use the default load screen, but i want to know how to do the followong: when the player chooses a game to load, there should be a messagebox showing, just one message box with one sentence, before the game loads. The messagebox should be centered on the screen. And of course it can be just a windowbox as well. Anyone know how to do this?
 
Here you go, this should work. Just change the 'Text' option at the top of the script to what you want and a box with text should pop and then go away after you load a save file:

Code:
#==============================================================================

# Title: Game Load Message | Version 1.0

# Author: TheLaw [aka. TheScripter]

# Requester: gRaViJa [@ hbgames.org]

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

 

Text = "Loading..."

 

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

# ** Scene_File

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

#  This is a superclass for the save screen and load screen.

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

 

class Scene_File

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

  # * Main Processing

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

  def main

    @message_window = Window_LoadMessage.new

    # Make help window

    @help_window = Window_Help.new

    @help_window.set_text(@help_text)

    # Make save file window

    @savefile_windows = []

    for i in 0..3

      @savefile_windows.push(Window_SaveFile.new(i, make_filename(i)))

    end

    # Select last file to be operated

    @file_index = $game_temp.last_file_index

    @savefile_windows[@file_index].selected = true

    # Execute transition

    Graphics.transition

    # Main loop

    loop do

      # Update game screen

      Graphics.update

      # Update input information

      Input.update

      # Frame update

      update

      # Abort loop if screen is changed

      if $scene != self

        break

      end

    end

    # Prepare for transition

    Graphics.freeze

    # Dispose of windows

    @help_window.dispose

    @message_window.dispose

    for i in @savefile_windows

      i.dispose

    end

  end

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

  # * Frame Update

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

  def update

    # Update windows

    @help_window.update

    @message_window.update

    for i in @savefile_windows

      i.update

    end

    # If C button was pressed

    if Input.trigger?(Input::C)

      # Call method: on_decision (defined by the subclasses)

      on_decision(make_filename(@file_index))

      $game_temp.last_file_index = @file_index

      return

    end

    # If B button was pressed

    if Input.trigger?(Input::B)

      # Call method: on_cancel (defined by the subclasses)

      on_cancel

      return

    end

    # If the down directional button was pressed

    if Input.repeat?(Input::DOWN)

      # If the down directional button pressed down is not a repeat,

      # or cursor position is more in front than 3

      if Input.trigger?(Input::DOWN) or @file_index < 3

        # Play cursor SE

        $game_system.se_play($data_system.cursor_se)

        # Move cursor down

        @savefile_windows[@file_index].selected = false

        @file_index = (@file_index + 1) % 4

        @savefile_windows[@file_index].selected = true

        return

      end

    end

    # If the up directional button was pressed

    if Input.repeat?(Input::UP)

      # If the up directional button pressed down is not a repeat、

      # or cursor position is more in back than 0

      if Input.trigger?(Input::UP) or @file_index > 0

        # Play cursor SE

        $game_system.se_play($data_system.cursor_se)

        # Move cursor up

        @savefile_windows[@file_index].selected = false

        @file_index = (@file_index + 3) % 4

        @savefile_windows[@file_index].selected = true

        return

      end

    end

  end

end

 

 

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

# ** Scene_Load

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

#  This class performs load screen processing.

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

 

class Scene_Load < Scene_File

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

  # * Decision Processing

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

  def on_decision(filename)

    @wait_count = 1000

    # If file doesn't exist

    unless FileTest.exist?(filename)

      # Play buzzer SE

      $game_system.se_play($data_system.buzzer_se)

      return

    end

    @message_window.visible = true

    # Play load SE

    $game_system.se_play($data_system.load_se)

    # Read save data

    file = File.open(filename, "rb")

    read_save_data(file)

    loop do

      @wait_count -= 1

      break if @wait_count == 0

    end

    if @wait_count == 0

      file.close

      # Restore BGM and BGS

      $game_system.bgm_play($game_system.playing_bgm)

      $game_system.bgs_play($game_system.playing_bgs)

      # Update map (run parallel process event)

      $game_map.update

      # Switch to map screen

      $scene = Scene_Map.new

    end

  end

end

 

 

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

# ** Window_LoadMessage

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

#  This window displays the loading message

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

 

class Window_LoadMessage < Window_Base

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

  # * Object Initialization

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

  def initialize

    super(320 - ((Text.size * 15) / 2), 208, Text.size * 15, 96)

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

    refresh

    self.visible = false

    self.z = 999

  end

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

  # * Refresh

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

  def refresh

    self.contents.clear

    self.contents.font.color = system_color

    self.contents.draw_text(0, 0, Text.length * 10, 64, Text, 2)

  end

end

 

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

# 

# *** END OF SCRIPT ***

#

#==============================================================================
 
Awesome, thanks :) I'll be testing this out tomorrow, need to catch some sleep before aceing an exam tomorrow morning :p

edit: i'll probaply find this myself too, but is there a way to control how long the message is shown? Or to show it untill the player press enter? :)
 
Alright, I added a wait time at the top that you can change, and good luck on that exam!

Code:
#==============================================================================

# Title: Game Load Message | Version 1.0

# Author: TheLaw [aka. TheScripter]

# Requester: gRaViJa [@ hbgames.org]

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

 

Text = "Loading..."

Wait_Time = 1000

 

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

# ** Scene_File

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

#  This is a superclass for the save screen and load screen.

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

 

class Scene_File

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

  # * Alias Listing

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

  alias scripter_scene_file_update update

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

  # * Main Processing

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

  def main

    @message_window = Window_LoadMessage.new

    # Make help window

    @help_window = Window_Help.new

    @help_window.set_text(@help_text)

    # Make save file window

    @savefile_windows = []

    for i in 0..3

      @savefile_windows.push(Window_SaveFile.new(i, make_filename(i)))

    end

    # Select last file to be operated

    @file_index = $game_temp.last_file_index

    @savefile_windows[@file_index].selected = true

    # Execute transition

    Graphics.transition

    # Main loop

    loop do

      # Update game screen

      Graphics.update

      # Update input information

      Input.update

      # Frame update

      update

      # Abort loop if screen is changed

      if $scene != self

        break

      end

    end

    # Prepare for transition

    Graphics.freeze

    # Dispose of windows

    @help_window.dispose

    @message_window.dispose

    for i in @savefile_windows

      i.dispose

    end

  end

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

  # * Frame Update

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

  def update

    @message_window.update

    scripter_scene_file_update

  end

end

 

 

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

# ** Scene_Load

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

#  This class performs load screen processing.

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

 

class Scene_Load < Scene_File

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

  # * Decision Processing

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

  def on_decision(filename)

    @wait_count = Wait_Time

    # If file doesn't exist

    unless FileTest.exist?(filename)

      # Play buzzer SE

      $game_system.se_play($data_system.buzzer_se)

      return

    end

    @message_window.visible = true

    # Play load SE

    $game_system.se_play($data_system.load_se)

    # Read save data

    file = File.open(filename, "rb")

    read_save_data(file)

    # Initialize loop count

    @loop_count = 0

    # Loop

    loop do

      # Add 1 to loop count

      @loop_count += 1

      # If 100 event commands ran

      if @loop_count > 100

        # Call Graphics.update for freeze prevention

        Graphics.update

        @loop_count = 0

      end

      if @wait_count > 0

        # Decrease wait count

        @wait_count -= 1

        if @wait_count == 0

          break

        end

      end

    end

    file.close

    # Restore BGM and BGS

    $game_system.bgm_play($game_system.playing_bgm)

    $game_system.bgs_play($game_system.playing_bgs)

    # Update map (run parallel process event)

    $game_map.update

    # Switch to map screen

    $scene = Scene_Map.new

  end

end

 

 

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

# ** Window_LoadMessage

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

#  This window displays the loading message

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

 

class Window_LoadMessage < Window_Base

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

  # * Object Initialization

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

  def initialize

    super(320 - ((Text.size * 15) / 2), 208, Text.size * 15, 96)

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

    refresh

    self.visible = false

    self.z = 999

  end

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

  # * Refresh

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

  def refresh

    self.contents.clear

    self.contents.font.color = system_color

    self.contents.draw_text(0, 0, Text.length * 10, 64, Text, 2)

  end

end

 

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

# 

# *** END OF SCRIPT ***

#

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

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