Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

Newbie window question

Drykul

Member

Ok, just to start off, I've used RPG Maker since 95 was new. I've taken big breaks here and there. When XP came out, I started learning how to use RGSS, but didn't get too far before I gave up. Now I'm having a go with VX and hoping I'll last longer. So far, so good. First of all, I know what variables, arrays, hashes, methods, classes, etc all are and what they do. But I'm having some other newbie problems that I feel stupid that I can't figure out on my own.

For one, I remember XP having a script call function in the events where all you had to do was put in the class, with VX it doesn't seem to work the same. For instance, I was reading an old RGSS tutorial and the basis was this:
Code:
class Say_something

  def initialize
     print "Say Something"
  end

end

Pretty simple, but I loaded up an event with the call script of Say_something.new, and it didn't work. I'm sure someone call tell me what I'm doing wrong.

Secondly, One thing I'm trying to do is create two seperate windows at the same time. The bottom window has different options to select and the top window displays info about the selected item. A couple of questions about that.

For the life of me, I can't figure out why I'm getting a "ArgumentError occurred while running script. wrong number of arguments(0 for 4)wth this:
***EDIT***
Ok, I figured out how to get both windows up at the same time in the right places. They both come up at the same time, like expected, but after a couple of seconds, the top window just disappears. ?? I've got both windows in seperate classes being called seperatly by an event. Is that not the proper way of doing it?
***END EDIT***
Code:
class Windows < Window_Base

   #Top window with description
   def top_win
      super(0, 0, 544, 312)
      self.contents = Bitmap.new(width - 32, height - 32)
   end

   #Bottom selectable window
   def bot_win
      super(0, 313, 544, 104)
      self.contents = Bitmap.new(width - 32, height - 32)
   end

end

And also, how do I go about pausing the game in the background while my window is up?
 
For the script call, if you just use Say_something.new, nothing will hapen because you're not creating it as a variable.
Most of the time, you have to create a variable to use your class:
Code:
@variable = Say_something.new
Sometimes, you can creates methods like "def self.speak" and then simply use Say_Something.speak to see the effect but it's unlikely that you will use and see that unless you're making a Module. I think classes like Font uses this.

Now about your windows. 1 Window class = 1 Window. You can't have multiple windows by creating only 1 Window class.
If you want to have multiple instance of the same window, simply create more variables like:
Code:
@window1 = My_Window.new
@window2 = My_Window.new
@window3 = My_Window.new
If you want your windows to be different at their initialization then you will have to create each of 'em separetly.
Like;
Code:
class Window1 < Window_Base
class Window2 < Window_Base
class Window3 < Window_Base

Later, you can change the x,y,width and height properties of a specific window by using for example
Code:
@window1.x = 64
@window2.width = 256
@window3.z = 1024

Also, the "super" word doesn't only create windows. super is a reserved work to call the method in which it is used with it's own arguments.
In your example, since class Windows is a child class of Window_Base, you would need to create the top_win method in Window_Base
like that
Code:
def top_win(x,y,width,height)
and then use super as you did in your Windows class.
 

Drykul

Member

Ahhhh, ok. I see what I was doing wrong. Thanks a ton Dargor. I was using the same variable name in the call event, therefore whichever window was called first would be replaced by the second window... Got it, got it.

And with the first sample script Say_something, in the event call, I didn't have the s in Say capitalized... Great, thanks for the fast replies!
 
Dargor":1at27lwf said:
For the script call, if you just use Say_something.new, nothing will hapen because you're not creating it as a variable.
Most of the time, you have to create a variable to use your class:
Code:
@variable = Say_something.new
No, you don't have to create a variable for it, thought if you don't, you'll only be able to call the initialize method. :thumb:
 

Drykul

Member

Ok, so how about getting the rest of the game to pause while these windows are up now?

The questions I have now are:

I have the bottom window class set to < Window_Selectable, but I can't seem to figure out how to put selectable options in it. self.contents.draw_text doesn't work.

So a quick recap of my questions:

How do I get selectable options in the bottom window, how will I get the info in the top window to update when an option is being "hovered" over in the bottom window, and how do I get the game in the background to pause while this is going on?

I don't want someone to practically write the script for me, which I know is what it seems like, so if you could point me in the right direction, or give me hints and clues, that'd be wonderful too. Once I pick this up, I'll be helping people as much as possible, no doubting that. So thanks for all the help getting me kick started!
 
oh, sorry about that man, here.
Code:
#==============================================================================
# ** Scene_Example
#------------------------------------------------------------------------------
#  This is just an example scene.
#==============================================================================

