FG7 - Easy Pause Screen

Easy Pause Screen
By: FamilyGamer7
​
Introduction
Quick and easy way to implement a pause screen script. The script leverages the power of $game_switches to perform its action.

Features
The ability to change the - Pause Button / Pause Screen Picture / Game Switch to help fuel the Pause Screen script. Ideally provides more flexibility than using a static variable created within a defined method.

Screenshots
- Not Needed -

Script
Spoiler: FG7 - Easy Pause Screen
Ruby:
#==============================================================================
# Title: Easy Pause Screen
# Author: FamilyGamer7 (FG7)
# Version: 1.0
# Engine: RPG Maker VX Ace
#==============================================================================
# ** Change Log |
# ---------------
# 1.0 => Created Script
#==============================================================================
# ** Description |
# ----------------
# Quick and easy way to implement a pause screen script. The script leverages
# the power of $game_switches to perform its action.
#==============================================================================
# ** Terms of Use |
# -----------------
# * Free to use in non-commercial projects and commercial projects
# * Feel free to modify and improve the script. Credit is still required.
# * Credit FamilyGamer7
#==============================================================================
# ** Usage |
# ----------
# - The "Pause_Button" allows you to change any key for the triger to pause
#   the screen.
#
# - The "Pause_Screen_Picture" allows you to specify the name of the image you
#   want to use once the game is paused.
#
# - The "Game_Switch_Number" allows to set any number value for the game switch
#   that is being used. Ideally provides more flexibility than using a static
#   variable created within a defined method.
#==============================================================================
# ** Notes |
# ----------
# The Pause screen is designed to not work with the Title Screen (Scene_Title).
# The script also stops the playtime count when the pause screen is active.
#
# List of Keys: /  :A :B :C :X :Y :Z :L :R :F5 :F6 :F7 :F8 :F9
#               /   :DOWN :LEFT :RIGHT :UP :SHIFT :CTRL :ALT
#==============================================================================

#==============================================================================
# ** Module: FG7::Easy_Pause_Screen
#------------------------------------------------------------------------------
#  This modules creates a static variable to be used within the script.
#==============================================================================

module FG7
  module Easy_Pause_Screen
 
#==============================================================================
# -------------------- ALLOWED TO EDIT BELOW THIS LINE ---------------------- #
#==============================================================================
 
    # Sets the pause button used to trigger the game frozen/paused
    Pause_Button = :X
 
    # Sets the pause background used once the pause is triggered
    # (Image to be placed in "Graphic/Pictures/" folder)
    Pause_Screen_Picture = "Pause_Background"
 
    # Sets the game switch number used for triggering the pause action
    Game_Switch_Number = 19
 
#==============================================================================
# ---------- DO NOT EDIT BELOW THIS LINE (FOR ADVANCED USERS) --------------- #
#==============================================================================
 
  end
end

#==============================================================================
# ** Game_System
#------------------------------------------------------------------------------
#  This class handles system data. It saves the disable state of saving and
# menus. Instances of this class are referenced by $game_system.
#==============================================================================

class Game_System
  #--------------------------------------------------------------------------
  # * New Method: update_pause (Checks if pause has been triggered)
  #--------------------------------------------------------------------------
  def update_pause
    # Add current frame count into count variable
    @update_frame_count = Graphics.frame_count
    # Creates Pause Picture bitmap to overlay on screen once pause is triggered
    # (The "z" value ensure nothing is above the pause screen)
    @pause_screen_pic = Sprite.new
    @pause_screen_pic.bitmap = Cache.picture(FG7::Easy_Pause_Screen::Pause_Screen_Picture)
    @pause_screen_pic.z = 5000
    # If the game switch is not met - do a "return"
    return @pause_screen_pic.dispose if $game_switches[FG7::Easy_Pause_Screen::Game_Switch_Number] != true
    # Loop and break if game switch is not met and properly unpauses screen
    loop do
      # Checks if the game switch is not met within the loop to dispose image
      if $game_switches[FG7::Easy_Pause_Screen::Game_Switch_Number] != true
        @pause_screen_pic.dispose
      end
      # Breaks if the game switch is not met and updates screen to normal
      break if $game_switches[FG7::Easy_Pause_Screen::Game_Switch_Number] != true
      $game_switches[FG7::Easy_Pause_Screen::Game_Switch_Number] = $game_switches[FG7::Easy_Pause_Screen::Game_Switch_Number] == true ? false : true if Input.trigger?(FG7::Easy_Pause_Screen::Pause_Button)
      # Add count variable back into frame count
      Graphics.frame_count = @update_frame_count
      # Re-update Input & Graphics
      Input.update
      Graphics.update
    end
  end
end

#==============================================================================
# ** Scene_Base
#------------------------------------------------------------------------------
#  This is a super class of all scenes within the game.
#==============================================================================

class Scene_Base
  #--------------------------------------------------------------------------
  # * Alias Method: Frame Update
  #--------------------------------------------------------------------------
  alias :fg7_easy_pause_screen_update :update
  def update
    fg7_easy_pause_screen_update
    # Performs the updating of the pause screen if conditions are met
    # (Pause is not performed on the on Title Screen)
    if !SceneManager::scene_is?(Scene_Battle) && !SceneManager::scene_is?(Scene_Title)
      $game_system.update_pause
      $game_switches[FG7::Easy_Pause_Screen::Game_Switch_Number] = $game_switches[FG7::Easy_Pause_Screen::Game_Switch_Number] == true ? false : true if Input.trigger?(FG7::Easy_Pause_Screen::Pause_Button)
    end
  end
end

#==============================================================================
# ** Scene_Battle
#------------------------------------------------------------------------------
#  This class performs battle screen processing.
#==============================================================================

class Scene_Battle < Scene_Base
  #--------------------------------------------------------------------------
  # * Alias Method: Update Frame (Basic)
  #--------------------------------------------------------------------------
  alias :fg7_easy_pause_screen_update_basic :update_basic
  def update_basic
    fg7_easy_pause_screen_update_basic
    # Performs the updating of the pause screen if conditions are met
    $game_system.update_pause
    $game_switches[FG7::Easy_Pause_Screen::Game_Switch_Number] = $game_switches[FG7::Easy_Pause_Screen::Game_Switch_Number] == true ? false : true if Input.trigger?(FG7::Easy_Pause_Screen::Pause_Button)
  end
end

How to Use
Add this script in the script editor under in the "Materials" section and above "Main Process".
The instructions and setup for the script are held within the script header itself. No need to repeat here.

Terms of Use
- Free to use in non-commercial projects and commercial projects
- Feel free to modify and improve the script. Credit is still required.
- Credit FamilyGamer7

Original thread: https://forums.rpgmakerweb.com/threads/fg7-easy-pause-screen.144477/