The RPG Maker Resource Kit

RMRK RPG Maker Creation => XP => XP Scripts Database => Topic started by: Zeriab on July 11, 2007, 04:31:17 PM

Title: F12 fix
Post by: Zeriab on July 11, 2007, 04:31:17 PM
After the F12 bother me one time too many I made this little snippet:
Copy and paste it as the very first script. (Top in the editor, above Game_Temp)
Code: [Select]
#=begin
unless $f12_cleaner_F3XXEFA1.nil?
  # Opens the game executable in a new thread
  Thread.new{system ("Game")}  # "Game" = Name of the game executable
  # Exits this thread
  exit
end

# Modifying this global variable might cause this snippet to stop working properly.
# Some garbage have been added to lessen the chance of it already being used
$f12_cleaner_F3XXEFA1 = true
#=end

It will close the current game and open a new game.
If you have Vista it might require you to give permission since it actually opens a new application.
There might be issues with it, so tell me if you find any.

Also, it's different from the unofficial SDK solution in that you can restart the game by pressing F12.

Enjoy ~

Edit:
Here is another snippet which works better in my opinion.
This prevents the F12 key from resetting the game.
For some reason pressing the F12 key now seems to speed up the game in many cases and in other pauses the game.

Code: [Select]
#=============================================================================
# ** 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_removal_update)
      alias_method(:zeriab_f12_removal_update, :update)
      alias_method(:zeriab_f12_removal_transition, :transition)
    end
    def update(*args)
      begin
        zeriab_f12_removal_update(*args)
      rescue Reset
        # Do nothing
      end
    end
    def transition(*args)
      done = false
      # Keep trying to do the transition
      while !done
        begin
          zeriab_f12_removal_transition(*args)
          done = true
        rescue Reset
          # Do nothing
        end
      end
    end
  end
end

For an extreme example of the speed up issue I mentioned here is a picture:
(https://rmrk.net/proxy.php?request=http%3A%2F%2Fimg89.imageshack.us%2Fimg89%2F438%2Fspeedboostlx8.png&hash=bdb4de4b1cce2b3c98e0127ad7268cf839da9245)

I don't know whether it actually went with 410 FPS or if something broke.

*hugs*
 - Zeriab
Title: Re: F12 fix
Post by: modern algebra on July 11, 2007, 05:21:18 PM
What was the bug with F12 before?
Title: Re: F12 fix
Post by: Zeriab on July 11, 2007, 10:13:49 PM
There seems to be no bugs with the default scripts.
Problem is however that stuff like global variables are preserved and some scripts give errors during their second read-through.
A common error is a stack error occurring in scripts where you alias a method.
Title: Re: F12 fix
Post by: Kokowam on July 11, 2007, 10:48:10 PM
Oh, cool?
Title: Re: F12 fix
Post by: modern algebra on October 19, 2007, 12:50:04 AM
Move to Database?
Title: Re: F12 fix
Post by: Zeriab on April 20, 2008, 09:06:49 PM
*Updates*
I have found a way to prevent the game from being reset when pressing F12. Look in the first post for more details ^_^
*hugs*
 - Zeriab