List Sort by Rank

Roguedeus

It's never too late to procrastinate...
Veteran
Joined
Mar 19, 2013
Messages
542
Reaction score
111
First Language
English
Primarily Uses
N/A
Normally the default listing of things like items and skills when presented in a window are in order of ID.

I was wondering if anyone would be willing to tackle a quick sorting mechanism so its easier to keep related members of a list together regardless of how far appeart their entries are in the database. This way if Strong Attack I is (ID:9) and Strong Attack II is (ID:33) they can both appear side by side in the list and not several button presses apart.

The simplest way I can think of, is to allow for a 'rank' to be assigned to any listable object.

Example:

<rank:#>This way all melee abilities can be rank 1XX, all white magic rank 2XX, etc...

In the above example, Strong Attack I could be rank:109 and Strong Attack II could be rank:108, thus when listed they would always appear side by side and (more > less) powerful.

Objects with the same rank would still be sorted by ID. Or a secondary rank can be assigned... If a secondary exists its always sorted in front of non-secondary ranked objects.

Example:

<rank:main,secondary>With a secondary rank included the above example could be rank:100,9 & rank:100,8 instead.

Hopefully with something like this, it won't be so damned painful to have such scattered database entries. :D

Thanks for your time!
 
Last edited by a moderator:

Kaliya

// Caffeine Overload
Developer
Joined
Nov 1, 2015
Messages
506
Reaction score
566
First Language
English
Primarily Uses
RMMV
Would this just be for the skill window? 
 

Roguedeus

It's never too late to procrastinate...
Veteran
Joined
Mar 19, 2013
Messages
542
Reaction score
111
First Language
English
Primarily Uses
N/A
Would this just be for the skill window? 
And Item Window. ;)

Thanks for the attention BTW!

edit:

Essentially any time the player needs to select an action (skill or item) it would trigger this sorting.

Also it might be better if the note tag was less easily used by other plugins... say something like:

Code:
<sort_rank:#,#>
 
Last edited by a moderator:

Heartbreak61

Wandering Noob
Veteran
Joined
Sep 5, 2012
Messages
187
Reaction score
90
First Language
Indonesian
Primarily Uses
RMMV
Try this  :D

By the way, would you mind changing my regexp on reference event to the one similiar like this?

I notice a big mistake on my regex when checking this snippet, lol

