Hey Matt. It is much appreciated that you try to help.
Please do a test run before posting example code as that would have exposed the errors in your example.
I suggest you place the code in a
block and use the Ruby commenting so the code can be directly pasted into the editor without the comments giving errors. This would give you this:
class Scene_Awesome
def main #(Main or Start in VX, is were the program begins)
super(x, y, width, height) #(Very important! always have this in main this is the SIZE of your scene)
Window_display_name #(This is the name of our window were calling out)
end
end
Class Window_Display_Name < Window_Base #(This means that it's a base window. Only used for displaying graphics)
def main
super(x,y,width,height) #(The size of your window)
self.contents.draw(x,y,size,"Hello! How are you!", side alingment)
end
end
Whether or not the parenthesis should be there is merely are matter of style.
On to the more serious matters.
Ruby is case-sensitive meaning that
Hello,
hello and
hELLo all are different to ruby.
Case-sensitive problems highlighted with red":x2rxiwl3 said:
class Scene_Awesome
def main #(Main or Start in VX, is were the program begins)
super(x, y, width, height) #(Very important! always have this in main this is the SIZE of your scene)
Window_display_name #(This is the name of our window were calling out)
end
end
Class Window_Display_Name < Window_Base #(This means that it's a base window. Only used for displaying graphics)
def main
super(x,y,width,height) #(The size of your window)
self.contents.draw(x,y,size,"Hello! How are you!", side alingment)
end
end
As you can see I have highlighted some more areas in your code.
The green area is just a little nitpick about you would normally call it
side_alignment rather than
side alignment so you have a local variable rather than a syntax error.
The blue area is about you first stating it's for VX while in VX you would have had
Scene_Awesome < Scene_Base. The one shown is how it is done in XP.
The next is the main of super class you are calling with 4 arguments. The super class of Scene_Awesome is Object which by default do not have a method named
main. In VX the main-method in Scene_Base takes no arguments. This line should simply be deleted. (You can't simply apply the logic from the Window_XXX classes in the Scene_XXX classes)
The orange area also includes
Window_display_name where I wonder what the purpose is of simply looking at the constant. Right now you would simply return the class to whatever is calling the main-method.
Normally you would create a new window
Window_Display_Name.new, store it in a variable and do stuff with it.
The teal area is about the main method in
Window_Display_Name. This is not the method you want. You want the
initialize method, which is called when you create an instance of the class.
The purple area is about
self.contents, the Bitmap which you draw upon. You need to create it first with something like
self.contents = Bitmap.new(width - 32, height - 32) or you will get an error.
The brown area is about a method which does not exist for Bitmaps. You want the
draw_text method, not the
draw method. (Note that the syntax can be looked up in the help file)
I would change the code to something like this:
class Scene_Awesome
def main #(Main is were the program begins)
window = Window_Display_Name.new #(This is the name of our window were calling out)
# Do stuff
window.dispose # Let's remove it again
end
end
class Window_Display_Name < Window_Base #(This means that it's a base window. Only used for displaying graphics)
def initialize
super(0, 0, 230, 64) #(x, y, width, height) - The size of your window
self.contents = Bitmap.new(width - 32, height - 32)
side_alignment = 1 # 0 = left, 1 = center, 2 = right
self.contents.draw_text(x, y, width - 32, height - 32, "Hello! How are you!", side_alignment)
end
end
Do you see the difference? This is a working example. You can put
Window_Display_Name.new in the script call of an event to test it. You can't really test the scene since its not finished at all. Had it been finished you could have tested it with
$scene = Scene_Awesome.new, but right now I believe you will just get a
Script Hanging error after a while.
This reminds me. It's not correct to do
$Scene_Awesome.new since $Scene_Awesome is a global variable which is not the same as Scene_Awesome. Scene_Awesome is a constant.
Basically:
- $variable is a global variable
- Variable is a constant. (Yeah, it shouldn't really be a variable, it should be constant. I.e. not changing)
- variable is a local variable
- @variable is an instance variable
- @@variable is a class variable
Nevertheless it's nice to see you have put an effort in your post despite the errors. Keep learning :D
@drerius: I am sorry for high-jacking your thread like this. I do hope that you have learned something about finding errors from this and even if a script looks alright at a first glance it might not be so.
*hugs*
- Zeriab