Modding Game_Picture Script

So, I’d like to add a script that, while not changing the main script itself, it instead adds to it.

The game I’m working with has a visual novel type of mechanic, with VN sprites and all, that has the parts stored in the graphics/pictures file and when a character wears a specific item, the VN sprite reflects it.

Ruby:
if $game_actors[@ac].equip[5] == $data_armors["###"]
    then
    $game_variables[4000][6] = "#"
    bodyS = "<filename>"

Where the 4000 variable is an array, @AC and “bodyS” are already stated before, and it continues with “elsif” statements repeating the same block of code.

What I would like to do is make it to where either: A. A separate script can be added to the game file that adds in my own custom stuff, or B. Simplify the script to where it can still call from the pictures file, but is called from the armor’s notetag or something like that instead of the repeating if statements.

I’m still learning Ruby and VXA so I’ll be working on figuring it out myself, but any helpful ideas/tips/suggestions would be grateful.
You can install this little script:
Spoiler
Code:
class RPG::EquipItem < RPG::BaseItem
 
  attr_accessor :equip_pic
 
  def equip_pic
    init_equip_pic if @equip_pic.nil?
    return @equip_pic
  end
 
  def init_equip_pic
    @equip_pic = @note =~ /<equip_pic: (.*)>/i ? $1 : ""
  end
 
end
And after that you could do something like this:
Spoiler
Code:
$game_actors[@ac].equips.each_with_index do |eq,ii|
  next if eq.nil?
  next if eq.equip_pic == "" # Optional skip
  $game_variables[4000][ii+1] = eq.equip_pic
end
This little code will iterate all equipment of the actor, and if there is something equipped on a slot, and if that equipment got the <equip_pic: filename> note-tag, it will store that filename from the note-tag into your selected variable ($game_variables[4000] in this case).
More precisely, since that variable is an array, it will store these filenames based on the equip slot they are equipped on into that array.

So if the actor got an equipment in slot 0, slot 1 and slot 3, your $game_variables[4000] array would end up like this:
Code:
[nil,"filename1","filename2",nil,"filename3"]
Alternatively, you could remove the line I marked with the # Optional skip note, and instead of storing a nil element for equipment without that note-tag, it would store an empty string.
You could also store an empty string instead of nil for empty equip slots if you don't simply skip empty slots and make it store an empty string for those too if you want.
The first element is always nil because I added +1 to the equip slot index in the iteration. If you prefer it to start storing the filename data from the first element instead, just remove the +1 part.

But without details on how and where you want to store and use these filenames, there may be better and easier implementations for this, so if you want more help with this, you will need to provide more details.

Original thread: https://forums.rpgmakerweb.com/threads/modding-game_picture-script.149685/