Main Menu
  • Welcome to The RPG Maker Resource Kit.

F12 fix

Started by Zeriab, July 11, 2007, 04:31:17 PM

0 Members and 1 Guest are viewing this topic.

Zeriab

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)
#=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.

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


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

*hugs*
- Zeriab

modern algebra

What was the bug with F12 before?

Zeriab

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.

Kokowam


modern algebra


Zeriab

*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