PhoenixSoul

Need assistance with simplifying a script

7 posts in this topic

Okay, so I've figured out how to make certain parts of the Status Screen adapt to certain changes, such as more than five pieces of equipment.

 

I modified the default window script, but in truth, all I really did was change the values in one area, and my level of RGSS3 knowledge is not really enough for me to be able to just make it a standalone part.

 

I'll show you the code of the script so you'll know what I am talking about.

 

 

 

#==============================================================================
# ** Window_Status_Override
#------------------------------------------------------------------------------
#  This window displays full status specs on the status screen.
#  Modified to suit the needs for extra space to display equipped items,
#  those scripts provided by TsukiHime, Yanfly, and others.
#  Place in the Materials Section (Above Main, Below Materials)
#  Designed by Amyrakunejo, (/c) 2014-2016
#  No credit needed, but nice
#  No rules on usage
#  This modifies one class instance
#  Displays up to ten equipped items neatly
#  Works really well with Yanfly's Ace Core Engine and resized to 640x480
#  and if the text size is reduced to ≤20
#==============================================================================

class Window_Status < Window_Selectable
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize(actor)
    super(0, 0, Graphics.width, Graphics.height)
    @actor = actor
    refresh
    activate
  end
  #--------------------------------------------------------------------------
  # * Set Actor
  #--------------------------------------------------------------------------
  def actor=(actor)
    return if @actor == actor
    @actor = actor
    refresh
  end
  #--------------------------------------------------------------------------
  # * Refresh # The altered values begin here
  #--------------------------------------------------------------------------
  def refresh
    contents.clear
    draw_block1   (line_height * 0)    # value unaltered
    draw_horz_line(line_height * 0.5)  # default 1
    draw_block2   (line_height * 1.5)  # default 2
    draw_horz_line(line_height * 5.5)  # default 6
    draw_block3   (line_height * 6.5)  # default 7
    draw_horz_line(line_height * 16)   # default 13
    draw_block4   (line_height * 16.5) # default 14
  end # The altered values end here
  #--------------------------------------------------------------------------
  # * Draw Block 1
  #--------------------------------------------------------------------------
  def draw_block1(y)
    draw_actor_name(@actor, 4, y)
    draw_actor_class(@actor, 128, y)
    draw_actor_nickname(@actor, 288, y)
  end
  #--------------------------------------------------------------------------
  # * Draw Block 2
  #--------------------------------------------------------------------------
  def draw_block2(y)
    draw_actor_face(@actor, 8, y)
    draw_basic_info(136, y)
    draw_exp_info(304, y)
  end
  #--------------------------------------------------------------------------
  # * Draw Block 3
  #--------------------------------------------------------------------------
  def draw_block3(y)
    draw_parameters(32, y)
    draw_equipments(288, y)
  end
  #--------------------------------------------------------------------------
  # * Draw Block 4
  #--------------------------------------------------------------------------
  def draw_block4(y)
    draw_description(4, y)
  end
  #--------------------------------------------------------------------------
  # * Draw Horizontal Line
  #--------------------------------------------------------------------------
  def draw_horz_line(y)
    line_y = y + line_height / 2 - 1
    contents.fill_rect(0, line_y, contents_width, 2, line_color)
  end
  #--------------------------------------------------------------------------
  # * Get Color of Horizontal Line
  #--------------------------------------------------------------------------
  def line_color
    color = normal_color
    color.alpha = 48
    color
  end
  #--------------------------------------------------------------------------
  # * Draw Basic Information
  #--------------------------------------------------------------------------
  def draw_basic_info(x, y)
    draw_actor_level(@actor, x, y + line_height * 0)
    draw_actor_icons(@actor, x, y + line_height * 1)
    draw_actor_hp(@actor, x, y + line_height * 2)
    draw_actor_mp(@actor, x, y + line_height * 3)
  end
  #--------------------------------------------------------------------------
  # * Draw Parameters
  #--------------------------------------------------------------------------
  def draw_parameters(x, y)
    6.times {|i| draw_actor_param(@actor, x, y + line_height * i, i + 2) }
  end
  #--------------------------------------------------------------------------
  # * Draw Experience Information
  #--------------------------------------------------------------------------
  def draw_exp_info(x, y)
    s1 = @actor.max_level? ? "-------" : @actor.exp
    s2 = @actor.max_level? ? "-------" : @actor.next_level_exp - @actor.exp
    s_next = sprintf(Vocab::ExpNext, Vocab::level)
    change_color(system_color)
    draw_text(x, y + line_height * 0, 180, line_height, Vocab::ExpTotal)
    draw_text(x, y + line_height * 2, 180, line_height, s_next)
    change_color(normal_color)
    draw_text(x, y + line_height * 1, 180, line_height, s1, 2)
    draw_text(x, y + line_height * 3, 180, line_height, s2, 2)
  end
  #--------------------------------------------------------------------------
  # * Draw Equipment
  #--------------------------------------------------------------------------
  def draw_equipments(x, y)
    @actor.equips.each_with_index do |item, i|
      draw_item_name(item, x, y + line_height * i)
    end
  end
  #--------------------------------------------------------------------------
  # * Draw Description
  #--------------------------------------------------------------------------
  def draw_description(x, y)
    draw_text_ex(x, y, @actor.description)
  end