Code:
//=============================================================================// SSG_ItemSort.js// Version 1.0.0//=============================================================================/*: * @plugindesc Item sort * @author Heartbreak61 *  * @param Default Sort Value 1 * @desc Default value for items, skills, and equipments * @default 100 * * @param Default Sort Value 2 * @desc Default value for items, skills, and equipments * @default 100 * * @param Sort Mode * @desc Ascending or descending for item that 'sort value'.  Sort by ID will still be ascending. * @default descending *  * @help * ============================================================================ * [Simple Stupid Gaming] Item Sort * <sort_value: Number, Number> */var Imported = Imported || {};Imported['SSG Item Sort'] = '1.0.0';(function() { // don't touch this!'use strict';var parameters = PluginManager.parameters('SSG_ItemSort');var sV = Number(parameters['Default Sort Value 1'] || 100);var sVV = Number(parameters['Default Sort Value 2'] || 100);var sM = String(parameters['Sort Mode'] || 'descending');var regexp = /(\d+)\s*[,;]?\s*(\d*)/;var _DataManager_onLoad = DataManager.onLoad;DataManager.onLoad = function(object) {	_DataManager_onLoad.call(this, object);	if ([$dataSkills, $dataItems, $dataWeapons, $dataArmors].contains(object)) {		for (var i = 0; i < object.length; i++) {			if (!object[i]) { continue; }			var str = object[i].meta.sort_value;			if (!str) {				object[i].sortValue = [sV, sVV];				continue;			}			var one = Number(str.match(regexp)[1]);			var two = Number(str.match(regexp)[2] || sVV);			object[i].sortValue = [one, two];		}	}};var _Window_SkillList_makeItemList = Window_SkillList.prototype.makeItemList;Window_SkillList.prototype.makeItemList = function() {	_Window_SkillList_makeItemList.call(this);	if (this._data.length > 0) {		this._data.sort(function(a,  {			var result;			if (sM.toLowerCase() === 'ascending') {				result = a.sortValue[0] - b.sortValue[0];				if (result === 0) {					result = a.sortValue[1] - b.sortValue[1];				}			} else {				result = b.sortValue[0] - a.sortValue[0];				if (result === 0) {					result = b.sortValue[1] - a.sortValue[1];				}			}			if (result === 0) {				result = a.id - b.id;			}			return result;		})	}};var _Window_ItemList_makeItemList = Window_ItemList.prototype.makeItemList;Window_ItemList.prototype.makeItemList = function() {	_Window_ItemList_makeItemList.call(this);	if (this._data.length > 0) {		var arr = this._data.slice(0);		if (arr.contains(null)) {			arr.pop();		}		arr.sort(function(a,  {			var result;			if (sM.toLowerCase() === 'ascending') {				result = a.sortValue[0] - b.sortValue[0];				if (result === 0) {					result = a.sortValue[1] - b.sortValue[1];					if (result === 0) {							result = a.id - b.id;					}				}			} else {				result = b.sortValue[0] - a.sortValue[0];				if (result === 0) {					result = b.sortValue[1] - a.sortValue[1];					if (result === 0) {							result = a.id - b.id;					}				}			}			console.log(result);			return result;		})		if (this._data.contains(null)) { arr.push(null); }		this._data = arr.slice(0);	}}})(); // Don't touch this!
 

Roguedeus

It's never too late to procrastinate...
Veteran
Joined
Mar 19, 2013
Messages
542
Reaction score
111
First Language
English
Primarily Uses
N/A
That works exactly as I had hoped Heartbreak61!
 

Roguedeus

It's never too late to procrastinate...
Veteran
Joined
Mar 19, 2013
Messages
542
Reaction score
111
First Language
English
Primarily Uses
N/A
Heartbreak61, I have been running into this error occasionally.

file:///X:/SkyDrive/_RMMV%20Projects/Projects/Prequel%20Project/js/plugins/SSG_ItemSort.js 47/X:/SkyDrive/_RMMV%20Projects/Projects/Prequel%20Project/js/plugins/SSG_ItemSort.js:47 Uncaught TypeError: Cannot read property 'sort_value' of undefinedIt only happens when I start the game. Before it runs. It happens once and then everything fine.

It seems intermittent.
 

Kaliya

// Caffeine Overload
Developer
Joined
Nov 1, 2015
Messages
506
Reaction score
566
First Language
English
Primarily Uses
RMMV
Try changing 

var _DataManager_onLoad = DataManager.onLoad;DataManager.onLoad = function(object) {    _DataManager_onLoad.call(this, object);    if ([$dataSkills, $dataItems, $dataWeapons, $dataArmors].contains(object)) {        for (var i = 0; i < object.length; i++) {            if (!object) { continue; }            var str = object.meta.sort_value;            if (!str) {                object.sortValue = [sV, sVV];                continue;            }            var one = Number(str.match(regexp)[1]);            var two = Number(str.match(regexp)[2] || sVV);            object.sortValue = [one, two];        }    }};To this:

var _DataManager_onLoad = DataManager.onLoad;DataManager.onLoad = function(object) {    _DataManager_onLoad.call(this, object);    if ([$dataSkills, $dataItems, $dataWeapons, $dataArmors].contains(object)) {        for (var i = 1; i < object.length; i++) {            if (!object) { continue; }            var str = object.meta.sort_value;            if (!str) {                object.sortValue = [sV, sVV];                continue;            }            var one = Number(str.match(regexp)[1]);            var two = Number(str.match(regexp)[2] || sVV);            object.sortValue = [one, two];        }    }};It looks like he was checking if object in $dataSomething (Actors,items,etc) had the notetag starting with object 0, but since RMMV doesn't have an object 0 (its null/undefined, because for whatever reason they didn't keep to consistent 0 based indexing or not). I've changed it to start checking with IDs 1 or higher.
 
