Jump to content
New account registrations are disabed. This website is now an archive. Read more here.
  • 0
Sign in to follow this  
GreenBanana

Inexplicable Jukebox Line Error

Question

This script:

#############################   ##########  #     #  #   #  #######
# Juke Box Script           #        #      #     #  # #    #
# created by: Polraudio     #        #      #     #  ##     #####
# created on: June 16, 2006 #   #    #      #     #  # #    #
# version: 2.0              #   ######      #######  #   #  #######
# credits: Polraudio        #
#          modern algebra   #
################################################################################
# If you want to add your own Music just look through the script for comments  #
# I have instrusctions there                                                   #
#      Any questions, comments or bugs E-mail me at polraudio@Gmail.com        #
################################################################################
# THE SANTAX FOR NON SCRIPTERS                                                 #
# $scene=Scene_Juke.new
################################################################################
# ITEM SANTAX                                                                  #
# $game_party.item_number(@item.id) == 1                                       #
#                           1^     2^ 3^                                       #
# 1: replace "@item.id" with the item number                                   #
# 2: replace 1st "=" with ">" or "<" or leave it "==" to make it have to equal #
# >: if higher or equal to                                           that item #
# <: if lower or equal to                                                      #
# 3: how many of that item                                                     #
################################################################################
# PRINT SYNTAX                                                                 #
# print("text")                                                                #
#         1^                                                                   #
# 1: replace "text" with what ever text you want                               #
################################################################################
# MUSIC SYNTAX                                                                 #
# Audio.bgm_play("Audio/BGM/" + "name", bgm.volume, bgm.pitch)                 #
#       1^              2^        3^       4^          5^                      #
# 1: replace with "se", "me", "bgs", "bgm" what ever one you want to play      #
# 2: what ever you put for "1^" put the same here but make it all CAPS         #
# 3: replace "name" with what ever your song name is(NOTE:Not case sensitive)  #
# 4: replace "bgm.volume" with a value from 0-100                              #
# 5: replace "bgm.pitch" with a value from 0-100                               #
################################################################################
# DRAW_TEXT SYNTAX                                                             #
# self.contents.draw_text(4, 0, 128, 30, "Exit Juke Box")                      #
#                        1^ 2^  3^   4^        5^                              #
# 1: how far to the right the text is                                          #
# 2: how far down the text is                                                  #
# 3: how much the text is streched to the right                                #
# 4: how much the text is streched down                                        #
# 5: replace "Exit Juke Box" with what ever text you want                      #
################################################################################
class Window_Juke < Window_Selectable
 def initialize
   super(0, 64, 640, 414)   # super(0, 64, 480, 64)
   self.contents = Bitmap.new(width - 32, height - 32)
   @item_max = 36
   @column_max = 3
   @row_max = 33
   @commands = ["","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","",]
   refresh
   self.index = 0
 end
 def refresh
   self.contents.clear
   @music = ["EXIT", "013-Theme02", "008-Boss04", "029-Town07"]
   @item_max = @music.size
   for i in 0...@item_max
     draw_item(i)
   end
 end
 def draw_item(index)
   self.contents.draw_text(4 + 216*(index%3), 32*(index/3), 128, 30, @music[index])
 end  
end

class Scene_Juke
 def main
   #You can change the name of the songs here
   $command_window = Window_Juke.new
   $help_window = Window_Help.new
   $help_window.set_text("Play Music")
   Graphics.transition
   loop do
     Graphics.update
     Input.update
     update
     if $scene != self
       break
     end
   end
   Graphics.freeze
   $help_window.dispose
   $command_window.dispose
   if $scene.is_a?(Scene_Juke)
     Graphics.transition
     Graphics.freeze
   end
	end
def update
 $help_window.update
   $command_window.update
   if Input.trigger?(Input::B)
     $game_system.se_play($data_system.cancel_se)
     $scene = Scene_Map.new
     return
   end
   if Input.trigger?(Input::C)
     case $command_window.index
     when 0
       $game_system.se_play($data_system.cancel_se)
       $scene = Scene_Map.new
     when 1...3
        Audio.bgm_play("Audio/BGM/" + @music[$command_window.index], 100, 50)
     end
     return
   end
 end
end

 

Gives this error:

Script '*Scene_Juke Box2(NEW)' line 109: NoMethodError occurred.

undefined method `[]' for nil:NilClass

 

...when you select a song to play from the Jukebox menu. So therefore the line "Audio.bgm_play("Audio/BGM/" + @music[$command_window.index], 100, 100)" has a problem. I've pinpointed the problem to be with "@music[$command_window.index]". This makes absolutely no sense whatsoever as @music is clearly defined as an array up above, and the reference $command_window.index is clearly a readable variable as evidenced by the functioning lines about the whencase statements.

Share this post


Link to post
Share on other sites

6 answers to this question

Recommended Posts

  • 0
Script '*Scene_Juke Box2(NEW)' line 109: NoMethodError occurred.

 

undefined method `[]' for nil:NilClass

 

If you did not make it did you try asking the person who did?

Share this post


Link to post
Share on other sites
  • 0

If you did not make it did you try asking the person who did?

Why should they be around to answer?

 

Anyways, the problem was that the two people working on the script before did not keep track of the fact that @music should have been $music instead. Which means they must have given up on their script, because it shouldn't have worked as-is. Well, I got it to work then.

 

Now the only problem that remains is finding out how RGSS can determine whether an audio file is a midi or an mp3.

Share this post


Link to post
Share on other sites
  • 0

It gives contact info right at the top. Plus Polraudio is an active member right here on this site. Modern Algebra can be contacted at RMRK.

Share this post


Link to post
Share on other sites
  • 0

It gives contact info right at the top. Plus Polraudio is an active member right here on this site. Modern Algebra can be contacted at RMRK.

Doesn't necessarily mean a reply's guaranteed! :rolleyes: Anyway, as mentioned above, the problem has been solved. Thanks anyways for your help! :)

Share this post


Link to post
Share on other sites
  • 0

Doesn't necessarily mean a reply's guaranteed! :rolleyes: Anyway, as mentioned above, the problem has been solved. Thanks anyways for your help! :)

 

 

Take a look at the post above this one. Look who's here. :P

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...