class Scene_Example < Scene_Base
  #--------------------------------------------------------------------------
  # * Start processing
  #--------------------------------------------------------------------------
  def start
    super
    create_menu_background
    #### Create Windows ####
  end
  #--------------------------------------------------------------------------
  # * Termination Processing
  #--------------------------------------------------------------------------
  def terminate
    super
    dispose_menu_background
    #### Dispose Windows ####
  end
  #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  def update
    super
    update_menu_background
    #### Update Windows ####
  end
end
and then you use this to call it
Code:
$scene = Scene_Example.new

You're using VX right? otherwise this wont work.
 

Drykul

Member

Ok, here's what I got out of that. Instead of making it < Window_Selectable, I need to make the class < Scene_Base. Correct?

Well, maybe if I understood what a "scene" actually was it would help. Or why or when you'd use < Window_Selectable or Window_Command?

I'm assuming the Scene_Base makes it a whole new entity that will function independantly of anything else that's going on at the moment? If you can explain it better I'd appreciate it.

SO, I'd be calling a scene in which to create the window in, am I correct? LoL, I'm pretty confused, I think I'll stop talking about it and read some more on it and hope for a quick reply.
 

Drykul

Member

Well, I'm going over Dubealex's tuts. They're very good. I think I've almost got it figured out finally. Don't you love it when you don't have a clue, then all of a sudden you're just like OOHHH! and then you feel really stupid afterwards as it should of been obvious?

That's how I've been feeling multiple times for about the past hour. :D
 
S S Muu":1oem97mx said:
Dargor":1oem97mx said:
For the script call, if you just use Say_something.new, nothing will hapen because you're not creating it as a variable.
Most of the time, you have to create a variable to use your class:
Code:
@variable = Say_something.new
No, you don't have to create a variable for it, thought if you don't, you'll only be able to call the initialize method. :thumb:

Say_Something.new.other_method :P
 
Replace
Code:
#### Create Windows ####
with (and replace x, y, width, height with the numbers you want)
Code:
@some_window = Window_Base.new(x, y, width, height)
and
Code:
#### Dispose Windows ####
with
Code:
@some_window.dispose

Code:
#### Update Windows ####
with
Code:
@some_window.update

You can also add more windows like
Code:
@some_window = Window_Base.new(x, y, width, height)
@some_window2 = Window_Base.new(x, y, width, height)
@mee = Window_Base.new(x, y, width, height)
@whoh = Window_Base.new(x, y, width, height)

Hope it helps :thumb:

Cowlol":s89desek said:
S S Muu":s89desek said:
Dargor":s89desek said:
For the script call, if you just use Say_something.new, nothing will hapen because you're not creating it as a variable.
Most of the time, you have to create a variable to use your class:
Code:
@variable = Say_something.new
No, you don't have to create a variable for it, thought if you don't, you'll only be able to call the initialize method. :thumb:

Say_Something.new.other_method :P
Well, yeah, I guess that's true :P
 

Drykul

Member

Ok, I've been trying to figure this out for a couple days now, and I normally get stuff like this pretty easily, but I just can't seem to grasp the concept just yet. Making the two windows is easy enough:

Code:
class Top_Win < Window_Base
  def initialize
    super(0, 0, 544, 312)
    self.contents = Bitmap.new(width - 32, height - 32)
    refresh
  end
  
  def refresh
    self.contents.clear
  end
end

class Bot_Win < Window_Base
  def initialize
    super(0, 312, 544, 104)
    self.contents = Bitmap.new(width - 32, height - 32)
    refresh
  end
  
  def refresh
    self.contents.clear
  end
end

I understand what every command in that code is doing. But I still don't understand how to make the bottom window a window with options that you can select. I think I have an idea on how to get the top window to update when an option is just highlighted on the bottom window. And I'm not really sure how to get the game to pause when these windows come up, kind of like when you press esc and go to the menu, the rest of the game stops, but you can still access the menu? Sorry if it's frustrating to you, believe me, it is to me too. I'm assuming I have to do something with Window_Command? And I still don't understand why I would need to call a scene, what a scene really is, and what a scene is used for... :(
 
I'm not exactly sure what you're trying to display in your windows but for the bottom window rather than having Window_Base as the parent why not have Window_Selectable (I'm at school btw so can't check the scripts exactly). Also if you want to dsisplay things such as names, facesets, and sprites then just look through the equip, skill etc windows and you can see the code to call them.

When I was trying out VX I managed to get a window working but I stopped because I decided to use XP instead, I couldn't stand the VX RTP.

I suggest you look at the other Scenes and Windows and see which achieve the effect you want that way you can just steal it rather than working out the code yourself. Works for me anyway, and as long as you understand it you'll learn more about coding too.
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top