Submit Your Article


 
RPG Maker

Welcome Guest ( Log In | Register )


  Games Resources RPG Maker VX RPG Maker XP Scripts Tutorials Downloads

 
Reply to this topicStart new topic
> [Scripting]Window_Selectable, Advanced Windowing, Fully Complete!
onidsouza
post May 29 2009, 10:52 AM
Post #1


image master of doom
Group Icon

Group: Revolutionary
Posts: 603
Type: None
RM Skill: Undisclosed




Window_Selectable Part 1: The most simple

All that I can do is create commented scripts, any questions you can ask me.

Call:
CODE
$scene = Scene_ChooseSome.new


script
CODE
#First, let's create our window.

class Window_ChooseSome < Window_Selectable
#We inherited Window_Selectable because it has methods that let us to create
#Selectable Items.

def initialize
super(0, 0, 544, 416)
#Super method. We call this method in every Window creation.
self.index = 0
# Position of the cursor.
self.active = true
# The player can select something.
end

def update
super
# Necessary in order to the window work.
items = ["Cherry Pie", "Apple Pie", "Ultra Death Pie"]
@data = items
# The items that the player can select.
@item_max = @data.size
#Max number of selectable items.
create_contents
#Also necessary
for it in 0...@data.size
draw_opt(it)
end
# We create the options
# And pass to draw_opt the index of the option
end

def draw_opt(itemm)
rect = item_rect(itemm)
#We create a rectangle instance
self.contents.clear_rect(rect)
# We clear that rectangle
string = @data[itemm]
# We recover the text
rect.width -= 4
self.contents.draw_text(rect.x, rect.y, rect.width, WLH, string)
# We draw the text in the window
end

end

# Now let's create the scene!

class Scene_ChooseSome < Scene_Base

def start
@window = Window_ChooseSome.new
# We create the Window
end

def terminate
@window.dispose
# We show the window in the screen
end

def update
super
@window.update
# We update the window
end

end


Window_Selectable Part 2: Commands, Index and Multi-Windows

Script 2

CODE
class Pie_Types
  
  attr_reader :name, :description
  
  def initialize(name, description)
    @name = name
    @description = description
  end
  
end

#First, let's create our window.

class Window_ChooseSome < Window_Selectable
#We inherited Window_Selectable because it has methods that let us to create
#Selectable Items.

attr_reader :items #We create the items method.

def initialize
  super(0, 0, 390, 416)
  #Super method. We call this method in every Window creation.
  self.index = 0
  # Position of the cursor.
  self.active = true
  # The player can select something.
  @items = [Pie_Types.new("Cherry Pie", "A special pie"), Pie_Types.new("Apple Pie", "A tasty pie"), Pie_Types.new("Ultra Death Pie", "Dangerous")]
end

def update
  super
  # Necessary in order to the window work.
  @data = @items
  # The items that the player can select.
  @item_max = @data.size
  #Max number of selectable items.
  create_contents
  #Also necessary
  for it in 0...@data.size
    draw_opt(it)
  end
  # We create the options
  # And pass to draw_opt the index of the option
end

def draw_opt(itemm)
  rect = item_rect(itemm)
  #We create a rectangle instance
  self.contents.clear_rect(rect)
  # We clear that rectangle
  string = @data[itemm].name
  # We recover the pie name
  rect.width -= 4
  self.contents.draw_text(rect.x, rect.y, rect.width, WLH, string)
  # We draw the pie name in the window
end

end

class Window_SomeStatus < Window_Base
  
  attr_accessor :item
  attr_accessor :item_list #Our especial variables
  
  def initialize(item_list)
    super(390, 0, 154, 416) # WE create the window
    @item_list = item_list # Create a list with the pie types
    @item = 0 # Index variable
  end
  
  def refresh
    self.contents.clear
    draw_information
  end
  
  def draw_information
    # We draw the description of the text
    self.contents.draw_text(0, 0, 140, WLH, @item_list[item].description)
  end
  
end

# Now let's create the scene!

class Scene_ChooseSome < Scene_Base
  
  def start
    @window = Window_ChooseSome.new
    @status = Window_SomeStatus.new(@window.items)
    # We create the Window
  end
  
  def terminate
    @window.dispose
    @status.dispose
    # We show the window in the screen
  end
  
  def update
    super
    if Input.trigger?(Input::B)
      $scene = Scene_Map.new
    end
    # If the player presses Esc, we return to the map.
    @window.update
    @status.item = @window.index
    @status.refresh
    # We update the window
  end
  
