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.

Why isn't my Command Window showing up?

I apologize in advance for what is probably a really dumb, noobish question. I've trying to properly learn scripting so that I can make a CBS. I'm still playing around, but what I've done is make the Scene_Map class call my Scene_CustomBattle class instead of the normal Scene_Battle.

Now, all I'm trying to do so far is to make a command window pop up on the screen (basically, I want my battles to be on the same map that players run around on normally).

Here's my code so far (pardon my sloppiness and extraneous code, I realize it's filled with unnecessary stuff):

Code:
class Scene_CustomBattle
  def main
    # Make actor command window
    s1 = "Exit combat"
    s2 = $data_system.words.skill
    s3 = $data_system.words.guard
    s4 = $data_system.words.item
    @actor_command_window = Window_Command.new(160, [s1, s2, s3, s4])
    @actor_command_window.y = 160
    @actor_command_window.back_opacity = 160
    @actor_command_window.visible = true
    @actor_command_window.active = true
    # Main loop
    loop do
      # Update game screen
      Graphics.update
      # Update input information
      Input.update
      # Frame update
      update
      # Abort loop if screen is changed
      if $scene != self
        break
      end
    end  
  end
    
  def update
    @actor_command_window.update
    @actor_command_window.refresh
    # If B button was pressed
    if Input.trigger?(Input::B)
      # Play cancel SE
      $game_system.se_play($data_system.cancel_se)
      # Dispose of windows
      #@actor_command_window.dispose
      # Switch to map screen
      $scene = Scene_Map.new
    end
    if Input.trigger?(Input::C)
      $game_system.se_play($data_system.decision_se)
    end
  end

end

The window doesn't show at all, but I know it's there because I can hear the sounds of me moving the cursor. When I "exit" my custom battle, the window suddenly appears. What am I doing wrong? I'd greatly appreciate any advice.
 

khmp

Sponsor

I would dispose of the window after the loop breaks in main. In the update method get rid of the call to refresh from the command window. The update call above it will determine whether or not the window needs to be redrawn. Then to actually answer your question add this line right below:
Code:
@actor_command_window.active = true
@actor_command_window.z = 9999
Not sure if it's a problem with z but it sounds like it. The reason the window hangs around after you exit the scene is because it wasn't disposed of. Tell me if it works out for you or not.

Good luck with it! :thumb:
 
Thanks a lot, I cleaned up my code according to your suggestions. However, my window still isn't showing up, although I know it's there because I can hear the sounds of my cursor moving/selecting stuff.  :(

Any other ideas?
 

khmp

Sponsor

Oh oh wait I got it. I think it's a scene thing. Above the loop and right after the end of the loop you need two lines of code.
Code:
Graphics.transition
loop do
  ...
end
Graphics.freeze
 
Awesome, that helped a bit...the window is finally showing up. However, the rest of the screen besides the window goes black (but I want to keep the Scene_Map...basically, I want the battle command window to pop up on the main map). Is there any easy way to do this? If not, thanks for your help regardless.
 

khmp

Sponsor

I believe what you want is a Spriteset_Map object. < That was the very first question I asked when I came to these forums :)

So above the Graphics.transition insert this line:
Code:
@spriteset = Spriteset_Map.new
And don't forget to dispose of it so below the Graphics.freeze:
Code:
@spriteset.dispose
 

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