F12 Reset Fix
Introduction
F12 reset can sometimes be a pain in the arse. This script fixes that by spawning a new Game.exe. It can also be used if you want to use the editor whilst play-testing it. You can also configure to show the console on test play.
Features
- Saves an RM user from death by F12 reset.
Screenshots
Not needed.
Script
Spoiler Code:
#============================================================================== # ** F12 Reset Fix # Author: Acezon # Date: 2 June 2013 #------------------------------------------------------------------------------ # Version 2.1 # - Fixed issue where game window is not in focus # when Console_on is set to false # - Now compatible with Tsuki's Test Edit script # Version 2.0 # - Console option added # - Automatically focuses window after pressing F12 # Version 1.1 # - Respawning the exe was better # Version 1.0 # - Initial Release #------------------------------------------------------------------------------ # Just credit me. Free to use for commercial/non-commercial games. # Thanks to Tsukihime and Cidiomar for the console scriptlet #============================================================================== $imported = {} if $imported.nil? $imported["Acezon-F12ResetFix"] = true #============================================================================== # ** START Configuration #============================================================================== module Config Console_on = false # duh end #============================================================================== # ** END Configuration #============================================================================== alias f12_reset_fix rgss_main def rgss_main(*args, &block) f12_reset_fix(*args) do if $run_once_f12 pid = spawn ($TEST ? 'Game.exe test' : 'Game') # Tell OS to ignore exit status Process.detach(pid) sleep(0.01) exit end $run_once_f12 = true # Run default rgss_main block.call end end module SceneManager class << self alias :acezon_f12_first :first_scene_class end def self.first_scene_class focus_game_window acezon_f12_first end def self.focus_game_window # Just to prevent re-spawning the console since # Tsuki uses this same part in his Test Edit script if !$imported["TH_TestEdit"] # Get game window text console_w = Win32API.new('user32','GetForegroundWindow', 'V', 'L').call buf_len = Win32API.new('user32','GetWindowTextLength', 'L', 'I').call(console_w) str = ' ' * (buf_len + 1) Win32API.new('user32', 'GetWindowText', 'LPI', 'I').call(console_w , str, str.length) if Config::Console_on # Initiate console Win32API.new('kernel32.dll', 'AllocConsole', '', '').call Win32API.new('kernel32.dll', 'SetConsoleTitle', 'P', '').call('RGSS3 Console') $stdout.reopen('CONOUT$') end # Sometimes pressing F12 will put the editor in focus first, # so we have to remove the program's name game_title = str.strip game_title.sub! ' - RPG Maker VX Ace', '' # Set game window to be foreground hwnd = Win32API.new('user32.dll', 'FindWindow', 'PP','N').call(0, game_title) Win32API.new('user32.dll', 'SetForegroundWindow', 'P', '').call(hwnd) end end end 复制代码
Log
Version 2.1
- Fixed issue where game window is not in focus
when Console_on is set to false
- Now compatible with Tsuki's Test Edit script
Version 2.0
- Console option added
- Automatically focuses window after pressing F12
Version 1.1
- Respawning the exe was better
Version 1.0
- Initial Release
Credit and Thanks
- Read the script header
本贴来自国际rpgmaker官方论坛作者:nthcat处,因国际论坛即将永久关站,为了存档多年珍贵资料,署名转载到本论坛存档,由于官方帖子为英文原帖,需要中文翻译请点击论坛顶部切换语言为中文就可以将帖子翻译成中文浏览,方便大家随时查看,原文地址:
https://forums.rpgmakerweb.com/threads/f12-reset-fix.8000/