Help - Search - Members - Calendar
Full Version: Need help making a window_selectable script
RPG RPG Revolution Forums > Game Engines > RPG Maker XP Discussion
vvalkingman
So, I am attempting to make a custom skill status page. The idea is that I have five different katas each with three techniques that you learn over time. What I want to do is make it so that if you don't know a kata then that kata is greyed out and not able to be selected. When you select a kata it will open the skill window and only show the skills associated with that kata. I've got a long way to go before I can get what I want....for now I'm having issues with just making the selectable window below the Window_skillstatus. Here is what I've got so far:

CODE
#==============================================================================
# ** Window_KataStatus
#------------------------------------------------------------------------------
#  This window displays the user's kata status on the skill screen.
#==============================================================================

class Window_KataStatus < Window_Selectable
  #--------------------------------------------------------------------------
  # * Object Initialization
  #     actor : actor
  #--------------------------------------------------------------------------
  def initialize(actor)
    super(0, 128, 640, 64)
    self.index = 0
    @item_max = 5
    self.contents = Bitmap.new(width - 32, height - 32)
    @actor = actor
    refresh
  end
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  def refresh
    self.contents.clear
    self.contents.draw_text(0,0,100,32,"Lightning")
    self.contents.draw_text(128,0,100,32,"Fire")
    self.contents.draw_text(256,0,100,32,"Water")
    self.contents.draw_text(384,0,100,32,"Earth")
    self.contents.draw_text(512,0,100,32,"Wind")
  end
#--------------------------------------------------------------------------
# * Check_Input
#--------------------------------------------------------------------------
def check_input
if Input.trigger?(Input::C)
$window.dispose
if self.index == 0
#skill window for lightning
elsif self.index == 1
#skill window for fire
elsif self.index == 2
#skill window for water
elsif self.index == 3
#skill window for earth
elsif self.index == 4
#skill window for wind
end
end
end
end


The problem I am having is that I can't select the other options. It's like the first option is the entire line of lightning,fire,water,earth, and wind and I have four other blank options going down. How can I make it so that I can select the other options horizontally instead of vertically? Also, if you have any idea how I can have the option greyed out until a switch is on, that would be great. Thanks for the help in advance! smile.gif
Jens of Zanicuud
Hey, vvalkingman,
it's been a while since your Kata Script request smile.gif

I'm glad you're keeping on your project and I'll see what I can do to help you.
At a first glance, I'd suggest to modify that initialize this way:

CODE
def initialize(actor)
    super(0, 128, 640, 64)
    self.index = 0
    @item_max = 5
    @column_max = 5
    self.contents = Bitmap.new(width - 32, height - 32)
    @actor = actor
    refresh
  end


The @column_max variables means that your items shall be disposed on five different columns, i.e. in line.
It's just a minor fix and should work, if not, just reply and I'll find something different...

Jens
vvalkingman
Jens of Zanicuud to the rescue again! Lol yea, I put the project on hold while I was doing the college thing this past semester lol its really come a long way since you wrote that script for me wink.gif now I'm just trying to make it pretty. Never knew that about the column variable, thanks man! I decided it looked better going vertical on the left side anyway so I went with that. Only issue I'm really havinv is greying out/???? the switch for the Kata is on. What is the command/operator for that? How would you approach it? Thanks again for coming to the rescue lol
Jens of Zanicuud
QUOTE (vvalkingman @ Aug 26 2012, 09:37 PM) *
Jens of Zanicuud to the rescue again! Lol yea, I put the project on hold while I was doing the college thing this past semester lol its really come a long way since you wrote that script for me wink.gif now I'm just trying to make it pretty. Never knew that about the column variable, thanks man! I decided it looked better going vertical on the left side anyway so I went with that. Only issue I'm really havinv is greying out/???? the switch for the Kata is on. What is the command/operator for that? How would you approach it? Thanks again for coming to the rescue lol


So... let's see if I got it.
You want to grey-colour kata which you haven't learnt it yet or mark them with "????" and use another colour on the active kata, right?

Then...

1. let's check if the kata was learnt. The associated switch is $game_switches[KATA[kata index][2]]. It's set to true if the kata is learnt;
2. the method @actor.kata_id give thecurrently equipped kata id;
3. to modify font colour, just use self.contents.font.color = Color.new(r,g,b ).

Well, I've a code ready, but if you want to do it yourself, you can try using that info I gave in the previous lines before clicking on the spoiler tag...

code
CODE
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  def refresh
    self.contents.clear
    #let's put kata names into an array
    kata_names = ["Lightning","Fire","Water","Earth","Wind"]
    #let's start a for cicle. This is the most compact way to write down many elements
    for i in 0...kata_names.size
    #if switch active, then draw kata, if not draw "????"
    if $game_switches[KATA[i][2]] == true
    #normal color stands for white in RGSS. It's defined in the Window_Base class
    self.contents.font.color = normal_color
        #if kata is actually equipped, change font colour.
        if @actor.kata_id == i
        self.contents.font.color = Color.new(128,128,255)
        end
        #elements will be drawn at x = 0 and at y = 32 times "i", where i is the cycle variable
    self.contents.draw_text(0,32*i,100,32, kata_names[i])
    else
    #this method modifies the font color.
    self.contents.font.color = Color.new(128,128,128)
    self.contents.draw_text(0,32*i,100,32, "????")
    end
    end
  end


Tell me if it works... in any case, if there's something you can't understand, just reply and I'll explain you the code I employed.
I hope this can help,

Jens
vvalkingman
Sorry for taking so long to respond, it's been a crazy week lol

Thanks again for the awesome code drop, man! Worked like a charm! I've been playing around with the skill windows alittle bit more and managed to get it so that it lists the skills in a single column (took about three cups of coffee to figure that one out but I was determined to not have to ask you for help on it lol) which looks alot better than two columns since only three moves are learned per kata anyway. I think I might spread them out too to make it look cleaner. Only thing I'm worried about now is when you select one of the five katas, they should show which moves you've learned in the skill box. So basically, starting out there is nothing in the skill box. Once Lightning is clicked then BAM the three lightning moves show up and I can check them out or choose them if I can(like heal myself whateva). If I press cancel then it empties the skill box and returns focus to the list of katas. Is most of that supposed to be in refresh or am I way off?

I'm starting to think I should just show you my project so you can see what I'm talking about lol
Jens of Zanicuud
That's actually not too much difficult to do, anyway I'm in some sort of trouble ATM.
I could give it a look, but not in the next days, since I have a huge exam coming.

Anyway, you could modify the skill window to receive an array of skills as main argument:

CODE
class Skill_Window_2 < Window_Selectable
def initialize(skills)
super(x,y,width,height)
@skills = skills
[...]
end
end


where skills is an array like this: [skill_id 1, skill_id 2, skill_id 3].
You could modify the refresh method to draw only the skills in the array you passed on the first line instead of drawing the actor's skills.

CODE
def refresh
self.contents.clear
for skill in @skills
[...]
end
end


and then, add a methode like this:

CODE
def change_skills(skills)
@skills = skills
refresh
end


This method rewrites the array and let you show the new skills instead of the previous one.

I know this could seem rather confusing, but ATM I can't be more precise.
I hope this can help,

Jens
vvalkingman
Thanks for pointing me in the right direction! I think I can take it from here, or at least I'll give it a try for a week or so lol good luck on your exams man!
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2013 Invision Power Services, Inc.