Jump to content
PoPS

Need Help Removing Something from Script

Recommended Posts

Hi there,

I've just joined this community, though I've been a user of the RPG Maker series for a looong time.

I've never been much of a scripter, but now that I'm getting into VX Ace properly, I've been browsing the scripts available here and downloaded some for my latest project, so thank you all very much for your awesome creations!

 

Now for the "help required" portion of this post:

I can't find the script in question anywhere on this forum, so hopefully it's ok to post it here. It's Neon Black's script for Item Effects Boxes.

I love this script, but I also love Elemental Crisis' script, Item Encyclopedia. Trouble is, the encyclopedia requires you to type in the item's Notes for them to appear in the encyclopedia, but that also makes the notes appear (and not fit) in the Item Effects Boxes.

So I'm wondering if any skilled scripter here can help me out by removing bits from Neon Black's script so that it doesn't look at the Notes sections, so I can seperate the 2 mods.

 

Thanks in advance for anything, whoever is able to help will of course be credited for it!

But of course, feel free to remove this post if it's not allowed. I'm not too familiar with the rules of this kinda stuff.

 

 

 

##----------------------------------------------------------------------------##
## Effects Box Script v1.0
## Created by Neon Black
##
## For both commercial and non-commercial use as long as credit is given to
## Neon Black and any additional authors.  Licensed under Creative Commons
## CC BY 3.0 - http://creativecommons.org/licenses/by/3.0/.
##----------------------------------------------------------------------------##
                                                                              ##
##----------------------------------------------------------------------------##
##    Revision Info:
## v1.0 - 3.3.2013
##  Wrote and debugged main script
##----------------------------------------------------------------------------##
                                                                              ##
$imported ||= {}                                                              ##
$imported["EFFECTS_BOX"] = 1.0                                                ##
                                                                              ##
##----------------------------------------------------------------------------##
##    Instructions:
## Place this script in the script editor below "Materials" and above "Main".
## This script requires Neon Black's Features and Effects name module.  You can
## obtain it from http://cphouseset.wordpress.com/modules/.  If you do not
## import it, you will get errors.
##
## This script is plug and play.  It allows a pop-up boxes to display on equips,
## items, and skills.  You can choose to have these pop-ups be constant, toggle
## with a button press, or only appear while a key is held down.  These display
## 3 bits of information.  First an added note, second all the stats equipping
## the item will provide, and finally all the effects or features of the item.
## A note can be added using <effect note> and </effect note> and placing your
## note in between those tags, like so:
##
##    <effect note>
##    This will display line 1
##    This will display line 2
##    </effect note>
##
##----------------------------------------------------------------------------##
                                                                              ##
module CP             # Do not touch                                          ##
module EFFECTS_WINDOW #  these lines.                                         ##
##----------------------------------------------------------------------------##
##    Config:
## The config options are below.  You can set these depending on the flavour of
## your game.  Each option is explained in a bit more detail above it.
##
##------
# This is the padding around the edges of the box.  Increasing this number will
# increase the size of the box without increasing the size of it's contents.
EDGES = 4

# This is the font size of the pop up's text.  Adjusting this affects the entire
# box's size.
FONT_SIZE = 16

# Choose to use font shadow or outlines.
SHADOW = false
OUTLINE = false

# If this value is set to false, stats will not be shown on equips.
SHOW_STATS = true

# The key to press to toggle or show the box.
BOX_KEY = :A

# The show type for the pop-up box.  Any value other than these three will
# prevent the box from being show.
#  0 = Hold button to display the box.
#  1 = Press button to toggle the box.
#  2 = The box is constantly show.
SHOW_TYPE = 2

# If type 2 was selected above, this is the default state of the box.  Set it to
# true to show the box or false to hide the box until the key is pressed.
@show = true
##----------------------------------------------------------------------------##
                                                                              ##
                                                                              ##
##----------------------------------------------------------------------------##
## The following lines are the actual core code of the script.  While you are
## certainly invited to look, modifying it may result in undesirable results.
## Modify at your own risk!
###----------------------------------------------------------------------------


  def self.toggle_effects
    @show = !@show if Input.trigger?(BOX_KEY)
    return @show
  end

end
end

