Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

System : Quick Shutdown

System : Quick Shutdown
Version: 3.5
By: Kain Nobel

Introduction

Quickly shutdown your entire fantasy world by simply pressing a button :P

Features

  • One-button shutdown (for lazy people, like me)
  • Define what button you want to call shutdown (F8 by default)
  • Define which scenes disable the One-Button shutdown feature

Script

Code:
#===============================================================================

# ** System : Quick Shutdown

#===============================================================================

 

#-------------------------------------------------------------------------------

# * SDK Log

#-------------------------------------------------------------------------------

if Object.const_defined?(:SDK)

  SDK.log('System.HotKeyShutdown', 'Kain Nobel ©', 3.5, '2009.06.17')

end

 

#===============================================================================

# ** QuickShutdown

#===============================================================================

 

module QuickShutdown

  #-----------------------------------------------------------------------------

  # * Button to trigger the game to close

  #-----------------------------------------------------------------------------

  Button = Keys::ESCAPE

  #-----------------------------------------------------------------------------

  # * Scenes which don't allow this hotkey to be utilized

  #-----------------------------------------------------------------------------

  Xclude = ['Scene_FullScreen', 'Scene_Splash']

end

 

#===============================================================================

# ** Graphics

#===============================================================================

 

class << Graphics

  #-----------------------------------------------------------------------------

  # * Alias Listings

  #-----------------------------------------------------------------------------

  alias_method :exithotkey_graphics_update, :update

  #-----------------------------------------------------------------------------

  # * Update

  #-----------------------------------------------------------------------------

  def update

    exithotkey_graphics_update

    if Input.trigger?(QuickShutdown::Button)

      unless QuickShutdown::Xclude.include?("#{$scene.class}") || $scene.nil?

        $game_system.se_play($data_system.actor_collapse_se)

        Audio.bgm_fade(800)

        Audio.bgs_fade(800)

        Audio.me_fade(800)

        $scene = nil

      end

    end

  end

end

Instructions

Place above 'main'

FAQ

The "Button" by default is F8 (Input::F8) but you can set it to anything, for instance if you're using a AWorks Input/Keys you could set it to Keys::ESCAPE if you'd like
In order to exclude scenes from allowing the one-button shutdown, just place the scene's name (as a String) into the Xclude array.

Lets say you don't want the key to work at the title screen or in battle, then it would be set like...

Xclude = ['Scene_Title', 'Scene_Battle']

Compatibility

Graphics.update

Terms and Conditions

Bah, credit me or whatever :P
 
hi !

I think you can change the line :
Code:
alias_method :exithotkey_graphics_update, :update
with this to prevent stack bugs due to aliases:
Code:
alias_method :exithotkey_graphics_update, :update unless $@

berka
 
Alot more effecient...

Code:
if $f12_fix.nil?

f12 = Thread.new {

  $f12_fix = Win32API.new('user32', 'keybd_event', 'LLLL', '')

  $f12_fix.call(0x7B,0,0,0)

  sleep(0.1)

  $f12_fix.call(0x7B,0,2,0)

}

f12.priority = 1

end

What it does, when you get a STLD from F12, it opens up the Game.exe as a new Thread, or something of that nature (maybe Z could explain it better, I honestly don't know how he figured this one out.) Basically, when the F12 error does occur, you probably won't even notice it.

If you ever get a STLD when resetting, with this snippet, then its not F12 but an actual problem with one of the scripts in your project. In theory, you can paste it anywhere (I have it pasted right in the middle of all my chaos) but I'd suggest pasting it one space above 'main'.
 

Zeriab

Sponsor

I am not really sure where you got that Kain, but it's not my F12 fix.
This is:
[ruby]#=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
[/ruby]

I have also made a script which pauses the game when F12 is pressed (RMXP only)
viewtopic.php?f=11&t=64701

Since you are changing a hidden class I would suggest only aliasing the method if you haven't done so already:
[ruby]unless method_defined?:)exithotkey_graphics_update)
  alias_method :exithotkey_graphics_update, :update
end
[/ruby]

*hugs*
- Zeriab
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top