Sort the Yanfly Party System list

SophieChieko

Villager
Member
Joined
Feb 24, 2019
Messages
6
Reaction score
1
First Language
French
Primarily Uses
RMVXA
Hello! Yanfly Party System for RPG Maker VX Ace is very cool, but not very convenient when you've got more than 200 actors...
Is it possible to arrange it to sort the character list with name at alphabetical order ?

I tried to add in my party the new member with alphabetical order, but when I did some modification of my active team with Formation, the list became in disorder because the script for formation doesn't put the list first order back after each manipulation...

Could you help me, please?
 

Heirukichi

Veteran
Veteran
Joined
Sep 24, 2015
Messages
1,421
Reaction score
596
First Language
Italian
Primarily Uses
RMVXA
So you are basically asking to sort actors that are not in the active party in alphabetical order each time, did I hit the mark?
 

bgillisp

Global Moderators
Global Mod
Joined
Jul 2, 2014
Messages
13,528
Reaction score
14,261
First Language
English
Primarily Uses
RMVXA

I've moved this thread to RGSSx Script Support. Please be sure to post your threads in the correct forum next time. Thank you.

 

Heirukichi

Veteran
Veteran
Joined
Sep 24, 2015
Messages
1,421
Reaction score
596
First Language
Italian
Primarily Uses
RMVXA
Could you please post a link to the script? This does not sound as a difficult task.
 

Heirukichi

Veteran
Veteran
Joined
Sep 24, 2015
Messages
1,421
Reaction score
596
First Language
Italian
Primarily Uses
RMVXA
Just copy/paste this in your scripts BELOW Yanfly Party System. You can either sort actors alphabetically or based on their database ID. As written in the instruction I strongly recommend doing it by database ID - especially if you have a large number of actors - however it works for alphabetical order as well.

Code:
$imported = {} if $imported.nil?
$imported["Heirukichi_SortActorsFromation"] = true

module HSF
   
    #=======================================================================
    # Set this value to true if you want to sort actors alphabetically
    # Set it to false if you want to sort them by ID.
    # Default is true.
    #-----------------------------------------------------------------------
    # * NOTE
    #-----------------------------------------------------------------------
    # Sorting them alphabetically is more time-consuming than sorting
    # them by ID so I strongly recommend sorting them in your database
    # and then sorting them by ID.
    #=======================================================================
   
    SORT_ALPHABETICALLY = true
   
    #=======================================================================
    # Set this value to true if you want to sort actors more efficiently.
    # It only works for alphabetical sorting. Default is true.
    #=======================================================================
   
    EFFICIENT_SORTING = true
   
    #=======================================================================
    # Do not modify after this point!
    #=======================================================================
   
    def self.compare(a, b)
        return if (a.nil? || b.nil?)
        return if ($data_actors[a].nil? || $data_actors[b].nil?)
        EFFICIENT_SORTING ? pcompare(a, b) : $data_actors[a].name <=> $data_actors[b].name
    end
   
    def self.initialize_actors_priority
        return unless @actors_priority.nil?
        @actors_priority = Array.new($data_actors.length+1) {|i| i}
        $data_actors.each.with_index do |a, i|
            next if (i==0)
            p = 0
            $data_actors.each.with_index do |b, j|
                next if (j==0)
                next if (a==b)
                p += 1 if a.name > b.name
            end
            @actors_priority[i] = p
        end
    end
   
    def self.priority
        @actors_priority
    end
   
    def self.pcompare(a, b)
        return if (a.nil? || b.nil?)
        return if ($data_actors[a].nil? || $data_actors[b].nil?)
        initialize_actors_priority
        priority[a] <=> priority[b]
    end
   
end

if $imported["YEA-PartySystem"]

#===========================================================================
# * Game Party class
#===========================================================================

class Game_Party
       
    alias hrk_rearrange_actors_old    rearrange_actors
    def rearrange_actors
        hrk_rearrange_actors_old
        sz = @battle_members_array.length
        sorted = @actors.slice!(sz, @actors.length - sz)
        if HSF::SORT_ALPHABETICALLY
            @actors += sorted.sort {|a, b| HSF.compare(a, b)}
        else
            @actors += sorted.sort
        end
    end
   
end

#===========================================================================
# * Scene Party class
#===========================================================================

class Scene_Party
   
    alias hrk_start_yep_old start
    def start
        hrk_start_yep_old
        window_refresh
    end
   
end

#===========================================================================
# * Scene Manu class
#===========================================================================

class Scene_Menu
   
    alias hrk_start_old    start
    def start
        hrk_start_old
        HSF.initialize_actors_priority
    end
   
end

end

This should fix your problem. However I am going to write a more efficient algorithm so that sorting actors alphabetically will be more efficient.

EDIT: I changed the code so that sorting alphabetically is more efficient.
 
Last edited:

SophieChieko

Villager
Member
Joined
Feb 24, 2019
Messages
6
Reaction score
1
First Language
French
Primarily Uses
RMVXA
It works perfectly! Whether alphabetically or ID based!
Thank you so much, Heirukichi! :kaoluv:
I couldn't have done it without your help!
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Profile Posts

Our latest feature is an interview with... me?!

People4_2 (Capelet off and on) added!

Just beat the last of us 2 last night and starting jedi: fallen order right now, both use unreal engine & when I say i knew 80% of jedi's buttons right away because they were the same buttons as TLOU2 its ridiculous, even the same narrow hallway crawl and barely-made-it jump they do. Unreal Engine is just big budget RPG Maker the way they make games nearly identical at its core lol.
Can someone recommend some fun story-heavy RPGs to me? Coming up with good gameplay is a nightmare! I was thinking of making some gameplay platforming-based, but that doesn't work well in RPG form*. I also was thinking of removing battles, but that would be too much like OneShot. I don't even know how to make good puzzles!
one bad plugin combo later and one of my followers is moonwalking off the screen on his own... I didn't even more yet on the new map lol.

Forum statistics

Threads
106,034
Messages
1,018,447
Members
137,820
Latest member
georg09byron
Top