module SceneManager
  class << self
    alias :cp_rshp_run :run unless method_defined?(:cp_rshp_run)
  end
 
  def self.run
    cp_module_check_features
    cp_rshp_run
  end
 
  def self.cp_module_check_features
    return if $imported["CP_FEATURES_EFFECTS"]
    a1 = "One or more scripts require Neon Black's Features and Effects module."
    a2 = "This can be obtained at http://cphouseset.wordpress.com/modules/"
    a3 = "Please add this module and try again."
    a4 = "Please contact the creator of the game to resolve this issue."
    if $TEST || $BTEST
      msgbox "#{a1}/n#{a2}/n#{a3}"
      Thread.new{system("start http://cphouseset.wordpress.com/modules/#features")}
    else
      msgbox "#{a1}/n#{a4}"
    end
  end
end

class Window_Selectable < Window_Base
  def item
    return nil
  end
 
  alias :cp_itembox_update :update
  def update(*args)
    cp_itembox_update(*args)
    show_fet_window
  end
 
  def show_fet_window
    key = key_show_features_box
    show_feature_box if key && active && open?
    remove_feature_box unless key && active && open?
  end
 
  def key_show_features_box
    case CP::EFFECTS_WINDOW::SHOW_TYPE
    when 0
      return Input.press?(CP::EFFECTS_WINDOW::BOX_KEY)
    when 1
      return CP::EFFECTS_WINDOW.toggle_effects
    when 2
      return true
    else
      return false
    end
  end
 
  def show_feature_box  ## Creates the box if shift is held.
    if item != @last_box_item
      if feature_box_item?
        @feature_box.dispose unless @feature_box.nil?
        rect = item_rect(@index)
        x = rect.x + self.x + padding + 24 - ox
        y = rect.y + line_height + self.y + padding - oy - 2
        @feature_box = Window_FeaturesShow.new(item, x, y, self)
        @last_box_item = item
      else
        remove_feature_box
      end
    end
  end
 
  def feature_box_item?
    item.is_a?(RPG::EquipItem) || item.is_a?(RPG::UsableItem)
  end
 
  def remove_feature_box  ## Dispose the box.
    @feature_box.dispose unless @feature_box.nil?
    @feature_box = nil
    @last_box_item = nil
  end
end

class Window_FeaturesShow < Window_Base
  def initialize(item, x, y, parent)
    @parent = parent
    @bx = x; @by = y
    @item = item
    super(0, 0, 500, 500)
    self.z = @parent.z + 500
    self.windowskin = Cache.system("EffectsWindow")
    self.back_opacity = 255
    self.tone = Tone.new
    make_width
    make_height
    make_position
    draw_all_items
  end
 
  def make_width
    contents.font.size = line_height
    contents.font.outline = CP::EFFECTS_WINDOW::OUTLINE
    contents.font.shadow = CP::EFFECTS_WINDOW::SHADOW
    i = 120
    unless notes.empty?
      i = [i, notes.collect{|n| contents.text_size(n).width}.max + 2].max
    end
    unless effects.empty?
      i = [i, effects.collect{|e| contents.text_size(e.vocab).width}.max + 2].max
    end
    unless stats.empty?
      i = [i, stats.collect{|s| contents.text_size(s).width}.max + 2].max
    end
    self.width = i + standard_padding * 2
  end
 
  def make_height
    sw = self.width - standard_padding * 2
    i = standard_padding * 2
    i += notes.size * line_height
    i += effects.size * line_height
    i += seps * line_height / 2
    unless stats.empty?
      w = stats.collect{|s| contents.text_size(s).width}.max + 2
      n = [sw / w, 1].max
      i += (stats.size + n - 1) / n * line_height
    end
    self.height = i
    self.visible = false if i == standard_padding * 2
    create_contents
    contents.font.size = line_height
    contents.font.outline = false
    contents.font.shadow = false
    change_color(normal_color)
  end
 
  def make_position
    self.x = @bx + self.width > Graphics.width ? Graphics.width - self.width :
             @bx
    self.y = @by + self.height <= Graphics.height ? @by :
             @by - self.height - @parent.line_height + 4 > 0 ? @by -
             self.height - @parent.line_height + 4 : Graphics.height -
             self.height
  end
 
  def standard_padding
    CP::EFFECTS_WINDOW::EDGES
  end
 
  def line_height
    CP::EFFECTS_WINDOW::FONT_SIZE
  end
 
  def seps
    i = -1
    i += 1 unless effects.empty?
    i += 1 unless notes.empty?
    i += 1 unless stats.empty?
    return [i, 0].max
  end
 
  def stats
    return [] unless CP::EFFECTS_WINDOW::SHOW_STATS && @item.is_a?(RPG::EquipItem)
    r = []
    8.times do |i|
      next if @item.params == 0
      r.push("#{Vocab.param(i)}   #{@item.params}")
    end
    return r
  end
 
  def notes
    @item.effect_desc
  end
 
  def effects
    if @item.is_a?(RPG::EquipItem)
      @item.features
    elsif @item.is_a?(RPG::UsableItem)
      @item.effects
    end
  end
 
  def draw_all_items
    contents.clear
    y = 0
    notes.each do |l|
      draw_text(1, y, contents.width, line_height, l)
      y += line_height
    end
    y += line_height / 2 unless y == 0
    unless stats.empty?
      w = stats.collect{|s| contents.text_size(s).width}.max + 2
      xt = contents.width / w
      xw = contents.width / xt
      xn = 0
      y -= line_height
      stats.each_with_index do |s, index|
        y += line_height if index % xt == 0
        case s
        when /(.*)   (-?)(\d+)/i
          draw_text(xw * (index % xt) + 1, y, xw, line_height, "#{$1.to_s}")
          draw_text(xw * (index % xt) + 1, y, xw, line_height,
                    "#{$2.to_s}#{$3.to_s}  ", 2)
        end
      end
      y += line_height
    end
    y += line_height / 2 unless y == 0
    effects.each do |e|
      draw_text(1, y, contents.width, line_height, e.vocab)
      y += line_height
    end
  end
