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.

Quick Alias/Hud/Command Question

Hi i have a question, if i am making a window that has choices on it like a regular option window. But the window is going to be on Scene_Map, like this:
I was trying a few things
Code:
class Scene_Map
  alias old_main main
  alias old_update update
  def main
    s1 = 'Quest::Name[1]'
    s2 = 'Quest::Name[2]'
    $cmd_window = Window_Command.new(160, [s1, s2])
    $cmd_window.visible = true
    $cmd_window.active = false
    old_main
    $cmd_window.dispose
  end
  def update
    $cmd_window.update
    old_update
    if $cmd_window.active
      update_quest
      return
    end
    if Input.trigger?(Input::C)
      unless $game_system.map_interpreter.running?
        Graphics.freeze
        @spriteset.freeze
        $cmd_window.active = true
      end
    end
    unless $game_player.moving?
      call_quest
    end
    if $game_temp.quest_window_showing
      return
    end
  end
  def call_quest
    $game_player.straighten
    $game_temp.quest_calling = false
  end
  def update_quest
    # nothing yet
  end
end
my problem is, when i start the game the character either moves with my options or when i freeze the graphics and update him the character ends up in a different spot, any reason why this is? I appreciate the help, its had me stumped, and as you can see I have tried several different ways!
:)
 

khmp

Sponsor

I'm not a 100% on what you're trying to accomplish with your quest window when looking at your code, so I took some liberties with your update code. I apologize for this. But before that I'll try to explain the problem. The character was moving because input was being handled in Scene_Map old_update, well actually game_player.update, causing the player to move. But before the next frame was being drawn. Graphics.Freeze/spriteset.freeze was being hit hiding the movement until the window became inactive. At least that's my thought about it.

Alright so I cut out some stuff and moved all the code above alias old_update. My thought process was to restrict entry to old_update if the quest window is active and that's about all.

Code:
  def update
    # Update quest window
    $cmd_window.update
    
    # See if the user would like to adjust focus to or from the quest window.
    unless $game_player.moving?
      if Input.trigger?(Input::C)
        $cmd_window.active = !$cmd_window.active
      end
    end
    
    # If the quest window is active perform quest window work then return.
    if $cmd_window.active
      update_quest
      call_quest
      return
    end
    
    old_update
  end

In any case good luck with it! :thumb:
 

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