Advertisement
Zeriab

[RGSS1+3]Debug hotkey snippet

Mar 27th, 2014
308
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 2.42 KB | None | 0 0
  1. ####
  2. # License Terms
  3. ##
  4. # Copyright (c) 2014 Zeriab
  5. #
  6. # This software is provided 'as-is', without any express or implied warranty.
  7. # In no event will the authors be held liable for any damages arising from the
  8. # use of this software.
  9. #
  10. # Permission is granted to anyone to use this software for any purpose, including
  11. # commercial applications, and to alter it and redistribute it freely, subject to
  12. # the following restrictions:
  13. #     1. The origin of this software must not be misrepresented; you must not
  14. #        claim that you wrote the original software. If you use this software in
  15. #        a product, an acknowledgment in the product documentation would be
  16. #        appreciated but is not required.
  17. #     2. Altered source versions must be plainly marked as such, and must not be
  18. #        misrepresented as being the original software.
  19. #     3. This notice may not be removed or altered from any source distribution.
  20. #
  21. module DebugMode
  22.   module_function
  23.   def test_method
  24.     # Example code
  25.     $game_switches[1] = !$game_switches[1]
  26.     $game_map.need_refresh = true
  27.   end
  28. end
  29. #=============================================================================
  30. # ** Module Graphics
  31. #=============================================================================
  32. module Input
  33.   class << self
  34.     #-------------------------------------------------------------------------
  35.     # * Aliases Input.update
  36.     #-------------------------------------------------------------------------
  37.     unless self.method_defined?(:zeriab_debug_map_update)
  38.       alias_method(:zeriab_debug_map_update, :update)
  39.     end
  40.     #-------------------------------------------------------------------------
  41.     # Change the update method so holding Z+X+C down triggers a teleport
  42.     #-------------------------------------------------------------------------
  43.     def update(*args)
  44.       zeriab_debug_map_update(*args)
  45.       return unless $DEBUG || $TEST
  46.       @counter ||= 0
  47.       if press?(A) && press?(B) && press?(C)
  48.         @counter += 1
  49.       else
  50.         @counter = 0
  51.       end
  52.       if @counter >= 180
  53.         # Teleport to special debug map
  54.         if $game_system
  55.           if $data_system.respond_to?(:decision_se)
  56.             $game_system.se_play($data_system.decision_se)
  57.           else
  58.             Sound.play_ok
  59.           end
  60.         end
  61.         @counter = 0
  62.         DebugMode.test_method
  63.       end
  64.     end
  65.   end
  66. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement