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

Nerdboy

Veteran
Veteran
Joined
Jan 4, 2017
Messages
78
Reaction score
7
Primarily Uses
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...
 

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
31,431
Reaction score
7,712
First Language
German
Primarily Uses
RMMV
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.
 

LTN Games

Indie Studio
Veteran
Joined
Jun 25, 2015
Messages
704
Reaction score
631
First Language
English
Primarily Uses
RMMV
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.
 

Nerdboy

Veteran
Veteran
Joined
Jan 4, 2017
Messages
78
Reaction score
7
Primarily Uses
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.
 

LTN Games

Indie Studio
Veteran
Joined
Jun 25, 2015
Messages
704
Reaction score
631
First Language
English
Primarily Uses
RMMV
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);
};
  
})()
 
Last edited by a moderator:

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

Latest Threads

Latest Profile Posts

Day 9 of giveaways! 8 prizes today :D
He mad, but he cute :kaopride:

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.

Forum statistics

Threads
106,040
Messages
1,018,470
Members
137,821
Latest member
Capterson
Top