Last edited by a moderator:

Heartbreak61

Wandering Noob
Veteran
Joined
Sep 5, 2012
Messages
187
Reaction score
90
First Language
Indonesian
Primarily Uses
RMMV
@roguedeus

maybe it's caused by empty actor on actor list database, for example you have actor 1-5 then you have "empty actor" on 6-7, and you have actor 8-10.

I could fix this but I can't promise it will be fast. My daytime job is kinda like hell these weeks lol.

Sorry for this bug.

@liquidize

it could be. member with id 0 from RMMV's $dataSomething is always null.

but i'm sure that i've checked if any object exist using if (!object){continue;}. then, it should skip that member 0 and any member that has falsy value (i.e. undefined, NaN, null, 0, "", false)
 

Roguedeus

It's never too late to procrastinate...
Veteran
Joined
Mar 19, 2013
Messages
542
Reaction score
111
First Language
English
Primarily Uses
N/A
@roguedeus

maybe it's caused by empty actor on actor list database, for example you have actor 1-5 then you have "empty actor" on 6-7, and you have actor 8-10.

I could fix this but I can't promise it will be fast. My daytime job is kinda like hell these weeks lol.

Sorry for this bug.

@liquidize

it could be. member with id 0 from RMMV's $dataSomething is always null.

but i'm sure that i've checked if any object exist using if (!object){continue;}. then, it should skip that member 0 and any member that has falsy value (i.e. undefined, NaN, null, 0, "", false)
 

I have empty actors. But the issue doesn't always happen very time I start. It is really intermittent.

 

No rush!
 

Roguedeus

It's never too late to procrastinate...
Veteran
Joined
Mar 19, 2013
Messages
542
Reaction score
111
First Language
English
Primarily Uses
N/A
I can verify now that its not caused by empty actors... I filled all my actor slots.

Trying this:

Code:
var _DataManager_onLoad = DataManager.onLoad;DataManager.onLoad = function(object) {    _DataManager_onLoad.call(this, object);    if ([$dataSkills, $dataItems, $dataWeapons, $dataArmors].contains(object)) {        for (var i = 1; i < object.length; i++) {            if (!object[i]) { continue; }            var str = object[i].meta.sort_value;            if (!str) {                object[i].sortValue = [sV, sVV];                continue;            }            var one = Number(str.match(regexp)[1]);            var two = Number(str.match(regexp)[2] || sVV);            object[i].sortValue = [one, two];        }    }};
 
Last edited by a moderator:

Nohmaan

Veteran
Veteran
Joined
Jul 7, 2012
Messages
180
Reaction score
49
First Language
English
This is pretty useful, good request.  Nice script also guys!
 

Roguedeus

It's never too late to procrastinate...
Veteran
Joined
Mar 19, 2013
Messages
542
Reaction score
111
First Language
English
Primarily Uses
N/A
It just happened again... Even with the change to the code.

It doesn't seem to happen as often though.
 

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

Latest Threads

Latest Posts

Latest Profile Posts

Couple hours of work. Might use in my game as a secret find or something. Not sure. Fancy though no? :D
Holy stink, where have I been? Well, I started my temporary job this week. So less time to spend on game design... :(
Cartoonier cloud cover that better fits the art style, as well as (slightly) improved blending/fading... fading clouds when there are larger patterns is still somewhat abrupt for some reason.
Do you Find Tilesetting or Looking for Tilesets/Plugins more fun? Personally I like making my tileset for my Game (Cretaceous Park TM) xD
How many parameters is 'too many'??

Forum statistics

Threads
105,865
Messages
1,017,059
Members
137,575
Latest member
akekaphol101
Top