[ACE]Creating a selectable window

Tomasz

Warper
Member
Joined
Aug 2, 2012
Messages
4
Reaction score
0
First Language
Polish
Primarily Uses
Hello there, I wanted to point out that I'm a complete beginner in scripting.

I'm skilled in RPG Maker 2003, but never really adapted to the scripts of later RPG Makers.

Recently I tried making a new game in RPG Maker VX Ace, with most things customly made. I created a custom battle system with events, and it works quiete well. However the battle system needs a seperate custom menu, and making it with just events would be difficult. I want to try making it with scripts.

I tried finding tutorials for complete beginners about windows (So I can create the menu system with them), and I found this one:

http://www.rpgrevolu...indows_265.html

This one worked fairly well, everything explained there worked fine.

However, I checked the second part:

http://www.rpgrevolu...indows_272.html

And while I can create a window with selectable options, I can't move the cursor. It's always stuck on the first item on the window, and can't select anything else. It might be because these tutorials are intended for RPG Maker XP. How would I make this work for RPG Maker VX Ace?

Also if anyone can point me out to tutorials for scripting beginners like me for RPG Maker VX Ace, I would greatly appreciate it!
 
Last edited by a moderator:

Mr. Bubble

Makes stuff.
Member
Joined
Mar 1, 2012
Messages
853
Reaction score
163
And while I can create a window with selectable options, I can't move the cursor. It's always stuck on the first item on the window, and can't select anything else. It might be because these tutorials are intended for RPG Maker XP. How would I make this work for RPG Maker VX Ace?
In VX Ace, you need to activate the window:



Code:
# Assuming that @my_window is initialized as a window object
@my_window.activate
I'll move this to the Learning Ruby and RGSSx section.
 
Last edited by a moderator:

Tomasz

Warper
Member
Joined
Aug 2, 2012
Messages
4
Reaction score
0
First Language
Polish
Primarily Uses
Thank you for the help Mr.Bubble, however "activate" didn't seem to work anywhere (It would just give me "undefined method" errors).

While researching this problem and trying to make it work, I found this: http://www.rpgmakerv...php/t30285.html This person seemed to have a similar problem.

I added in $window.active=true in the event. That makes it work a little bit better: The player can't move anymore, and the item on the menu is now high lighted (the border around the text is flashing, which didn't happen before). However I still can't move the cursor up and down. I can select the first item, just not move the cursor.

I tried making a Scene class (Similar to the one in that link), however I couldn't actually call the Scene in an event. When interacting with the event (that activates the Scene, with this: $scene = Scene_Pet.new ), nothing would happen.

So how can I make the cursor move in the selectable window? And how would I activate scenes in events?

Thank you very much in advance!
 
Last edited by a moderator:

Mr. Bubble

Makes stuff.
Member
Joined
Mar 1, 2012
Messages
853
Reaction score
163
First and foremost, you need to post your attempted code. It's not possible to explain what you did incorrectly without it.

If $window.activate didn't work in Ace then I can't imagine that $window is a proper window object.

When interacting with the event (that activates the Scene, with this: $scene = Scene_Pet.new ), nothing would happen.
That's the scene call syntax for VX. It's not the same in Ace. In Ace that scene call would be



Code:
SceneManager.call(Scene_Pet)
 
Last edited by a moderator:

Tomasz

Warper
Member
Joined
Aug 2, 2012
Messages
4
Reaction score
0
First Language
Polish
Primarily Uses
Thank you once again Mr.Bubble, yes I fear that I didn't make the Window into a proper object.

ATM this is my code, the script is made so the player can choose between a canary or cat:

Code:
#==============================================================================
# ** Window_Pet.
#------------------------------------------------------------------------------
# Based on the Script Builder's Guide, this is a selectable window for a pet.
#==============================================================================
class Window_Pet < Window_Selectable
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize
super(100, 100, 640, 480)
self.index = 0 # This is what item is selected when the window is first made
@item_max = 2
self.contents = Bitmap.new(width-32,height-32)
refresh
end
#--------------------------------------------------------------------------
# * Refresh
#--------------------------------------------------------------------------
def refresh
self.contents.clear
#self.contents.draw_text(x_position_from_edge , y_position_from_edge,
# width, height, "Text", alignment)
self.contents.draw_text(0,0,100,32,"Canary Halinka")
self.contents.draw_text(0,32,100,32,"Cat Lulu")
end
#==============================================================================
# ** Scene_Window
#------------------------------------------------------------------------------
class Scene_Pet < Scene_Base

