(http://i.imgur.com/pCXpn.png)
I got this error after trying to create my own Scene. :roll:
Here is the scene I created:
#==============================================================================
# * 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
@command_window.index = @menu_index
@command_window.index = 0
You haven't defined the @menu_index variable yet.
There is no defined @window variable.
However, I don't see why those problems would cause that particular error. I'm probably missing something...
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.
:( I got that error out, now this shows up:
(http://i.imgur.com/3GOAn.png)
I gotta take more tutorials... :(
Quote from: SBR* on February 15, 2012, 04:30:08 pm
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.
So... after I pressed "Return"... The window and the command things were still there...
# 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.
I'm working on that, it's not finished :P
I guess no more error huh?