Need Help! With javascript or spacing fix for actor name/class spacing

hi, im use really long actor names and i have a main class and subclass, but the actor name overlaps onto the class/subclass. I've been messing around with javascript in the rpg_windows.js file, and this is what I found but can't figure out what to do to solve this problem.


this line of code works if i modify it but changes global text to whateve i do with it.


Window_Base.prototype.drawText = function(text, x, y, maxWidth, align) {
    this.contents.drawText(text, x, y, maxWidth, this.lineHeight(), align);
};


this line of code if i modify nothing changes no matter what i do but (seems like it would solve my problem if i could figure out how to get this line to actually modify in game text)


Window_Base.prototype.drawActorClass = function(actor, x, y, width) {
    width = width || 168;
    this.resetTextColor();
    this.drawText(actor.currentClass().name, x, y, width);
};


this line of code seems interesting but doesnt do anything either when i try to modify it.


Window_Status.prototype.drawBlock1 = function(y) {
    this.drawActorName(this._actor, 6, y);
    this.drawActorClass(this._actor, 200, y);
    this.drawActorNickname(this._actor, 432, y);
};


the only thing that modifys and works but not correctly is using this line of code


Window_Base.prototype.drawText = function(text, x, y, maxWidth, align) {
    this.contents.drawText(text, x, y, maxWidth, this.lineHeight(), align);
};


like if i change align to = 'right' or 'center', it changes the actor name/ class/subclass to align right or center but its GLOBAL so it changes all the text. not specific to my problem. I spent 24 hours trying to figure this out, but no luck, please if you know anything please help...
I've moved this thread to learning javascript. Please be sure to post your threads in the correct forum next time. Thank you.



As a sidenote, you should NOT edit the corefiles but use a plugin to override their functions.


Editing the core files means that it will break your edit every time the project's core gets updated, which means you'll either have to stop updating (bad) or remake the edit whenever the project is updated. Using a plugin for the change is less work in the long term.
Im on mobile right now so i cant look at the codebase but im pretty sure the method youre looking foe is named Window_Base.prototype.drawActorSimpleStatus.


It should be where the name, class and gauges are drawn and given thier cordinates. Just change the x value of the class name and it should fix your issue. As Andar mentioned though be sure to throw it in a seperate file so you dont overerite the code base.
thank you LTN games it worked. now how do i create a .js file to refernce the X variable inside rpg_window.js in plugins folder?? im pretty new to javascript.
Just create the new file "plugin_name.js" and inside it, literally copy the whole drawActorSimpleStatus function into the new file.


//Plugin.js

Window_Base.prototype.drawActorSimpleStatus = function(actor, x, y, width) {
var lineHeight = this.lineHeight();
var x2 = x + 180;
var width2 = Math.min(200, width - 180 - this.textPadding());
this.drawActorName(actor, x, y);
this.drawActorLevel(actor, x, y + lineHeight * 1);
this.drawActorIcons(actor, x, y + lineHeight * 2);
this.drawActorClass(actor, x2, y);
this.drawActorHp(actor, x2, y + lineHeight * 1, width2);
this.drawActorMp(actor, x2, y + lineHeight * 2, width2);
};


if you have other plugins that affect it, then you may have to alias it or look at the other plugin which is using the same method and find a work around it, you will have to alias it and all that fun jazz. I'm assuming you don't have to worry about that right now and you can just copy the above into a new file and place it in the plugin folder like you would any other plugin and turn it on. 


If you want to go a step further you can add parametes like so.

Code:
 //=============================================================================
// Plugin.js
// =============================================================================
// Version 1.0
/*:
 *@plugindesc V1.0 Describe your plugin here

 @author Your Name

 @param Class Name X
 @desc The x value of the class name in the main menu. 
 Adjust to fit for larger actor names. 
 @default 60
 
*/

// Name this t whatever you want, perferably less than 5 characters.
var myNamespace = myNamespace || {};

// IIFE - This keeps you from polluting global space.
(function () {

//Retrieve plugin parameters. Thank's to MV's core method :)
// 'Plugin' is the name of the file..
myNameSpace.Parameters = PluginManager.parameters('Plugin');

//Create a Param object within your namespace
myNamespace.Param = myNamespace.Param || {};

// Start of plugin parameters. Use JS default method to convert from string to a number.
myNamespace.Param.classNameXValue = Number(myNameSpace.Parameters['Class Name X'] || 0);


  Window_Base.prototype.drawActorSimpleStatus = function(actor, x, y, width) {
    // Assign classX to your plugin parameter.
    var classX = myNamespace.Param.classNameXValue;
    var lineHeight = this.lineHeight();
    var x2 = x + 180;
    var width2 = Math.min(200, width - 180 - this.textPadding());
    this.drawActorName(actor, x, y);
    this.drawActorLevel(actor, x, y + lineHeight * 1);
    this.drawActorIcons(actor, x, y + lineHeight * 2);
    // Add classX to the original x value
    this.drawActorClass(actor, x2 + classX, y);
    this.drawActorHp(actor, x2, y + lineHeight * 1, width2);
    this.drawActorMp(actor, x2, y + lineHeight * 2, width2);
};
  
})()

Original thread: https://forums.rpgmakerweb.com/threads/need-help-with-javascript-or-spacing-fix-for-actor-name-class-spacing.73159/