Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 F12 Reset Fix
#1
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.

Script
Code:
#==============================================================
#   ** F12 Reset Fix
#   Author: Acezon
#   Date: 12 Feb 2013
#--------------------------------------------------------------
#   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
#--------------------------------------------------------------
#   Credits are optional.
#     Although doing so will make me happy.
#   Thanks to Tsukihime and Cidiomar for the console scriptlet
#==============================================================

module Config
# START EDITING HERE
  Console_on = true       # Sets the console
# END EDITING HERE
end

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
  def self.first_scene_class
    if Config::Console_on
      # 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)
      
      # Initiate console
      Win32API.new('kernel32.dll', 'AllocConsole', '', '').call
      Win32API.new('kernel32.dll', 'SetConsoleTitle', 'P', '').call('RGSS3 Console')
      $stdout.reopen('CONOUT$')
      
      # 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
    $BTEST ? Scene_Battle : Scene_Title
  end
end

Credits and Thanks
- Read the script header.
Reply }
#2
Where does this go now?
Reply }
#3
Hag on, so the Ace has actually the same problem (as in a "F12 error that is likely to happen") as the XP? Really? XD'
This is a usefull script in that case, I suppose =) Beeing able to edit while testing is always a huge plus as well =D
Friendship is born at that moment when one person says to another: "What! You, too? Thought I was the only one." (C.S. Lewis)
For the time you're laughing, there's nothing wrong in the world. (Colin Mochrie)

If it's funny, make sure people laugh. If it's not funny, make it funny (unless it's actually really serious). (silvercheers)

Please don't spell my name "Yamina-chan". It's all small. Thank you =D
Reply }
#4
Good ol' Zeriab made one of the best for RMXP and made one for VX. He first thought that the VX one would work for VXAce once it was found to have an F12 bug of it's own, but found it was caused by a totally different bit of code. Thankies for submitting a workaround. Happy
Up is down, left is right and sideways is straight ahead. - Cord "Circle of Iron", 1978 (written by Bruce Lee and James Coburn... really...)
[Image: QrnbKlx.jpg]
[Image: sGz1ErF.png] [Image: liM4ikn.png] [Image: fdzKgZA.png] [Image: sj0H81z.png]
[Image: QL7oRau.png] [Image: uSqjY09.png] [Image: GAA3qE9.png] [Image: 2Hmnx1G.png] [Image: BwtNdKw.png%5B]
Above are clickable links

Reply }
#5
UPDATED to version 2. Read the first post for changes.
Reply }


Possibly Related Threads…
Thread Author Replies Views Last Post
   Equipment TP Reset ACE kyonides 0 890 11-01-2022, 10:47 PM
Last Post: kyonides
   DoubleX RMMV Popularized ATB Reset DoubleX 1 5,233 06-02-2016, 02:05 PM
Last Post: DoubleX
   Edited Paradog's Battle BGM Anti-Reset MicKo 1 5,808 06-27-2014, 06:05 PM
Last Post: Steel Beast 6Beets
   Battle BGM Anti-Reset ParaDog 0 3,467 03-04-2008, 04:37 AM
Last Post: ParaDog



Users browsing this thread: