[XP]Need Help!

Started by mineox100, February 15, 2012, 03:43:18 pm

Previous topic - Next topic

mineox100


I got this error after trying to create my own Scene.  :roll:
Here is the scene I created:
Spoiler: ShowHide
#==============================================================================
# * Scene_Gift
#==============================================================================

class Scene_Gift
  #--------------------------------------------------------------------------
  # * Main Processing
  #--------------------------------------------------------------------------
  def main
    # Command Window
     s1 = "Get Gift"
     s2 = "Return"
     @command_window = Window_Command.new(160, [s1, s2])
     @command_window.index = @menu_index
     @command_window.index = 0
    # Execute transition
    Graphics.transition
    # 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
    # Prepare for transition
    Graphics.freeze
    # Dispose of windows
    @window.dispose
  end
  #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  def update
    # Update windows
    @window.update
    # If C button was pressed
    if Input.trigger?(Input::C)
    # Branch by command window cursor position
      case @command_window.index
      when 0  # Get Gift
        command_mgift
      when 1 # Return
      # Play cancel SE
       $game_system.se_play($data_system.cancel_se)
      # return to title
       $scene = Scene_Menu.new
     end
   end
end
end

SBR*


     @command_window.index = @menu_index
     @command_window.index = 0

You haven't defined the @menu_index variable yet.


@window.update

There is no defined @window variable.

However, I don't see why those problems would cause that particular error. I'm probably missing something...

KK20

At the line "@command_window.index = @menu_index", the method "index=(index)" under the class Window_Selectable is called. Within this method, "update_cursor_rect" is called. And, if you look at Line 102, you'll find "if @index < 0".

You set @index to equal @menu_index, but as SBR said, @menu_index has no value. Thus, @index = nil.

The error is being thrown because...well, what does nil < 0 mean?

Solution: Remove "@command_window.index = @menu_index" from your scene.

Other Projects
RPG Maker XP Ace  Upgrade RMXP to RMVXA performance!
XPA Tilemap  Tilemap rewrite with many features, including custom resolution!

Nintendo Switch Friend Code: 8310-1917-5318
Discord: KK20 Tyler#8901

Join the CP Discord Server!

mineox100

 :( I got that error out, now this shows up:


I gotta take more tutorials... :(

KK20

Quote from: SBR* on February 15, 2012, 04:30:08 pm

@window.update

There is no defined @window variable.


Change that line to @command_window.update

Don't worry. Windows and scenes were difficult for me too. It took me about a good 3-6 months before I understood what everything did.

Other Projects
RPG Maker XP Ace  Upgrade RMXP to RMVXA performance!
XPA Tilemap  Tilemap rewrite with many features, including custom resolution!

Nintendo Switch Friend Code: 8310-1917-5318
Discord: KK20 Tyler#8901

Join the CP Discord Server!

mineox100

So... after I pressed "Return"... The window and the command things were still there...

KK20

    # Dispose of windows
    @command_window.dispose

Change that line because, once again, @window is undefined.

Also, what is command_mgift? You don't have it defined here.

Other Projects
RPG Maker XP Ace  Upgrade RMXP to RMVXA performance!
XPA Tilemap  Tilemap rewrite with many features, including custom resolution!

Nintendo Switch Friend Code: 8310-1917-5318
Discord: KK20 Tyler#8901

Join the CP Discord Server!

mineox100

I'm working on that, it's not finished :P
I guess no more error huh?