Dainekoichi's Skill Core Script Add on Request - Automatic Skill Core Sorting + Remova All actor skill cores in menu

Good Morning / Day / Afternoon / Evening everyone.

I have a request for a certain kind of script modification.

I have Dainekoichi's Skill Core system in mind. It allows characters to equip skill cores as an alternative to the traditional skill learning.

http://dainekoichi.blogspot.com/2015/10/rmvxa-skill-core-system_5.html

I was wondering if it was possible to have an add on that would do the following:

1. Include a "rearrange" or "sort" option below remove/unequip skill cores to orderly sort the skill cores by their ICON graphic? For example, skill cores with icon 300 will be always placed above icon 301 on the skill core list. Just remember some skill cores will share the same icon graphic, so: after icon order, they would be ordered alphabetically if they share the same icon graphic.

1. Include a "remove all" option below the previous option that will remove every skill core the actor currently has equipped.


Any help would be greatly appreciated.
Add the following as a new script (call it something like DNI Skill Core Edit)

Code:
module DAI
  module SKILLCORES
    SORT_TEXT = "Sort"
    REMOVE_ALL_TEXT = "Remove All"
  end
end

Game_Actor.class_eval do
  def remove_all_skillcores
    for i in 0...$game_party.skillcores.length
      if $game_party.skillcores[i][:actor] == @actor_id
        $game_party.skillcores[i][:actor] = 0
      end
    end
    @skillcores = []
    i = 0
    while i < DAI::SKILLCORES::EQUIP_COUNT
      @skillcores.push(-1)
      i += 1
    end # while
    return
  end
end

Window_SklCoreCommand.class_eval do
  alias_method(:tlb_draw_item, :draw_item)
  def draw_item(index)
    rect = item_rect_for_text(index)
    if @list[index][:name] == DAI::SKILLCORES::SORT_TEXT || @list[index][:name] == DAI::SKILLCORES::REMOVE_ALL_TEXT
      draw_text(rect, @list[index][:name], alignment)
      return
    end
    tlb_draw_item(index)
  end
end

Window_SklCoreItems.class_eval do
  alias_method(:tlb_make_command_list, :make_command_list)
  def make_command_list
    tlb_make_command_list
    add_command(DAI::SKILLCORES::SORT_TEXT,:sort,true,nil)
    add_command(DAI::SKILLCORES::REMOVE_ALL_TEXT,:remove_all,true,nil)
  end # def
end

Scene_SkillCore.class_eval do
  alias_method(:tlb_start, :start)
  def start
    tlb_start
    @cores_window.set_handler(:sort,    method(:sort_cores))
    @cores_window.set_handler(:remove_all,  method(:remove_all_cores))
  end

  def sort_cores
    $game_party.skillcores.sort_by! { |core| [core[:icon], core[:name]] }
    @cores_window.refresh
    @equip_window.refresh
    on_cores_cancel
  end

  def remove_all_cores
    @actor.remove_all_skillcores
    @cores_window.refresh
    @equip_window.refresh
    on_cores_cancel
  end
end
First, words cannot begin to describe how grateful I am for this. Thank you very much for your effort and you will definitely be credited for this.

Second, if I encounter any problems or errors, I will make sure to let you know.
Credit is always appreciated. <3

Yeah, if anything goes wrong with it or doesn't work quite the way you imagined, give me a shout.
Hey, remember when I said I would give you a shout if I encountered an issue? well I have.

You see... the sorting script works just fine when in your list of skill cores. HOWEVER, whenever I try to sort skill cores when any actor has their list full, it just messes up the equip order of the actor. It just switches up the skill cores that the actor has equipped. Not only that, doing this results in a glitch where a random skill core is duplicated, as you see in this picture.

000000.png


Is there a way to make it so only THE MAIN MIDDLE skill core list is the one sorted (the list of available skillcores to equip), without affecting the actor's equiupped skill core list (on the left) and making sure that duplication glitch doesn't happen?
I'm not entirely sure, since I think the two windows use the same list. I'll have a look at it.
I understand and please if it is too much don't be afraid to tell me it is. I really appreciate all of the effort.
Can you do me a favour and paste your skillcore setup for me so I can work with the same set?
You mean how I set up the script? Sure, I will have to include all the add ons I've requested in the past as well, please hold on. I can't post the script here without permission and there doesn't seem to be a way to contact the original scripter... perhaps I should send a demo?

The main script itself is virtually unchanged, though. would you like me to post the other addons I have included?
Just the config setup for the skillcore section.

here is a demo with the script including all of the addons.
That just had the default set of skillcores, I'm not seeing any of the ones from your screenshot.
ah my apologies. Please hold on.

This should do it?
That just takes me to the easyupload homepage.
Hold on, this is so complicated...
Seriously, all I need from you is to copy/paste your CORES setup from the initial plugin so I have the same set as you do for testing. 😛
I apologise for the multi posting.


It should be set up exactly like how I left it in my game project. with all the addons included
There we go!

Ahh, the issue is that the list is being sorted, but the actor's skillcores array still has the same IDs in it, and the elements of cores retain the IDs they're considered to be equipped against. So you end up with whichever skillcores end up in the place of the ID positions you had equipped before sorting.
Is there any way to workaround it? if it's impossible I understand completely. I'll just work with what I have.

Original thread: https://forums.rpgmakerweb.com/threads/dainekoichis-skill-core-script-add-on-request-automatic-skill-core-sorting-remova-all-actor-skill-cores-in-menu.123388/