Author Topic: [XP] F12 Pause with image script  (Read 16867 times)

Offline Zeriab

  • Ethereal Devastator
  • ****
  • Posts: 350
  • LV: 65
  • Mighty Scripter
    • View Profile
    • Zeriab's Junk
[XP] F12 Pause with image script
« on: May 22, 2009, 11: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



Script

(click to show/hide)

Instructions

Copy+paste the script into the script editor. (Unsure? See this tutorial)
Import picture named pause to Graphics/Pictures. You can use the example picture below for trying it out.



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.

(click to show/hide)
« Last Edit: May 25, 2009, 04:03:40 PM by Zeriab »

Offline Blizzard

  • This sexy
  • Administrator
  • has over 9000 posts
  • *****
  • Posts: 20005
  • LV: 651
  • Gender: Male
  • Magic midgets.
    • View Profile
    • You're already on it. (-_-')
Re: [XP] F12 Pause with image script
« Reply #1 on: May 22, 2009, 11:17:08 AM »
So I am not allowed to credit your for using your override of F12? ._.
« Last Edit: May 22, 2009, 11:18:35 AM by Blizzard »
Check out Daygames and our games:

King of Booze      King of Booze: Never Ever      Pet Bots
Drinking Game for Android      Never have I ever for Android      Pet Bots for Android
Drinking Game for iOS      Never have I ever for iOS      Pet Bots for iOS
Drinking Game on Steam


Quote from: winkio
I do not speak to bricks, either as individuals or in wall form.

Quote from: Barney Stinson
When I get sad, I stop being sad and be awesome instead. True story.

Offline Zeriab

  • Ethereal Devastator
  • ****
  • Posts: 350
  • LV: 65
  • Mighty Scripter
    • View Profile
    • Zeriab's Junk
Re: [XP] F12 Pause with image script
« Reply #2 on: May 22, 2009, 03:49:06 PM »
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

Offline legacyblade

  • Pretzel Man
  • Moderator
  • Chaos User
  • ***
  • Posts: 1838
  • LV: 84
  • Gender: Male
  • There is a fate worse than hell
    • View Profile
    • SpencerConrad.com
Re: [XP] F12 Pause with image script
« Reply #3 on: May 22, 2009, 05:12:19 PM »
Is this compatible with all scripts? It sounds like it should be, but I'm just asking.

Offline Zeriab

  • Ethereal Devastator
  • ****
  • Posts: 350
  • LV: 65
  • Mighty Scripter
    • View Profile
    • Zeriab's Junk
Re: [XP] F12 Pause with image script
« Reply #4 on: May 22, 2009, 05:21:43 PM »
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*

Offline legacyblade

  • Pretzel Man
  • Moderator
  • Chaos User
  • ***
  • Posts: 1838
  • LV: 84
  • Gender: Male
  • There is a fate worse than hell
    • View Profile
    • SpencerConrad.com
Re: [XP] F12 Pause with image script
« Reply #5 on: May 22, 2009, 06:12:04 PM »
So theoretically, would it be possible to have a very LONG evented cutscene, and pause mid-scene?

Offline Starrodkirby86

  • Kirby de Varita Estelar
  • Guardian of Chaos
  • ********
  • Posts: 3281
  • LV: 194
  • Gender: Male
  • ~!
    • View Profile
    • The Archive of Starrodkirby86
Re: [XP] F12 Pause with image script
« Reply #6 on: May 23, 2009, 12:28:48 AM »
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?

What's osu!? It's a rhythm game. Thought I should have a signature with a working rank. ;P It's now clickable!
Still Aqua's biggest fan (Or am I?).



Offline Kagutsuchi

  • Ethereal Devastator
  • ****
  • Posts: 468
  • LV: 2
  • Gender: Male
  • The God of .. eating souls?
    • View Profile
    • University Hosted Web Page - In Norwegian
Re: [XP] F12 Pause with image script
« Reply #7 on: May 23, 2009, 12:45:00 AM »
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

Offline legacyblade

  • Pretzel Man
  • Moderator
  • Chaos User
  • ***
  • Posts: 1838
  • LV: 84
  • Gender: Male
  • There is a fate worse than hell
    • View Profile
    • SpencerConrad.com