end

class RPG::BaseItem
  def effect_desc
    make_effect_desc if @effect_desc.nil?
    return @effect_desc
  end
 
  def make_effect_desc
    @effect_desc = []
    noted = false
    self.note.split(/[\r\n]+/i).each do |line|
      case line
      when /<effect note>/i
        noted = true
      when /<\/effect note>/i
        break
      else
        @effect_desc.push("#{line}")
      end
    end
  end
end


###--------------------------------------------------------------------------###
#  End of script.                                                              #
###--------------------------------------------------------------------------###

 

 

Share this post


Link to post
Share on other sites

The part of the script where it looks in the notes section is here:

 


unless notes.empty?
      i = [i, notes.collect{|n| contents.text_size(n).width}.max + 2].max
    end
    unless effects.empty?
      i = [i, effects.collect{|e| contents.text_size(e.vocab).width}.max + 2].max
    end
    unless stats.empty?
      i = [i, stats.collect{|s| contents.text_size(s).width}.max + 2].max
    end
    self.width = i + standard_padding * 2
  end

 

My suggestion is you take this:

 


i = [i, notes.collect{|n| contents.text_size(n).width}.max + 2].max

and make it into


i = 0



			
		

Share this post


Link to post
Share on other sites

Thank you very much for the quick response!

Unfortunately that didn't work for some reason, it still shows up in the item effect box, just more squished to fit in, instead of making the box wider.

 

If necessary, I'll probably just stop using the Item Effects Boxes script, that seems like the  slightly less important of the two, but I very much appreciate your time and efforts.

Share this post


Link to post
Share on other sites

Thank you very much for the quick response!

Unfortunately that didn't work for some reason, it still shows up in the item effect box, just more squished to fit in, instead of making the box wider.

 

If necessary, I'll probably just stop using the Item Effects Boxes script, that seems like the  slightly less important of the two, but I very much appreciate your time and efforts.

 

Else try change this line instead:

 

def notes

    @item.effect_desc

  end

 

to this:


def notes

    @item.effect_desc = nil

  end

 

See if that works maybe.

Share this post


Link to post
Share on other sites

Unfortunately that one just causes an error:

 

Script ' * Item Effects Boxes' line 265: NoMethodError occurred.

undefined method `effect_desc=' for #<RPG::Item:0x8aac924>

 

(line 265 is the line I put  " = nil"  onto the end of)

 

I then tried just adding a # to the start of every line that seemed to handle something to do with notes, but that just led into more and more of the script bringing up an error.

Share this post


Link to post
Share on other sites
Guest
This topic is now closed to further replies.

  • Recently Browsing   0 members

    No registered users viewing this page.

×