Chaos Project

RPG Maker => RPG Maker Scripts => Script Troubleshooting => Topic started by: mineox100 on February 15, 2012, 03:43:18 pm

Title: [XP]Need Help!
Post by: mineox100 on February 15, 2012, 03:43:18 pm
(http://i.imgur.com/pCXpn.png)
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
Title: Re: [XP]Need Help!
Post by: SBR* on February 15, 2012, 04:30:08 pm

     @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...
Title: Re: [XP]Need Help!
Post by: KK20 on February 15, 2012, 05:17:08 pm
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.
Title: Re: [XP]Need Help!
Post by: mineox100 on February 16, 2012, 03:04:18 pm
 :( I got that error out, now this shows up:
(http://i.imgur.com/3GOAn.png)

I gotta take more tutorials... :(
Title: Re: [XP]Need Help!
Post by: KK20 on February 16, 2012, 04:23:37 pm
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.
Title: Re: [XP]Need Help!
Post by: mineox100 on February 17, 2012, 05:17:50 pm
So... after I pressed "Return"... The window and the command things were still there...
Title: Re: [XP]Need Help!
Post by: KK20 on February 17, 2012, 06:05:45 pm
    # 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.
Title: Re: [XP]Need Help!
Post by: mineox100 on February 18, 2012, 07:39:14 am
I'm working on that, it's not finished :P
I guess no more error huh?