end

 

 

 

Can anyone help me make this to where it is much simpler? Thanks in advance to whomever assists.

Share this post


Link to post
Share on other sites

Okay, so I've figured out how to make certain parts of the Status Screen adapt to certain changes, such as more than five pieces of equipment.

 

I modified the default window script, but in truth, all I really did was change the values in one area, and my level of RGSS3 knowledge is not really enough for me to be able to just make it a standalone part.

 

I'll show you the code of the script so you'll know what I am talking about.

 

 

 

#==============================================================================
# ** Window_Status_Override
#------------------------------------------------------------------------------
#  This window displays full status specs on the status screen.
#  Modified to suit the needs for extra space to display equipped items,
#  those scripts provided by TsukiHime, Yanfly, and others.
#  Place in the Materials Section (Above Main, Below Materials)
#  Designed by Amyrakunejo, (/c) 2014-2016
#  No credit needed, but nice
#  No rules on usage
#  This modifies one class instance
#  Displays up to ten equipped items neatly
#  Works really well with Yanfly's Ace Core Engine and resized to 640x480
#  and if the text size is reduced to ≤20
#==============================================================================

class Window_Status < Window_Selectable
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize(actor)
    super(0, 0, Graphics.width, Graphics.height)
    @actor = actor
    refresh
    activate
  end
  #--------------------------------------------------------------------------
  # * Set Actor
  #--------------------------------------------------------------------------
  def actor=(actor)
    return if @actor == actor
    @actor = actor
    refresh
  end
  #--------------------------------------------------------------------------
  # * Refresh # The altered values begin here
  #--------------------------------------------------------------------------
  def refresh
    contents.clear
    draw_block1   (line_height * 0)    # value unaltered
    draw_horz_line(line_height * 0.5)  # default 1
    draw_block2   (line_height * 1.5)  # default 2
    draw_horz_line(line_height * 5.5)  # default 6
    draw_block3   (line_height * 6.5)  # default 7
    draw_horz_line(line_height * 16)   # default 13
    draw_block4   (line_height * 16.5) # default 14
  end # The altered values end here
  #--------------------------------------------------------------------------
  # * Draw Block 1
  #--------------------------------------------------------------------------
  def draw_block1(y)
    draw_actor_name(@actor, 4, y)
    draw_actor_class(@actor, 128, y)
    draw_actor_nickname(@actor, 288, y)
  end
  #--------------------------------------------------------------------------
  # * Draw Block 2
  #--------------------------------------------------------------------------
  def draw_block2(y)
    draw_actor_face(@actor, 8, y)
    draw_basic_info(136, y)
    draw_exp_info(304, y)
  end
  #--------------------------------------------------------------------------
  # * Draw Block 3
  #--------------------------------------------------------------------------
  def draw_block3(y)
    draw_parameters(32, y)
    draw_equipments(288, y)
  end
  #--------------------------------------------------------------------------
  # * Draw Block 4
  #--------------------------------------------------------------------------
  def draw_block4(y)
    draw_description(4, y)
  end
  #--------------------------------------------------------------------------
  # * Draw Horizontal Line
  #--------------------------------------------------------------------------
  def draw_horz_line(y)
    line_y = y + line_height / 2 - 1
    contents.fill_rect(0, line_y, contents_width, 2, line_color)
  end
  #--------------------------------------------------------------------------
  # * Get Color of Horizontal Line
  #--------------------------------------------------------------------------
  def line_color
    color = normal_color
    color.alpha = 48
    color
  end
  #--------------------------------------------------------------------------
  # * Draw Basic Information
  #--------------------------------------------------------------------------
  def draw_basic_info(x, y)
    draw_actor_level(@actor, x, y + line_height * 0)
    draw_actor_icons(@actor, x, y + line_height * 1)
    draw_actor_hp(@actor, x, y + line_height * 2)
    draw_actor_mp(@actor, x, y + line_height * 3)
  end
  #--------------------------------------------------------------------------
  # * Draw Parameters
  #--------------------------------------------------------------------------
  def draw_parameters(x, y)
    6.times {|i| draw_actor_param(@actor, x, y + line_height * i, i + 2) }
  end
  #--------------------------------------------------------------------------
  # * Draw Experience Information
  #--------------------------------------------------------------------------
  def draw_exp_info(x, y)
    s1 = @actor.max_level? ? "-------" : @actor.exp
    s2 = @actor.max_level? ? "-------" : @actor.next_level_exp - @actor.exp
    s_next = sprintf(Vocab::ExpNext, Vocab::level)
    change_color(system_color)
    draw_text(x, y + line_height * 0, 180, line_height, Vocab::ExpTotal)
    draw_text(x, y + line_height * 2, 180, line_height, s_next)
    change_color(normal_color)
    draw_text(x, y + line_height * 1, 180, line_height, s1, 2)
    draw_text(x, y + line_height * 3, 180, line_height, s2, 2)
  end
  #--------------------------------------------------------------------------
  # * Draw Equipment
  #--------------------------------------------------------------------------
  def draw_equipments(x, y)
    @actor.equips.each_with_index do |item, i|
      draw_item_name(item, x, y + line_height * i)
    end
  end
  #--------------------------------------------------------------------------
  # * Draw Description
  #--------------------------------------------------------------------------
  def draw_description(x, y)
    draw_text_ex(x, y, @actor.description)
  end
