Introduction
This script removes the functionality of the F12 button, and thus prevents possible stack errors from occurring. But while doing so, it also performs a routine that lets on-screen graphics refresh at a normal speed if the F12 button is depressed for any extended length of time. This is a change from other F12 scripts of its type whereby the graphics are sped up. Only the game play remains frozen.
Script
The F12 Fix
Code:
#==============================================================================
# ** F12 Fix: DerVVulfman-Style
#------------------------------------------------------------------------------
# by DerVVulfman
# version 1.2
# 04-23-2013
# RGSS / RPGMaker XP
#==============================================================================
#
# INTRODUCTION:
#
# There are a few scripts out for RPGMaker XP that fixes the dreaded F12 bug,
# whereby pressing the F12 button (whether intentional or by accident) allows
# the player to reset their game... and incidentally force some scripts to
# try and reload causing 'stack' errors. A number of scripts have been out
# that fully clear resources while others attempt to remove the functionality
# of the F12 button altogether. This is one of the latter.
#
# This script removes the functionality of the F12 button, and thus prevents
# possible stack errors from occurring. But while doing so, it also performs
# a routine that lets on-screen graphics refresh at a normal speed if the F12
# button is depressed for any extended length of time. This is a change from
# other F12 scripts of its type whereby the graphics are sped up. Only the
# player's game play actions remain frozen.
#
# But, there is something to note. If you press the F12 button while in the
# midst of a screen transition, it will reset the transition to the start.
#
# Graphics created with an outside .dll (3D / Mode7) may not refresh properly
# with this system.
#
# USE: Seriously? Just paste it into your game.
#
#===============================================================================
#===============================================================================
# ** Reset
#------------------------------------------------------------------------------
# The class that detects the F12 key.
#===============================================================================
class Reset < Exception
end
#===============================================================================
# ** Graphics
#------------------------------------------------------------------------------
# The module that carries out graphics processing.
#===============================================================================
class << Graphics
#-----------------------------------------------------------------------------
# * Alias Listings
#-----------------------------------------------------------------------------
alias f12_graphics_update update
alias f12_graphics_transition transition
#-----------------------------------------------------------------------------
# * Frame Update
#-----------------------------------------------------------------------------
def update
# Set up frame counter flip flag
@flip_count = false if @flip_count.nil?
# Execute update with F12 check
begin
# Perform the original call
f12_graphics_update
# F12 [Reset] check
rescue Reset
# Sleep for a fraction of a second (based on frame_rate)
sleep(1.0/self.frame_rate)
# Toggle frame counter flag
@flip_count = !@flip_count
# Add 1 to count
self.frame_count += 1
# Add additional count if flag is true
self.frame_count += 1 if @flip_count == true
# Reset the screen refresh timing (prevents clipping)
frame_reset
# Do nothing
end
end
#-----------------------------------------------------------------------------
# * Transition
#-----------------------------------------------------------------------------
def transition(*args)
# Transition finished flag
trans_end = false
# If transition being performed (not finished)
while trans_end != true
# Execute update with F12 check
begin
# Perform the original call
f12_graphics_transition(*args)
# Transition finished performing
trans_end = true
# F12 [Reset] check
rescue Reset
# Reset the screen refresh timing (prevents clipping)
frame_reset
# Do nothing
end
end
end
end
FAQ
Dang small, isn't it?
Compatibility
RPGMaker XP only. It won't work with VX.
Terms and Conditions
Free for use, even in commercial scripts. Due credit is all that's required.
Up is down, left is right and sideways is straight ahead. - Cord "Circle of Iron", 1978 (written by Bruce Lee and James Coburn... really...)