Stop F12 from resetting your game
#1
Here is a rather useful snippet I just cooked up.
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:
#=============================================================================
# ** 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:
[Image: speedboostlx8.png]

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

If the player press F12 during a transition the transition will reset and start again.
If F12 is kept pressed the game will feel like it has been paused. The FPS registered will typically be registered as higher although game playing will not change. Nor will it if it's Graphics.update being cancelled. The shown timer will however run faster.
Here is a snippet where it feels like the game simply pauses when pressing F12, if that is what one prefer:

Code:
#=============================================================================
# ** 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)
      done = false
      # Keep trying to do the update
      while !done
        begin
          zeriab_f12_removal_update(*args)
          done = true
        rescue Reset
          # Do nothing
        end
      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
*hugs*
- Zeriab
Reply }


Possibly Related Threads…
Thread Author Replies Views Last Post
   Name Game Switch & Variable XP kyonides 0 1,078 06-27-2023, 09:17 PM
Last Post: kyonides
Photo  Map Tileset Changer during the game Narzew 1 6,388 05-06-2013, 09:18 PM
Last Post: Narzew
   DerVVulfman's Game Data Sneak DerVVulfman 1 7,431 04-03-2013, 08:42 PM
Last Post: Taylor
   Mr.Mo ABS Game Log Window JayRay 0 5,349 10-30-2012, 06:54 AM
Last Post: JayRay
   Limit Breaker - breaks game limits Narzew 1 6,366 10-09-2012, 10:35 AM
Last Post: MetalRenard
   1 Save Slot / AutoLoad Saved Game kyonides 1 6,704 07-09-2010, 08:38 AM
Last Post: Kread-EX
   Card Game Data Structure Trickster 5 11,373 12-09-2009, 06:38 PM
Last Post: Trickster
   Game Over Replacer + Enhancer [Exclusive] PK8 0 7,921 07-03-2009, 10:31 AM
Last Post: PK8
   [Unsupported] Force Save Before New Game PK8 0 4,898 12-07-2008, 04:44 PM
Last Post: PK8
   [Unsupported] Game Disc 1 and 2 PK8 0 4,644 12-07-2008, 02:34 PM
Last Post: PK8



Users browsing this thread: 1 Guest(s)