end

 

 

 

Can anyone help me make this to where it is much simpler? Thanks in advance to whomever assists.

 

I hope this helps in any way.

 


# I hope this simplifies the Refresh and draw_block methods

def refresh
  contents.clear
  4.times {|i|
    y = 0
    line_y = 0
    case i
    when 0
      y = 0
      line_y = 0.5
    when 1
      y = 1.5
      line_y = 5.5
    when 2
      y = 6.5
      line_y = 16
    when 3
      y = 16
      line_y = 0
    else
      y = 0
      line_y = 0
    end
    y      *= line_height
    line_y *= line_height
    draw_block(i, y)           if y != 0
    draw_horz_line(line_y)     if line_y != 0
  }
end

def draw_block(n, y)
  case n
  when 0
    draw_actor_name(@actor, 4, y)
    draw_actor_class(@actor, 128, y)
    draw_actor_nickname(@actor, 288, y)
  when 1
    draw_actor_face(@actor, 8, y)
    draw_basic_info(136, y)
    draw_exp_info(304, y)
  when 2
    draw_parameters(32, y)
    draw_equipments(288, y)
  when 3
    draw_description(4, y)
  end
end
Edited by oichidan
PhoenixSoul likes this

Share this post


Link to post
Share on other sites

Without a clear understanding of where this is supposed to go and/or replace, not really...

Share this post


Link to post
Share on other sites

Without a clear understanding of where this is supposed to go and/or replace, not really...

 

Well, it's supposed to replace the refresh and all the draw_block methods. Pardon my misunderstanding, but I didn't quite understand the 'standalone' part you're aiming to create.

Share this post


Link to post
Share on other sites

I'm not well skilled with classes, subclasses, etcetera. I know that this script is copied from the default script and just a few values changed, but I don't know how to reference it in a much simpler manner.

 

Like, I'd kinds just like to have this section of the script only...

  def refresh
    contents.clear
    draw_block1   (line_height * 0)    # value unaltered
    draw_horz_line(line_height * 0.5)  # default 1
    draw_block2   (line_height * 1.5)  # default 2
    draw_horz_line(line_height * 5.5)  # default 6
    draw_block3   (line_height * 6.5)  # default 7
    draw_horz_line(line_height * 16)   # default 13
    draw_block4   (line_height * 16.5) # default 14
  end # The altered values end here

That's all I've modified, but everything else is the same as the default.

 

I am still learning, but this was a necessity to show extra equipment without the extra equipment going into the description text below...(REALLY REALLY ANNNNOOOOOYYYIIIINNNNGGG)

Share this post


Link to post
Share on other sites

Another script that gives you more than the default equipment slots is http://bmscripts.weebly.com/

I use the Advanced VK equip.

Not sure if it is what your looking for, but might as well take a look.

 

Keeping this in mind, but it is not.

 

No, the status window is the main focus here.

 

I'm just trying to simplify the script, but since I know little about classes and subclasses...

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.