Re: [XP] F12 Pause with image script
« Reply #8 on: May 23, 2009, 01:30:57 AM »
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.
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.

Offline Zeriab

  • Ethereal Devastator
  • ****
  • Posts: 350
  • LV: 65
  • Mighty Scripter
    • View Profile
    • Zeriab's Junk
Re: [XP] F12 Pause with image script
« Reply #9 on: May 23, 2009, 01:14:57 PM »
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:

Code: [Select]
#=============================================================================
# ** 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.
Quote
DOWN 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

Offline Zeriab

  • Ethereal Devastator
  • ****
  • Posts: 350
  • LV: 65
  • Mighty Scripter
    • View Profile
    • Zeriab's Junk
Re: [XP] F12 Pause with image script
« Reply #10 on: May 25, 2009, 04:06:31 PM »
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.
Code: [Select]
#==============================================================================
# ** 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

Offline Calintz

  • Guardian of Chaos
  • ********
  • Posts: 3803
  • LV: 108
  • Gender: Male
  • A Pixel's Worst Nightmare
    • View Profile
Re: [XP] F12 Pause with image script
« Reply #11 on: May 25, 2009, 11: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.

Offline Fantasist

  • Lexima Warrior
  • *******
  • Posts: 2223
  • LV: 146
  • Gender: Male
    • View Profile
    • Blog
Re: [XP] F12 Pause with image script
« Reply #12 on: May 28, 2009, 05:30:04 PM »
You never seem to amaze me Zeriab :up:
Do you like ambient/electronic music? Then you should promote a talented artist! Help out here. (I'm serious. Just listen to his work at least!)

The best of freeware reviews: Gizmo's Freeware Reviews



Offline Reno-s--Joker

  • Astral Trancist
  • *****
  • Posts: 674
  • LV: 34
  • Gender: Female
  • Zombie account.
    • View Profile
    • My DeviantART
Re: [XP] F12 Pause with image script
« Reply #13 on: June 03, 2009, 11:13:33 AM »
Is it just me or is this freaking amazing.

I'm a fan. Seriously. Have I mentioned that before?

Offline Zeriab

  • Ethereal Devastator
  • ****
  • Posts: 350
  • LV: 65
  • Mighty Scripter
    • View Profile
    • Zeriab's Junk
Re: [XP] F12 Pause with image script
« Reply #14 on: June 06, 2009, 11: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 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.
Code: [Select]
#==============================================================================
# ** 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

Offline Calintz

  • Guardian of Chaos
  • ********
  • Posts: 3803
  • LV: 108
  • Gender: Male
  • A Pixel's Worst Nightmare
    • View Profile
Re: [XP] F12 Pause with image script
« Reply #15 on: June 06, 2009, 09:31:32 PM »
Now even better! =D

Offline Hellfire Dragon

  • Astral Trancist
  • *****
  • Posts: 768
  • LV: 24
  • Gender: Male
    • View Profile
Re: [XP] F12 Pause with image script
« Reply #16 on: June 06, 2009, 10:41:18 PM »
You never seem to amaze me Zeriab :up:
Really? Spelling mistake?

Awesome script Zeriab :)

Offline Calintz

  • Guardian of Chaos
  • ********
  • Posts: 3803
  • LV: 108
  • Gender: Male
  • A Pixel's Worst Nightmare
    • View Profile
Re: [XP] F12 Pause with image script
« Reply #17 on: June 06, 2009, 10:48:48 PM »
I really like this one Zeriab ...

BTW:
Do you just create scripts for us, or do you have a project??

Offline Zeriab

  • Ethereal Devastator
  • ****
  • Posts: 350
  • LV: 65
  • Mighty Scripter
    • View Profile
    • Zeriab's Junk
Re: [XP] F12 Pause with image script
« Reply #18 on: June 06, 2009, 11: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

Offline Calintz

  • Guardian of Chaos
  • ********
  • Posts: 3803
  • LV: 108
  • Gender: Male
  • A Pixel's Worst Nightmare
    • View Profile
Re: [XP] F12 Pause with image script
« Reply #19 on: June 07, 2009, 01:26:45 AM »
Good deal, well we are all glad to have your assistance.