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

RGSS Error

Question

Hi everyone. As some of you may know, that have been in the chat this past day, I have been learning RGSS and have taken a liking to it quite quickly. I know some basic commands, some variable stuff, etc.. But I've been following this tutorial Mr. Mo had written back in 2006 to make windows/menus etc.. SO, I thought I'd follow some of these takes and take some of the code and modify it to my liking to make a silly little menu system, however, I keep getting an error.

 

rgss.png

 

Now, here is the code:

################################################################################
# Custom Menu System(CMS) by Ecowolfsteen
################################################################################

class Custom < Window_Base
  super(560, 0, 233, 254)
    self.contents = Bitmap.new(width - 32, height - 32)
   refresh # Calls the refresh function in this class
 end

  def refresh
  self.contents.clear
  self.contents.font.color = normal_color
  self.contents.font.size = 20
  self.contents.draw_text(0, 0, 230, 30, "Menu")
end

#==============================================================================
# * Scene_ShowWindow
#==============================================================================

class Scene_ShowWindow
 #--------------------------------------------------------------------------
 # * Main Processing
 #--------------------------------------------------------------------------
 def main
   #call the window
   @window = Custom.new
   # 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
 end
end

 

Points for anyone who can find the mistake. Don't hit me, I'm still an RGSS noob. :<

Thanks guys. ^.^

Edited by Ecowolfsteen

Share this post


Link to post
Share on other sites

2 answers to this question

Recommended Posts

  • 0

:3 You are learning ruby :D good luck! It is a very beautiful and addictive language

 

I'll help you out with this one:

 

class Custom < Window_Base
  super(560, 0, 233, 254)
    self.contents = Bitmap.new(width - 32, height - 32)
   refresh # Calls the refresh function in this class
 end

 

What's happening is you are calling super (which calls the super class's method of the same name) outside of any method...I guess my explanation isn't much better than the error message but I can show you why, you have super directly below the class definition, where it should be below a method definition. In this case you need the initialize method (which is called when creating an instance of a class, ex: Custom.new)

 

so you simply need:

class Custom < Window_Base
 def initialize
   super(560, 0, 233, 254)
   self.contents = Bitmap.new(width - 32, height - 32)
   refresh # Calls the refresh function in this class
 end

 

now super is called within a method, and you won't get that pesky error. I might be able to explain better, but lack of sleep's got my brain in a knot XD

 

If you need a better explanation, lemme know :)

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...