Chaos Project

RPG Maker => RPG Maker Scripts => RMXP Script Database => Topic started by: Zeriab on May 22, 2009, 05:08:26 am

Title: [XP] F12 Pause with image script
Post by: Zeriab on May 22, 2009, 05:08:26 am
F12 Pause with image script
Authors: Zeriab
Version: 1.1
Type: Pause system, F12 reset prevention
Key Term: Misc System



Introduction

This script changes the functionality of the F12 button so it toggles pause on and off instead of resetting the game.
It displays an image while paused.



Screenshots

(http://bb.xieke.com/files/f12_pause.jpg)


Script

Spoiler: ShowHide
#==============================================================================
# ** Pausing with F12
#------------------------------------------------------------------------------
# Zeriab
# Version 1.1
# 2009-05-25 (Year-Month-Day)
#------------------------------------------------------------------------------
# * Version History :
#
#   Version 1.0 -------------------------------------------------- (2009-05-22)
#   - First release
#
#   Version 1.1 -------------------------------------------------- (2009-05-25)
#   - The pause image now appears immediately when F12 is pressed.
#   - Transitions are cut short rather than restarted when F12 is pressed.
#------------------------------------------------------------------------------
# * Description :
#
#   This script changes the functionality of pressing F12 during the game
#   from resetting the game to (un)pausing the game. A picture is displayed
#   while the game is paused. (Having a picture is optional)
#------------------------------------------------------------------------------
# * License :
#
#   Copyright (C) 2009  Zeriab
#
#   This program is free software: you can redistribute it and/or modify
#   it under the terms of the GNU Lesser Public License as published by
#   the Free Software Foundation, either version 3 of the License, or
#   (at your option) any later version.
#
#   This program is distributed in the hope that it will be useful,
#   but WITHOUT ANY WARRANTY; without even the implied warranty of
#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#   GNU Lesser Public License for more details.
#
#   For the full license see <http://www.gnu.org/licenses/>
#   The GNU General Public License: http://www.gnu.org/licenses/gpl.txt
#   The GNU Lesser General Public License: http://www.gnu.org/licenses/lgpl.txt
#------------------------------------------------------------------------------
# * Compatibility :
#
#   Is most likely not compatible with other F12 prevention scripts.
#------------------------------------------------------------------------------
# * Instructions :
#
#   Place this script anywhere above main.
#   The image file 'pause' present in Graphics/Pictures is used.
#   Note: No picture is shown if there is no 'pause' in Graphics/Pictures.
#==============================================================================

#=============================================================================
# ** Reset class (because it won't be defined until F12 is pressed otherwise)
#=============================================================================
class Reset < Exception
 
end
#=============================================================================
# ** Module Graphics
#=============================================================================
module Graphics
  class << self
    #-------------------------------------------------------------------------
    # * Aliases Graphics.update and Graphics.transition
    #-------------------------------------------------------------------------
    unless self.method_defined?(:zeriab_f12_pause_update)
      alias_method(:zeriab_f12_pause_update, :update)
      alias_method(:zeriab_f12_pause_transition, :transition)
    end
    #-------------------------------------------------------------------------
    # Change the update method so F12 toggles pause
    #-------------------------------------------------------------------------
    def update(*args)
      # Try to update normally
      begin
        zeriab_f12_pause_update(*args)
        return
      rescue Reset
        # Do nothing
      end
      # F12 has been pressed
      done = false
      # Store frame count
      frame_count = Graphics.frame_count
      # Show pause image
      @sprite = Sprite.new
      @sprite.z = 9999
      begin
        @sprite.bitmap = RPG::Cache.picture('pause')
      rescue
        @sprite.bitmap = Bitmap.new(32,32)
      end
      # Keep trying to do the update
      while !done
        begin
          zeriab_f12_pause_update(*args)
          done = true
        rescue Reset
          # Do Nothing
        end
      end
      # F12 has been released, update until it is pressed again
      while done
        begin
          zeriab_f12_pause_update(*args)
        rescue Reset
          done = false
        end
      end
      # F12 has been pressed, keep trying to update
      while !done
        begin
          zeriab_f12_pause_update(*args)
          done = true
        rescue Reset
          # Do nothing
        end
      end
      # F12 has been released, dispose pause image
      @sprite.dispose
      # Set proper frame count
      Graphics.frame_count = frame_count
    end
    #-------------------------------------------------------------------------
    # Changes the transition so it is cut short if F12 is pressed
    #-------------------------------------------------------------------------
    def transition(*args)
      done = false
      # Keep trying to do the transition
      while !done
        begin
          zeriab_f12_pause_transition(*args)
          done = true
        rescue Reset
          # Set transition length to 0 frames.
          args[0] = 0
        end
      end
    end
  end
end



Instructions

Copy+paste the script into the script editor. (Unsure? See this tutorial (http://rmrk.net/index.php/topic,263.0.html))
Import picture named pause to Graphics/Pictures. You can use the example picture below for trying it out.

(http://bb.xieke.com/files/pause.png)


Compatibility

Will most likely not work together with other scripts changing the functionality of the F12 button.


Credits and Thanks

Credits goes to Zeriab for writing the script and making the Paused picture.
Thanks to sixdd for suggesting pause toggling and showing a pause image.
Thanks goes to Kiriashi for inspiration on cutting the transitions short.



Author's Notes

If F12 is pressed during a transition the transition is cut short.
You can use the pause image and modify it any way you like. You don't have to provide credits or anything.
Note that it does NOT work on VX.

License: ShowHide
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU Lesser Public License for more details.

For the full license see <http://www.gnu.org/licenses/>
The GNU General Public License: http://www.gnu.org/licenses/gpl.txt
The GNU Lesser General Public License: http://www.gnu.org/licenses/lgpl.txt
Title: Re: [XP] F12 Pause with image script
Post by: Blizzard on May 22, 2009, 05:17:08 am
So I am not allowed to credit your for using your override of F12? ._.
Title: Re: [XP] F12 Pause with image script
Post by: Zeriab on May 22, 2009, 09:49:06 am
You are perfectly allowed to credit me ^_^
Just don't put the it on the features list.

On another note I believe this script is unconvertible to VX
Title: Re: [XP] F12 Pause with image script
Post by: legacyblade on May 22, 2009, 11:12:19 am
Is this compatible with all scripts? It sounds like it should be, but I'm just asking.
Title: Re: [XP] F12 Pause with image script
Post by: Zeriab on May 22, 2009, 11:21:43 am
Probably not other F12 prevention scripts. Other than that it should compatible. There is a higher chance of it being compatible than with most other scripts.

*hugs*
Title: Re: [XP] F12 Pause with image script
Post by: legacyblade on May 22, 2009, 12:12:04 pm
So theoretically, would it be possible to have a very LONG evented cutscene, and pause mid-scene?
Title: Re: [XP] F12 Pause with image script
Post by: Starrodkirby86 on May 22, 2009, 06:28:48 pm
Why don't you try, Legacy? Darkness Rebirth is totally crying out for a test run with this.

(Obligatory question that should be asked)
What if I don't want to use F12 as a Pause? How would I change that key to something else...such as erm, Pause/Break or F4?
Title: Re: [XP] F12 Pause with image script
Post by: Kagutsuchi on May 22, 2009, 06:45:00 pm
Quintessence is in desperate need of this script imo :P Thought you must also be able to save and turn off the game in the middle of the cutscene and continue from there later :P
Title: Re: [XP] F12 Pause with image script
Post by: legacyblade on May 22, 2009, 07:30:57 pm
Quote from: Kagutsuchi on May 22, 2009, 06:45:00 pm
Quintessence is in desperate need of this script imo :P Thought you must also be able to save and turn off the game in the middle of the cutscene and continue from there later :P


That is the game I was wondering for. I'd love that feature in quintessence.
Quote from: Curly Brace (SRK86) on May 22, 2009, 06:28:48 pm
Why don't you try, Legacy? Darkness Rebirth is totally crying out for a test run with this.

(Obligatory question that should be asked)
What if I don't want to use F12 as a Pause? How would I change that key to something else...such as erm, Pause/Break or F4?


If my RMXP comp was up and running, I would have.
Title: Re: [XP] F12 Pause with image script
Post by: Zeriab on May 23, 2009, 07:14:57 am
Yes, you can pause in cut scenes regardless of their length. The only place you won't be able to pause is during transitions from map to map. (You can still hold F12 down, but it's only paused while you hold the button down during transitions.
As for saving the game while paused the answer is no. You won't be able to do that with this script although you are free to modify this script for this purpose if you like.

@Curly Brace:
When F12 is pressed Graphics.update throw an exception. I am handling this exception to give the toggle pause feel.
Since only F12 makes Graphics.update throw the Reset exception it cannot be easily changed to use other key-presses.
If you want to use other keys to pause I would suggest messing around with the Input module rather than the Graphics module:

#=============================================================================
# ** Module Input
#=============================================================================
module Input
  class << self
    #-------------------------------------------------------------------------
    # * Aliases Graphics.update and Graphics.transition
    #-------------------------------------------------------------------------
    unless self.method_defined?(:zeriab_pause_update)
      alias_method(:zeriab_pause_update, :update)
    end
    def update(*args)
      zeriab_pause_update(*args)
      return unless trigger?(F6)
      # Store frame count
      frame_count = Graphics.frame_count
      # Show pause image
      @sprite = Sprite.new
      @sprite.z = 9999
      begin
        @sprite.bitmap = RPG::Cache.picture('pause')
      rescue
        @sprite.bitmap = Bitmap.new(32,32)
      end
      # Update once so the trigger doesn't count.
      zeriab_pause_update(*args)
      # Update until trigger
      while !trigger?(F6)
        zeriab_pause_update(*args)
        Graphics.update
      end
      # Dispose pause image
      @sprite.dispose
      # Set proper frame count
      Graphics.frame_count = frame_count
    end
  end
end


This will work for the buttons specified in help file.
QuoteDOWN LEFT RIGHT UP
Numbers corresponding to the directions down, left, right, and up.

A B C X Y Z L R
Numbers corresponding to the various controller buttons.

SHIFT CTRL ALT
Numbers directly corresponding to the keyboard's SHIFT, CTRL, and ALT keys.

F5 F6 F7 F8 F9
Numbers corresponding to the keyboard's function keys. The other function keys are reserved by the system and cannot be obtained.


If you want to user other keys I would suggest finding an input script to your liking and modifying this script to accommodate to the input script you choose.

*hugs*
- Zeriab
Title: Re: [XP] F12 Pause with image script
Post by: Zeriab on May 25, 2009, 10:06:31 am
I have updated the script so the pause image appear immediately and transitions are cut short when pressing F12.
I have changed the Terms of Use to LGPL.

Here's the pause script if you want other inputs where I added a PAUSE_BUTTON constant so it's easier to see where to change should you want a different button.
#==============================================================================
# ** Pause with image
#------------------------------------------------------------------------------
# Zeriab
# Version 1.0
# 2009-05-23 (Year-Month-Day)
#------------------------------------------------------------------------------
# * Description :
#
#   This script changes the functionality of pressing F12 during the game
#   from resetting the game to (un)pausing the game. A picture is displayed
#   while the game is paused. (Having a picture is optional)
#------------------------------------------------------------------------------
# * License :
#
#   Copyright (C) 2009  Zeriab
#
#   This program is free software: you can redistribute it and/or modify
#   it under the terms of the GNU Lesser Public License as published by
#   the Free Software Foundation, either version 3 of the License, or
#   (at your option) any later version.
#
#   This program is distributed in the hope that it will be useful,
#   but WITHOUT ANY WARRANTY; without even the implied warranty of
#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#   GNU Lesser Public License for more details.
#
#   For the full license see <http://www.gnu.org/licenses/>
#   The GNU General Public License: http://www.gnu.org/licenses/gpl.txt
#   The GNU Lesser General Public License: http://www.gnu.org/licenses/lgpl.txt
#------------------------------------------------------------------------------
# * Compatibility :
#
#   Is most likely not compatible with other pause scripts.
#------------------------------------------------------------------------------
# * Instructions :
#
#   Place this script anywhere above main.
#   The image file 'pause' present in Graphics/Pictures is used.
#   Note: No picture is shown if there is no 'pause' in Graphics/Pictures.
#==============================================================================

#=============================================================================
# ** Module Input
#=============================================================================
module Input
  class << self
    PAUSE_BUTTON = F6
    #-------------------------------------------------------------------------
    # * Aliases Graphics.update and Graphics.transition
    #-------------------------------------------------------------------------
    unless self.method_defined?(:zeriab_pause_update)
      alias_method(:zeriab_pause_update, :update)
    end
    def update(*args)
      zeriab_pause_update(*args)
      return unless trigger?(PAUSE_BUTTON)
      # Store frame count
      frame_count = Graphics.frame_count
      # Show pause image
      @sprite = Sprite.new
      @sprite.z = 9999
      begin
        @sprite.bitmap = RPG::Cache.picture('pause')
      rescue
        @sprite.bitmap = Bitmap.new(32,32)
      end
      # Update once so the trigger doesn't count.
      zeriab_pause_update(*args)
      # Update until trigger
      while !trigger?(PAUSE_BUTTON)
        zeriab_pause_update(*args)
        Graphics.update
      end
      # Dispose pause image
      @sprite.dispose
      # Set proper frame count
      Graphics.frame_count = frame_count
    end
  end
end


*hugs*
- Zeriab
Title: Re: [XP] F12 Pause with image script
Post by: Calintz on May 25, 2009, 05:21:06 pm
Haha, dude ...
This is the shit, Lol.

I love the more simple scripts that add features that EVERY game should have in them.
Title: Re: [XP] F12 Pause with image script
Post by: Fantasist on May 28, 2009, 11:30:04 am
You never seem to amaze me Zeriab :up:
Title: Re: [XP] F12 Pause with image script
Post by: Reno-s--Joker on June 03, 2009, 05:13:33 am
Is it just me or is this freaking amazing.

I'm a fan. Seriously. Have I mentioned that before?
Title: Re: [XP] F12 Pause with image script
Post by: Zeriab on June 06, 2009, 05:22:01 am
I am glad you like it and your nice words warm my heart <3

If you use Cowlol's FMOD Ex Audio Module Rewrite (http://www.rmxp.org/forums/viewtopic.php?f=11&t=55486) then you can use this code to pause both background music and background sounds. Note that it will not pause Music Effects and Sound Effects.
#==============================================================================
# ** Pausing with F12 which uses the FMOD Ex Audio Module to pause the background music and sound
#------------------------------------------------------------------------------
# Zeriab
# Version 1.1b
# 2009-06-01 (Year-Month-Day)
#------------------------------------------------------------------------------
# * Version History :
#
#   Version 1.0 -------------------------------------------------- (2009-05-22)
#   - First release
#
#   Version 1.1 -------------------------------------------------- (2009-05-25)
#   - The pause image now appears immediately when F12 is pressed.
#   - Transitions are cut short rather than restarted when F12 is pressed.
#
#   Version 1.1b ------------------------------------------------- (2009-06-01)
#   - The FMOD Audio module is used to pause the background music and sound
#------------------------------------------------------------------------------
# * Description :
#
#   This script changes the functionality of pressing F12 during the game
#   from resetting the game to (un)pausing the game. A picture is displayed
#   while the game is paused. (Having a picture is optional)
#------------------------------------------------------------------------------
# * License :
#
#   Copyright (C) 2009  Zeriab
#
#   This program is free software: you can redistribute it and/or modify
#   it under the terms of the GNU Lesser Public License as published by
#   the Free Software Foundation, either version 3 of the License, or
#   (at your option) any later version.
#
#   This program is distributed in the hope that it will be useful,
#   but WITHOUT ANY WARRANTY; without even the implied warranty of
#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#   GNU Lesser Public License for more details.
#
#   For the full license see <http://www.gnu.org/licenses/>
#   The GNU General Public License: http://www.gnu.org/licenses/gpl.txt
#   The GNU Lesser General Public License: http://www.gnu.org/licenses/lgpl.txt
#------------------------------------------------------------------------------
# * Compatibility :
#
#   Is most likely not compatible with other F12 prevention scripts.
#------------------------------------------------------------------------------
# * Instructions :
#
#   Place this script anywhere above main.
#   The image file 'pause' present in Graphics/Pictures is used.
#   Note: No picture is shown if there is no 'pause' in Graphics/Pictures.
#==============================================================================

#=============================================================================
# ** Reset class (because it won't be defined until F12 is pressed otherwise)
#=============================================================================
class Reset < Exception

end
#=============================================================================
# ** Module Graphics
#=============================================================================
module Graphics
  class << self
    #-------------------------------------------------------------------------
    # * Aliases Graphics.update and Graphics.transition
    #-------------------------------------------------------------------------
    unless self.method_defined?(:zeriab_f12_pause_update)
      alias_method(:zeriab_f12_pause_update, :update)
      alias_method(:zeriab_f12_pause_transition, :transition)
    end
    #-------------------------------------------------------------------------
    # Change the update method so F12 toggles pause
    #-------------------------------------------------------------------------
    def update(*args)
      # Try to update normally
      begin
        zeriab_f12_pause_update(*args)
        return
      rescue Reset
        # Do nothing
      end
      # F12 has been pressed
      $game_system.bgm_memorize
      $game_system.bgm_stop
      $game_system.bgs_memorize
      $game_system.bgs_stop
      done = false
      # Store frame count
      frame_count = Graphics.frame_count
      # Show pause image
      @sprite = Sprite.new
      @sprite.z = 9999
      begin
        @sprite.bitmap = RPG::Cache.picture('pause')
      rescue
        @sprite.bitmap = Bitmap.new(32,32)
      end
      # Keep trying to do the update
      while !done
        begin
          zeriab_f12_pause_update(*args)
          done = true
        rescue Reset
          # Do Nothing
        end
      end
      # F12 has been released, update until it is pressed again
      while done
        begin
          zeriab_f12_pause_update(*args)
        rescue Reset
          done = false
        end
      end
      # F12 has been pressed, keep trying to update
      while !done
        begin
          zeriab_f12_pause_update(*args)
          done = true
        rescue Reset
          # Do nothing
        end
      end
      # F12 has been released, dispose pause image
      @sprite.dispose
      $game_system.bgm_restore
      $game_system.bgs_restore
      # Set proper frame count
      Graphics.frame_count = frame_count
    end
    #-------------------------------------------------------------------------
    # Changes the transition so it is cut short if F12 is pressed
    #-------------------------------------------------------------------------
    def transition(*args)
      done = false
      # Keep trying to do the transition
      while !done
        begin
          zeriab_f12_pause_transition(*args)
          done = true
        rescue Reset
          # Set transition length to 0 frames.
          args[0] = 0
        end
      end
    end
  end
end


*hugs*
- Zeriab
Title: Re: [XP] F12 Pause with image script
Post by: Calintz on June 06, 2009, 03:31:32 pm
Now even better! =D
Title: Re: [XP] F12 Pause with image script
Post by: Hellfire Dragon on June 06, 2009, 04:41:18 pm
Quote from: Fantasist on May 28, 2009, 11:30:04 am
You never seem to amaze me Zeriab :up:

Really? Spelling mistake?

Awesome script Zeriab :)
Title: Re: [XP] F12 Pause with image script
Post by: Calintz on June 06, 2009, 04:48:48 pm
I really like this one Zeriab ...

BTW:
Do you just create scripts for us, or do you have a project??
Title: Re: [XP] F12 Pause with image script
Post by: Zeriab on June 06, 2009, 05:56:07 pm
I prefer the version which pauses the Audio despite it requiring a third party script ^_^

I script a bit for a project, but mainly I just make modular scripts :3
Title: Re: [XP] F12 Pause with image script
Post by: Calintz on June 06, 2009, 07:26:45 pm
Good deal, well we are all glad to have your assistance.
Title: Re: [XP] F12 Pause with image script
Post by: Zeriab on June 09, 2009, 04:38:07 pm
Probably not, but the fact that some of you are makes me happy ^_^
I enjoy doing it, so it's a win-win situation
Title: Re: [XP] F12 Pause with image script
Post by: Calintz on June 09, 2009, 10:34:14 pm
That's really all that matters ... =D
Title: Re: [XP] F12 Pause with image script
Post by: phcs666 on December 15, 2010, 10:20:01 am
Can the key be changed ? to ESC or PauseBreak for example ?
Title: Re: [XP] F12 Pause with image script
Post by: ForeverZer0 on December 15, 2010, 11:12:10 am
If you need that, you can probably quickly add the feature in to be called when a key is pressed. As it is, the script captures the Reset feature that is built into RMXP, and prevents the game from being reset.
Title: Re: [XP] F12 Pause with image script
Post by: phcs666 on December 15, 2010, 07:08:08 pm
Got it, the game must be reseted when my defined key is pressed, but with the reset feature captured by the pause feature, it will pause the game instead of reseting it, right ?

So what do i have to put into my key condition to make the game reset ( pause )
Title: Re: [XP] F12 Pause with image script
Post by: Zeriab on December 17, 2010, 02:14:14 pm
I'd suggest finding an input script which supports checking for those keys and modifying this version which uses F6: http://forum.chaos-project.com/index.php/topic,3613.msg72096.html#msg72096

*hugs*
Title: Re: [XP] F12 Pause with image script
Post by: phcs666 on December 17, 2010, 06:53:40 pm
Oh =O, i havent noticed that post of yours, thank you Zeriab, thats what i need \o
Title: Re: [XP] F12 Pause with image script
Post by: Futendra on December 29, 2010, 06:31:54 am
Quote from: Zeriab on December 17, 2010, 02:14:14 pm
I'd suggest finding an input script which supports checking for those keys and modifying this version which uses F6: http://forum.chaos-project.com/index.php/topic,3613.msg72096.html#msg72096

*hugs*



Finally I got the spam verification code workign for my registration, I had some bgu ore something...

FINALLY I can ask you my questiond :D

How do I make the pause picture slightly transparent?

Im dutch so srry for my suckywucky english :D
Title: Re: [XP] F12 Pause with image script
Post by: stripe103 on December 29, 2010, 07:33:47 am
Since it only shows the image I'd guess it is enough with making the image file itself slightly transparent.. Just use PhotoShop or Gimp or anything like them.
Title: Re: [XP] F12 Pause with image script
Post by: Futendra on December 30, 2010, 07:28:28 am
Quote from: stripe103 on December 29, 2010, 07:33:47 am
Since it only shows the image I'd guess it is enough with making the image file itself slightly transparent.. Just use PhotoShop or Gimp or anything like them.


well since my photoshop expired and my download limit is extremely limited, it will be hard (thats why i come to this forum, the scripts arent in downloads but just in script spoilers :D :)
Title: Re: [XP] F12 Pause with image script
Post by: stripe103 on December 30, 2010, 08:59:37 am
Okay..
In the script, go to line 87 ( @sprite.z = 9999 ) and add a new line after, before the line begin and write
@sprite.opacity = NUMBER

and that should work.

Change the NUMBER to a value from 0(invisible) to 255(totally visible) that you want.
Title: Re: [XP] F12 Pause with image script
Post by: World Eater on July 25, 2011, 10:13:19 pm
I've been toying with this but I'm a little over my head at the moment.
Would it be possible to make the pause script have animation functionality?

If so, how would one go about doing so?

Thanks for the awesome script by the way.
Title: Re: [XP] F12 Pause with image script
Post by: Zeriab on August 08, 2011, 01:36:25 pm
Certainly it is. Here is a quick and dirty modification where you can have both a start animation (which plays just once) and a loop animations which continues to play until the player unpauses the game.

#==============================================================================
# ** Pausing with F12
#------------------------------------------------------------------------------
# Zeriab
# Version 1.2
# 2011-08-08 (Year-Month-Day)
#------------------------------------------------------------------------------
# * Version History :
#
#   Version 1.0 -------------------------------------------------- (2009-05-22)
#   - First release
#
#   Version 1.1 -------------------------------------------------- (2009-05-25)
#   - The pause image now appears immediately when F12 is pressed.
#   - Transitions are cut short rather than restarted when F12 is pressed.
#
#   Version 1.2 -------------------------------------------------- (2011-08-08)
#   - Allowed a start and loop animation to be played
#------------------------------------------------------------------------------
# * Description :
#
#   This script changes the functionality of pressing F12 during the game
#   from resetting the game to (un)pausing the game. A picture is displayed
#   while the game is paused. (Having a picture is optional)
#------------------------------------------------------------------------------
# * License :
#
#   Copyright (C) 2009  Zeriab
#
#   This program is free software: you can redistribute it and/or modify
#   it under the terms of the GNU Lesser Public License as published by
#   the Free Software Foundation, either version 3 of the License, or
#   (at your option) any later version.
#
#   This program is distributed in the hope that it will be useful,
#   but WITHOUT ANY WARRANTY; without even the implied warranty of
#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#   GNU Lesser Public License for more details.
#
#   For the full license see <http://www.gnu.org/licenses/>
#   The GNU General Public License: http://www.gnu.org/licenses/gpl.txt
#   The GNU Lesser General Public License: http://www.gnu.org/licenses/lgpl.txt
#------------------------------------------------------------------------------
# * Compatibility :
#
#   Is most likely not compatible with other F12 prevention scripts.
#------------------------------------------------------------------------------
# * Instructions :
#
#   Place this script anywhere above main.
#   The image file 'pause' present in Graphics/Pictures is used.
#   Note: No picture is shown if there is no 'pause' in Graphics/Pictures.
#==============================================================================

#=============================================================================
# ** Reset class (because it won't be defined until F12 is pressed otherwise)
#=============================================================================
class Reset < Exception
 
end
#=============================================================================
# ** Module Graphics
#=============================================================================
module Graphics
  class << self
    START_ANIMATION_ID = 99
    LOOP_ANIMATION_ID  = 94
    WAIT_BEFORE_LOOP = 30 # Amount of frames before the loop animation starts
    #-------------------------------------------------------------------------
    # * Aliases Graphics.update and Graphics.transition
    #-------------------------------------------------------------------------
    unless self.method_defined?(:zeriab_f12_pause_update)
      alias_method(:zeriab_f12_pause_update, :update)
      alias_method(:zeriab_f12_pause_transition, :transition)
    end
    #-------------------------------------------------------------------------
    # Change the update method so F12 toggles pause
    #-------------------------------------------------------------------------
    def update(*args)
      # Try to update normally
      begin
        zeriab_f12_pause_update(*args)
        return
      rescue Reset
        # Do nothing
      end
      # F12 has been pressed
      done = false
      # Store frame count
      frame_count = Graphics.frame_count
      # Show pause image
      @sprite = RPG::Sprite.new
      @sprite.z = 9999
      if $data_animations && $data_animations[START_ANIMATION_ID]
        @sprite.animation($data_animations[START_ANIMATION_ID], false)
      end
      begin
        @sprite.bitmap = RPG::Cache.picture('pause')
      rescue
        @sprite.bitmap = Bitmap.new(32,32)
      end
      # Keep trying to do the update
      while !done
        begin
          zeriab_f12_pause_update(*args)
          done = true
        rescue Reset
          # Do Nothing
        end
      end
      # F12 has been released, update until it is pressed again
      counter = 0
      while done
        begin
          counter += 1
          if counter >= WAIT_BEFORE_LOOP && $data_animations && $data_animations[LOOP_ANIMATION_ID]
            @sprite.loop_animation($data_animations[LOOP_ANIMATION_ID])
          end
          @sprite.update
          zeriab_f12_pause_update(*args)
        rescue Reset
          done = false
        end
      end
      # F12 has been pressed, keep trying to update
      while !done
        begin
          zeriab_f12_pause_update(*args)
          done = true
        rescue Reset
          # Do nothing
        end
      end
      # F12 has been released, dispose pause image
      @sprite.dispose
      # Set proper frame count
      Graphics.frame_count = frame_count
    end
    #-------------------------------------------------------------------------
    # Changes the transition so it is cut short if F12 is pressed
    #-------------------------------------------------------------------------
    def transition(*args)
      done = false
      # Keep trying to do the transition
      while !done
        begin
          zeriab_f12_pause_transition(*args)
          done = true
        rescue Reset
          # Set transition length to 0 frames.
          args[0] = 0
        end
      end
    end
  end
end


*hugs*