Jump to content
Sign in to follow this  
SymbolsWriter

Galv’s Invader Mini Game - Add Exit Menu

Recommended Posts

Guys. I think I need some help.

I want to use Galv's awesome Invader Mini Game script, but there's one thing I don't like about it: when you press ESC the minigame just closes and exits to the map. I want to make it so that when you press ESC the minigame would pause and ask you if you want to quit.

I'm not a scripter, but after looking on the web I managed to steal edit and repurpose some code into this, which I added after Galv's script:

#Initializes the dialogue choice into a window with appropriate keys
class Window_InvadersExit < Window_Command
  def initialize
    #window placement location
    super(0,0)
    self.x = (Graphics.width - width) / 2
    self.y = (Graphics.height - height) / 2
  end

  def visible_line_number
    return 2
  end

  def window_width
    return 100
  end

  #creates the command keys list for choices
  def make_command_list
    add_command("Resume", :Inv01)
    add_command("Quit", :Inv02)
  end

end

#Sets objects in the window to play them in a new "scene"
class Scene_InvadersMenuExit < Scene_MenuBase

  def start
    super
    create_background
    create_choices
  end

  #creates the command window for choices
  def create_choices
    @dtest = Window_InvadersExit.new
      @dtest.set_handler(:Inv01, method(:InvResume))
      @dtest.set_handler(:Inv02, method(:InvExit))
    end

  #resume
  def InvResume
    SceneManager.return
  end

  #exit
  def InvExit
    SceneManager.goto(Scene_Map)
  end

end

While also replacing this (line 322 of original script):

if Input.trigger?(:
      SceneManager.goto(Scene_Map)

with this:

 if Input.trigger?(:
      SceneManager.call(Scene_InvadersMenuExit)

What it does is call a menu with two choices (Resume and Quit) upon pressing ESC. But when selecting Resume (returning to the minigame scene), instead of continuing, the minigame restarts.

 

Again, I'm not a scripter, so I may be principally wrong in what I'm doing, but the problem as I see it is with pausing the minigame scene without losing the progress made, and I just don't understand how to achieve this.

 

Can I have some help please?

Share this post


Link to post
Share on other sites

Don't make a new Scene for exit :|

if Input.trigger?(:
      create_choice

However, the game doesn't use Window so you can't pause it normally.

Put this under the game's script:

#
#Add your window-exit class here
#

class Scene_Invaders < Scene_Base
  alias dmtk_pause_update update
  def update
  if @dtest && !@dtest.disposed?
    @dtest.update
  else
    dmtk_pause_update
  end

  def create_choices
    @dtest = Window_InvadersExit.new
    @dtest.set_handler(:Inv01, method(:InvResume))
    @dtest.set_handler(:Inv02, method(:InvExit))
  end

  def InvResume
    @dtest.dispose
  end

  def InvExit
    SceneManager.goto(Scene_Map)
  end
end

Share this post


Link to post
Share on other sites

Ohhh, thanks a lot!

After tinkering with your script for a bit I think I've managed to get it working.

Here's the end result if anyone needs it in the future.

 

 

Replace this (line 322-323 of minigame script):

 if Input.trigger?(:
      SceneManager.goto(Scene_Map)
with this:

if Input.trigger?(:
       create_choices
And add this after the whole minigame script:

#Initializes the dialogue choice into a window with appropriate keys
class Window_InvadersExit < Window_Command
  def initialize
    #window placement location
    super(0,0)
    self.x = (Graphics.width - width) / 2
    self.y = (Graphics.height - height) / 2
  end

  def visible_line_number
    return 2
  end

  def window_width
    return 100
  end

  #creates the command keys list for choices
  def make_command_list
    add_command("Resume", :Inv01)
    add_command("Quit", :Inv02)
  end

end

#Edit scene invaders
class Scene_Invaders < Scene_Base
alias dmtk_pause_update update
  def update
  if @dtest && !@dtest.disposed?
    super
  else
    dmtk_pause_update
  end
  end

  def create_choices
    @dtest = Window_InvadersExit.new
    @dtest.set_handler(:Inv01, method(:InvResume))
    @dtest.set_handler(:Inv02, method(:InvExit))
  end

  def InvResume
    @dtest.dispose
    @dtest = nil
  end

  def InvExit
    SceneManager.goto(Scene_Map)
  end
end

 

I think I'll try to make a similar menu appear on game over and post script here a bit later.

 

ETA: And here's the version that makes the menu also appear on gameover:

 

 

Replace this (line 309-315 of minigame script):

def update_game_over
    @game_over.opacity += 3
    if @game_over.opacity >= 255 && Input.trigger?(:C)
      dispose_graphics
      initialize_game
    end
  end
with this:

def update_game_over
    @game_over.opacity += 3
    if @game_over.opacity >= 255 && Input.trigger?(:C)
      create_choices (@dead)
    end
  end
And replace this (line 322-323 of minigame script):

if Input.trigger?(:
      SceneManager.goto(Scene_Map)
with this:

if Input.trigger?(:
       create_choices (@dead)
And add this after the whole minigame script:

#Initializes the dialogue choice into a window with appropriate keys
class Window_InvadersExit < Window_Command
  def initialize (dead)
    #window placement location
    @dead = dead
    super(0,0)
    self.x = (Graphics.width - width) / 2
    self.y = (Graphics.height - height) / 2
  end

  def visible_line_number
    return 2
  end

  def window_width
    return 100
  end

  #creates the command keys list for choices
  def make_command_list
    if !@dead
      add_command("Resume", :Inv01)
    else
      add_command("Retry", :Inv03)
    end
    add_command("Quit", :Inv02)
  end

end

#Edit scene invaders
class Scene_Invaders < Scene_Base
alias dmtk_pause_update update
  def update
  if @dtest && !@dtest.disposed?
      if !@dead
      super
      else
      dmtk_pause_update
      end
    else dmtk_pause_update
  end
  end

  def create_choices (dead)
    @dtest = Window_InvadersExit.new (dead)
    @dtest.set_handler(:Inv01, method(:InvResume))
    @dtest.set_handler(:Inv02, method(:InvExit))
    @dtest.set_handler(:Inv03, method(:InvRetry))
  end

  def InvResume
    @dtest.dispose
    @dtest = nil
  end

  def InvExit
    SceneManager.goto(Scene_Map)
  end
  
  def InvRetry
    dispose_graphics
    initialize_game
    @dtest.dispose
    @dtest = nil
  end
  
  
end

 

Edited by SymbolsWriter

Share this post


Link to post
Share on other sites
Guest
This topic is now closed to further replies.
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

×