end



Window_Selectable Part 3: Selecting Items

Script 3

CODE
class Pie_Types
  
  attr_reader :name, :description
  
  def initialize(name, description)
    @name = name
    @description = description
  end
  
end

#First, let's create our window.

class Window_ChooseSome < Window_Selectable
#We inherited Window_Selectable because it has methods that let us to create
#Selectable Items.

attr_reader :items #We create the items method.

def initialize
  super(0, 0, 390, 416)
  #Super method. We call this method in every Window creation.
  self.index = 0
  # Position of the cursor.
  self.active = true
  # The player can select something.
  @items = [Pie_Types.new("Cherry Pie", "A special pie"), Pie_Types.new("Apple Pie", "A tasty pie"), Pie_Types.new("Ultra Death Pie", "Dangerous")]
end

def update
  super
  # Necessary in order to the window work.
  @data = @items
  # The items that the player can select.
  @item_max = @data.size
  #Max number of selectable items.
  create_contents
  #Also necessary
  for it in 0...@data.size
    draw_opt(it)
  end
  # We create the options
  # And pass to draw_opt the index of the option
end

def draw_opt(itemm)
  rect = item_rect(itemm)
  #We create a rectangle instance
  self.contents.clear_rect(rect)
  # We clear that rectangle
  string = @data[itemm].name
  # We recover the pie name
  rect.width -= 4
  self.contents.draw_text(rect.x, rect.y, rect.width, WLH, string)
  # We draw the pie name in the window
end

end

# We create our invisible window
class Window_PieStatus < Window_Base
  
attr_accessor :pie
  
def initialize(pie)
   super(200, 150, 200, 200)
   self.visible = false
   # We make our window invisible
   @pie = pie
end

def refresh
   self.contents.clear
   draw_information
end

def draw_information
   self.contents.draw_text(0, 0, 200, WLH, @pie.name)
   self.contents.draw_text(0, WLH + 4, 200, WLH, @pie.description)
   # We draw the pie information
end

end

class Window_SomeStatus < Window_Base
  
  attr_accessor :item
  attr_accessor :item_list #Our especial variables
  
  def initialize(item_list)
    super(390, 0, 154, 416) # WE create the window
    @item_list = item_list # Create a list with the pie types
    @item = 0 # Index variable
  end
  
  def refresh
    self.contents.clear
    draw_information
  end
  
  def draw_information
    # We draw the description of the text
    self.contents.draw_text(0, 0, 140, WLH, @item_list[item].description)
  end
  
end

# Now let's create the scene!

class Scene_ChooseSome < Scene_Base
  
  def start
    @window = Window_ChooseSome.new
    @status = Window_SomeStatus.new(@window.items)
    @pie = Window_PieStatus.new(@window.items[0])
    # We create the Window
  end
  
  def terminate
    @window.dispose
    @status.dispose
    @pie.dispose
    # We show the window in the screen
  end
  
  def update
    super
    if Input.trigger?(Input::B)
      if @pie.visible
        @pie.visible = false
        @window.active = true
      else
      $scene = Scene_Map.new
      end
    end
    # If the player presses Esc, we return to the map.
    if Input.trigger?(Input::C)
      unless @pie.visible
        @window.active = false
        @pie.visible = true
      end
    end
    # If the player press enter, we draw the pie information
    @window.update
    @status.item = @window.index
    @status.refresh
    @pie.refresh
    @pie.pie = @window.items[@window.index]
    # We update the window
  end
  
end



~The End~


