Jump to content
New account registrations are disabed. This website is now an archive. Read more here.
Sign in to follow this  
Zeriab

F12 Pause with image script

Recommended Posts

F12 Pause with image script

Version: 1.1

Author: Zeriab

Date: 2009-05-25

 

Description

 

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

 

f12_pause.jpg

 

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.

 

pause.png

 

Script

 

#==============================================================================
# ** 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

 

Credit

 

Credits goes to Zeriab for writing the script and making the Paused picture.

 

Known Compatibility Issues

 

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

 

Author's Notes

Thanks goes to sixdd for suggesting pause toggling and showing a pause image.

Thanks goes to Kiriashi for inspiration on cutting the transitions short.

You can use the pause image and modify it any way you like. You don't have to provide credits or anything.

If F12 is pressed during a transition the transition is cut short.

Note that it does NOT work on VX.

 

Terms and Conditions

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

Share this post


Link to post
Share on other sites

Hey! Cool!

 

This could be a really nice touch to any game.

 

 

Thanks for the script Zeriab, and nice to see you around again!

Share this post


Link to post
Share on other sites

I am glad you like and I am glad to be back (although I unfortunately won't be very active)

The method I am using for preventing resets does not work in VX. I.e. it's not just a syntax problem, it's the methodology which doesn't work in VX.

I am not saying it's impossible make a script which pauses rather than resets on F12 in VX, I just don't know how.

 

The reason I made this script is because I believe that F12 pausing is preferable over resetting the game. You can pause the game anywhere independent of what's going on except during transitions. Pressing F12 during a transition causes the transition to restart.

 

*hugs*

Share this post


Link to post
Share on other sites
Pressing F12 during a transition causes the transition to restart.

 

 

 

Any way to fix this? Maybe disable it during transitions or something?

 

 

*hugs* back

Share this post


Link to post
Share on other sites

Disabling it during transitions would have the effect of the game restarting, so that's not really a viable solution.

Cutting the transition short on the other hand works well. That is a good idea ^_^

 

I have updated the first post with the new version.

If you are interested in using another button to pause with then you can use this script:

#==============================================================================
# ** 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

 

Notice the PAUSE_BUTTON = F6. You can change it to any of the buttons specified in under the Input module in the help-file.

 

*hugs*

- Zeriab

Share this post


Link to post
Share on other sites

Now this is funny. I was going to ask if there was a way to change it from pressing F12 to pressing a different button, and you just posted another version of the Pause script that can do what I was going to ask. I find that funny :P

Share this post


Link to post
Share on other sites

Cool script Zeriab! It's better to use F12 to pause then just press F12 to restart when you just can exit and open the game up!

Share this post


Link to post
Share on other sites

this is probly one of the most useful things I bumped into. Just to think of those times I pointed at the print screen key and missed the shot and ended up reseting the game.... :rolleyes:

Share this post


Link to post
Share on other sites
this is probly one of the most useful things I bumped into. Just to think of those times I pointed at the print screen key and missed the shot and ended up reseting the game.... :rolleyes:

You nailed my motivation for making this script :D

I wasn't able to remove completely (i.e. pressing F12 does nothing), so that's why I made a pause script.

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...