def start
super
@pet = Window_Pet.new
end
#--------------------------------------------------------------------------
# * Dispose Window
#--------------------------------------------------------------------------
def terminate
@pet.dispose
end
#--------------------------------------------------------------------------
# * Update Window
#--------------------------------------------------------------------------
def update
@pet.update
if Input.trigger?(Input::C)
$window.dispose
if self.index == 0
$window = Window_Text.new
elsif self.index == 1
print "You have selected the cat Lulu!"
$window = Window_Text.new
$window.y = 0
$window.back_opacity = 0
end
end
end
end
end
I based it on this (outdated) code:

http://www.rpgrevolu...indows_272.html

http://www.rpgmakerv...php/t30285.html

I tried to create a scene to keep my window updated with the player's input (Instead of doing that with events, it seems to be a better idea to create a Scene from the information I could find), however RPG Maker now keeps pointing out the following:

"uninitialized constant Game_Interpreter:: Scene_Pet". Even though I did create the class "Scene_Pet" when making the Scene. What did I do wrong here?

And I still don't know how to make the cursor move, I'm sure it has something to do with $window.activate but I don't know where to put it.

It would be great if I could find a RPG Maker VX Ace tutorial about this, because the syntax to ACE is different to VX.
 
Last edited by a moderator:

Mr. Bubble

Makes stuff.
Member
Joined
Mar 1, 2012
Messages
853
Reaction score
163
Well, there's a lot to explain.

You accidentally nested the Scene_Pet class within Window_Pet class. What this means is that outside of class Window_Pet, you can't instantiate Scene_Pet through the normal means except maybe through some strange coding loop holes I'm unaware of. See Scope.

Code:
self.contents = Bitmap.new(width-32,height-32)
This isn't necessary in Ace. Windows will create their contents bitmap on initialization in Ace. See the create_contents method in Window_Base.
Code:
if Input.trigger?(Input::C)
# code
if self.index == 0
# code
elsif self.index == 1
You were trying to make a conditional branch list with if-elsif statements, but the second "if" is supposed to be elsif which changes the flow of that control structure completely.



Code:
if Input.trigger?(Input::C)
# code
elsif self.index == 0
# code
elsif self.index == 1
You almost got it, but you'll want to read up on proper if-elsif-else control structures. http://en.wikibooks....else_expression

However, the entirety of your update method won't work in Ace. In Ace, Windows use handlers now and I'm not capable of explaining that in beginner's terms.
Code:
#--------------------------------------------------------------------------
# * Refresh
#--------------------------------------------------------------------------
def refresh
self.contents.clear
#self.contents.draw_text(x_position_from_edge , y_position_from_edge,
# width, height, "Text", alignment)
self.contents.draw_text(0,0,100,32,"Canary Halinka")
self.contents.draw_text(0,32,100,32,"Cat Lulu")
end
I just want to make it clear that you're not actually populating the window with selectable items with this method. You're drawing two lines of text in a window.
Code:
$window = Window_Text.new
The Window_Text class doesn't exist in Ace which is why $window is nil.
Code:
#--------------------------------------------------------------------------
# * Dispose Window
#--------------------------------------------------------------------------
def terminate
@pet.dispose
end
Manually disposing windows in a scene isn't needed anymore in Ace since Scene_Base now has a method which disposes all windows automatically when needed.
Code:
@item_max = 2
@item_max has been turned into a method.



Code:
#--------------------------------------------------------------------------
# * Get Number of Items
#--------------------------------------------------------------------------
def item_max
return 2
end
This is the reason why your cursor won't move in your window.
While it's better than nothing, I don't think using an XP tutorial on VX Ace will help much. Judging from your code, you're better off doing beginner Ruby tutorials to learn the programming fundamentals and working your way up from there. No point in trying to make a building when your foundation isn't solid.
 
Last edited by a moderator:

Tomasz

Warper
Member
Joined
Aug 2, 2012
Messages
4
Reaction score
0
First Language
Polish
Primarily Uses
Thank you very much for taking your time to review all my code, Mr. Bubble, I appreciate it. I have tried altering my script with your suggestions but I couldn't do it.

You're right I need to start from the very basics with Ruby. I'm going to learn it using this for now: http://ruby.learncodethehardway.org/book/ex0.html

Hopefully I'll get good enough eventually to make my own scripts in RPG Maker.

Again, thanks a lot! :)
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

Couple hours of work. Might use in my game as a secret find or something. Not sure. Fancy though no? :D
Holy stink, where have I been? Well, I started my temporary job this week. So less time to spend on game design... :(
Cartoonier cloud cover that better fits the art style, as well as (slightly) improved blending/fading... fading clouds when there are larger patterns is still somewhat abrupt for some reason.
Do you Find Tilesetting or Looking for Tilesets/Plugins more fun? Personally I like making my tileset for my Game (Cretaceous Park TM) xD
How many parameters is 'too many'??

Forum statistics

Threads
105,867
Messages
1,017,061
Members
137,575
Latest member
akekaphol101
Top