__________________________
Gabba Gabba Hey! enjoy your life ^^
lol (by keet's brother)
some lol
more lol
even MORE lol
Serious Discussion
why all my lol's have Teh Parakeet involved?

me ^^

bacon

Spamming is always better with bacon
Go to the top of the page
 
+Quote Post
   
breadlord
post May 29 2009, 01:36 PM
Post #2


What did you expect...
Group Icon

Group: Revolutionary
Posts: 461
Type: Developer
RM Skill: Intermediate




Part 2 allready, onidsuoza, you are amazing.



__________________________

Check out my project http://www.rpgrevolution.com/forums/index....showtopic=29698
[Show/Hide] I thought my sig was to big so... Clicky clicky


[Show/Hide] My RRR card, Thanks Holder!!




[Show/Hide] What things am I, CLICK!!!

I taste a bit like Almonds.


Mmm, the taste of almonds - anathema to many with nut allergies, and a bad sign for many more, as my taste is not unlike that of cyanide. Am I good or am I poison? A risky thing to guess about. What Flavour Are You?



What Mystical creature are you?
Pegasus



You are a shy, night time person and you are very gentle and soft hearted. You are like the opposite from your cousin the unicorn.


Which Final Fantasy Character Are You?
Final Fantasy 7


[Show/Hide] Can you read this?
Cna yuo raed tihs? Olny 55% of plepoe can.
I cdnuolt blveiee taht I cluod aulaclty uesdnatnrd waht I was rdanieg. The phaonmneal pweor of the hmuan mnid, aoccdrnig to a rscheearch at Cmabrigde Uinervtisy, it dseno't mtaetr in waht oerdr the ltteres in a wrod are, the olny iproamtnt tihng is taht the frsit and lsat ltteer be in the rghit pclae. The rset can be a taotl mses and you can sitll raed it whotuit a pboerlm. Tihs is bcuseae the huamn mnid deos not raed ervey lteter by istlef, but the wrod as a wlohe. Azanmig huh? yaeh and I awlyas tghuhot slpeling was ipmorantt!
fi yuo cna raed tihs, palce it in yuor siantugre.


[Show/Hide] Personality things




Your answers suggest you are a Strategist

The four aspects that make up this personality type are:



Summary of Strategists

* Quiet, easy-going and intellectually curious
* Use logical, objective thinking to find original solutions to problems
* Think of themselves as bright, logical and individualistic
* May be impractical, forgetting practical issues, such as paying bills or doing the shopping

More about Strategists

Strategists are quiet people who like to get to the heart of tough problems on their own and come up with innovative solutions. They analyse situations with a sceptical eye and develop ways of measuring everything, including themselves.

Strategists are the group most likely to say they are unhappy in their job, according to a UK survey.

Strategists are generally easy-going. They are intellectually curious and enjoy abstract ideas. Sometimes they like thinking of a solution to a problem more than taking practical steps to solve it.

In situations where they can't use their talents, are unappreciated, or not taken seriously, Strategists may become negatively critical or sarcastic. Under extreme stress, Strategists could be prone to inappropriate, tearful or angry outbursts.

Strategists may be insensitive to the emotional needs of others or how their behaviour impacts the people around them.


Go to the top of the page
 
+Quote Post
   
onidsouza
post Jun 1 2009, 03:36 AM
Post #3


image master of doom
Group Icon

Group: Revolutionary
Posts: 603
Type: None
RM Skill: Undisclosed




Doing part tree now, but i'm a little busy with my tests again.


__________________________
Gabba Gabba Hey! enjoy your life ^^
lol (by keet's brother)
some lol
more lol
even MORE lol
Serious Discussion
why all my lol's have Teh Parakeet involved?

me ^^

bacon

Spamming is always better with bacon
Go to the top of the page
 
+Quote Post
   
onidsouza
post Jun 1 2009, 04:49 PM
Post #4


image master of doom
Group Icon

Group: Revolutionary
Posts: 603
Type: None
RM Skill: Undisclosed




It's complete now!


__________________________
Gabba Gabba Hey! enjoy your life ^^
lol (by keet's brother)
some lol
more lol
even MORE lol
Serious Discussion
why all my lol's have Teh Parakeet involved?

me ^^

bacon

Spamming is always better with bacon
Go to the top of the page
 
+Quote Post
   
breadlord
post Jun 1 2009, 09:31 PM
Post #5


What did you expect...
Group Icon

Group: Revolutionary
Posts: 461
Type: Developer
RM Skill: Intermediate




Thank you onidisouza, I can now make selectable windows smile.gif .


__________________________

Check out my project http://www.rpgrevolution.com/forums/index....showtopic=29698
[Show/Hide] I thought my sig was to big so... Clicky clicky


[Show/Hide] My RRR card, Thanks Holder!!




[Show/Hide] What things am I, CLICK!!!

I taste a bit like Almonds.


Mmm, the taste of almonds - anathema to many with nut allergies, and a bad sign for many more, as my taste is not unlike that of cyanide. Am I good or am I poison? A risky thing to guess about. What Flavour Are You?



What Mystical creature are you?
Pegasus



You are a shy, night time person and you are very gentle and soft hearted. You are like the opposite from your cousin the unicorn.


Which Final Fantasy Character Are You?
Final Fantasy 7


[Show/Hide] Can you read this?
Cna yuo raed tihs? Olny 55% of plepoe can.
I cdnuolt blveiee taht I cluod aulaclty uesdnatnrd waht I was rdanieg. The phaonmneal pweor of the hmuan mnid, aoccdrnig to a rscheearch at Cmabrigde Uinervtisy, it dseno't mtaetr in waht oerdr the ltteres in a wrod are, the olny iproamtnt tihng is taht the frsit and lsat ltteer be in the rghit pclae. The rset can be a taotl mses and you can sitll raed it whotuit a pboerlm. Tihs is bcuseae the huamn mnid deos not raed ervey lteter by istlef, but the wrod as a wlohe. Azanmig huh? yaeh and I awlyas tghuhot slpeling was ipmorantt!
fi yuo cna raed tihs, palce it in yuor siantugre.


[Show/Hide] Personality things




Your answers suggest you are a Strategist

The four aspects that make up this personality type are:



Summary of Strategists

* Quiet, easy-going and intellectually curious
* Use logical, objective thinking to find original solutions to problems
* Think of themselves as bright, logical and individualistic
* May be impractical, forgetting practical issues, such as paying bills or doing the shopping

More about Strategists

Strategists are quiet people who like to get to the heart of tough problems on their own and come up with innovative solutions. They analyse situations with a sceptical eye and develop ways of measuring everything, including themselves.

Strategists are the group most likely to say they are unhappy in their job, according to a UK survey.

Strategists are generally easy-going. They are intellectually curious and enjoy abstract ideas. Sometimes they like thinking of a solution to a problem more than taking practical steps to solve it.

In situations where they can't use their talents, are unappreciated, or not taken seriously, Strategists may become negatively critical or sarcastic. Under extreme stress, Strategists could be prone to inappropriate, tearful or angry outbursts.

Strategists may be insensitive to the emotional needs of others or how their behaviour impacts the people around them.


Go to the top of the page
 
+Quote Post
   
Vascious
post Jun 1 2009, 09:45 PM
Post #6


Level 13
Group Icon

Group: Revolutionary
Posts: 229
Type: Event Designer
RM Skill: Beginner




I'm confused what is this script used for exactly?


__________________________


Go to the top of the page
 
+Quote Post
   
breadlord
post Jun 1 2009, 09:58 PM
Post #7


What did you expect...
Group Icon

Group: Revolutionary
Posts: 461
Type: Developer
RM Skill: Intermediate




This isn't a script to be used in your game, it's an example to help learning scripters (Like me XD).


__________________________

Check out my project http://www.rpgrevolution.com/forums/index....showtopic=29698
[Show/Hide] I thought my sig was to big so... Clicky clicky


[Show/Hide] My RRR card, Thanks Holder!!




[Show/Hide] What things am I, CLICK!!!

I taste a bit like Almonds.


Mmm, the taste of almonds - anathema to many with nut allergies, and a bad sign for many more, as my taste is not unlike that of cyanide. Am I good or am I poison? A risky thing to guess about. What Flavour Are You?



What Mystical creature are you?
Pegasus



You are a shy, night time person and you are very gentle and soft hearted. You are like the opposite from your cousin the unicorn.


Which Final Fantasy Character Are You?
Final Fantasy 7


[Show/Hide] Can you read this?
Cna yuo raed tihs? Olny 55% of plepoe can.
I cdnuolt blveiee taht I cluod aulaclty uesdnatnrd waht I was rdanieg. The phaonmneal pweor of the hmuan mnid, aoccdrnig to a rscheearch at Cmabrigde Uinervtisy, it dseno't mtaetr in waht oerdr the ltteres in a wrod are, the olny iproamtnt tihng is taht the frsit and lsat ltteer be in the rghit pclae. The rset can be a taotl mses and you can sitll raed it whotuit a pboerlm. Tihs is bcuseae the huamn mnid deos not raed ervey lteter by istlef, but the wrod as a wlohe. Azanmig huh? yaeh and I awlyas tghuhot slpeling was ipmorantt!
fi yuo cna raed tihs, palce it in yuor siantugre.


[Show/Hide] Personality things




Your answers suggest you are a Strategist

The four aspects that make up this personality type are:



Summary of Strategists

* Quiet, easy-going and intellectually curious
* Use logical, objective thinking to find original solutions to problems
* Think of themselves as bright, logical and individualistic
* May be impractical, forgetting practical issues, such as paying bills or doing the shopping

More about Strategists

Strategists are quiet people who like to get to the heart of tough problems on their own and come up with innovative solutions. They analyse situations with a sceptical eye and develop ways of measuring everything, including themselves.

Strategists are the group most likely to say they are unhappy in their job, according to a UK survey.

Strategists are generally easy-going. They are intellectually curious and enjoy abstract ideas. Sometimes they like thinking of a solution to a problem more than taking practical steps to solve it.

In situations where they can't use their talents, are unappreciated, or not taken seriously, Strategists may become negatively critical or sarcastic. Under extreme stress, Strategists could be prone to inappropriate, tearful or angry outbursts.

Strategists may be insensitive to the emotional needs of others or how their behaviour impacts the people around them.


Go to the top of the page
 
+Quote Post
   
onidsouza
post Jun 2 2009, 08:26 AM
Post #8


image master of doom
Group Icon

Group: Revolutionary
Posts: 603
Type: None
RM Skill: Undisclosed




QUOTE (Vascious @ Jun 2 2009, 02:45 AM) *
I'm confused what is this script used for exactly?


This is a tutorial to how to create windows that you can select things, like the items window. I created three scripts that explain everything.
The first only create the window, the second created commands and uses more than one window and the last one shows how to "select" things on your window, like when you select an item.


__________________________
Gabba Gabba Hey! enjoy your life ^^
lol (by keet's brother)
some lol
more lol
even MORE lol
Serious Discussion
why all my lol's have Teh Parakeet involved?

me ^^

bacon

Spamming is always better with bacon
Go to the top of the page
 
+Quote Post
   
onidsouza
post Jun 3 2009, 09:40 AM
Post #9


image master of doom
Group Icon

Group: Revolutionary
Posts: 603
Type: None
RM Skill: Undisclosed




*BUMP*


__________________________
Gabba Gabba Hey! enjoy your life ^^
lol (by keet's brother)
some lol
more lol
even MORE lol
Serious Discussion
why all my lol's have Teh Parakeet involved?

me ^^

bacon

Spamming is always better with bacon
Go to the top of the page
 
+Quote Post
   
noahflash14
post Jul 11 2009, 06:28 AM
Post #10


Level 4
Group Icon

Group: Member
Posts: 54
Type: Artist
RM Skill: Beginner




Wow! This is great oni. Nice tutorial and I hope you can make some more. I know it'll really help a lot people who wants to learn how to script.

Thanks for this tutorial and I wish you make some more.
Godbless!


__________________________
Pokemon SXR by noahflash14
[Updated(11-06-10): added 4 spritesn] Pokemon SR = 22

Don't forget to visit Pokemon SXR thread.
Go to the top of the page
 
+Quote Post
   
onidsouza
post Jul 12 2009, 04:22 AM
Post #11


image master of doom
Group Icon

Group: Revolutionary
Posts: 603
Type: None
RM Skill: Undisclosed




Thanks!
I will think on making some more...
I'm with new ideas for RPG Maker. I created a better, independent NPC system, with Artificcial Intelligence (AI)
But still it has some bugs... But it's a very simple system, i'm going to publish it very soon.


__________________________
Gabba Gabba Hey! enjoy your life ^^
lol (by keet's brother)
some lol
more lol
even MORE lol
Serious Discussion
why all my lol's have Teh Parakeet involved?

me ^^

bacon

Spamming is always better with bacon
Go to the top of the page
 
+Quote Post
   
Khev
post Jul 12 2009, 07:52 AM
Post #12


I'm sorry.. What?
Group Icon

Group: Revolutionary
Posts: 217
Type: Event Designer
RM Skill: Skilled




Ótimo tuto! ohmy.gif

Really in need of some scripting lessons.. I'm done with eventing tongue.gif

I wanna get to that point in which you only open an event for graphics or "Call Script" functions biggrin.gif


__________________________

Go to the top of the page
 
+Quote Post
   

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 

Lo-Fi Version Time is now: 21st May 2013 - 04:51 PM
RPG RPG Revolution is an Privacy Policy and Legal
eXTReMe Tracker