Cryranos

Veteran
Veteran
Joined
Jun 24, 2012
Messages
64
Reaction score
34
First Language
English
Primarily Uses
RMMV
This is the first plugin I've attempted to make (just a snippet to change font size), and I'm not sure if I'm understanding the process of overwriting parameters from the core scripts: changing the parameter in the editor doesn't change the font size. I have some experience with RGSS, so I'm not sure if I'm just not quite grasping javascript.
 

Attachments

  • KRY_Fontsize.js
    1.3 KB · Views: 9

??????

Diabolical Codemaster
Veteran
Joined
May 11, 2012
Messages
6,548
Reaction score
3,310
First Language
Binary
Primarily Uses
RMMZ
Just gonna drop my feedback on the code. Feel free to take it or leave it. :)

My main issue is that you shouldn't overwrite a method whenever possible. Instead use an alias. (see snippet below)

Code:
// annonomous function to wrap our code
(function(){
    const alias_initialize = Bitmap.prototype.initialize;
    Bitmap.prototype.initialize = function(){
        // call the old method before doing any changes
        alias_initialize.apply(this, arguments);
        // do changes here:..
    }
})();// < auto call the anon function

There is also no default method of 'standardFontSize'. not sure if your overwriting that from some other plugin or if its a function you are intending to add for yourself.

Default windows use the $gameSystem.fontXXX functions to get the information:
Code:
Window_Base.prototype.resetFontSettings = function() {
    this.contents.fontFace = $gameSystem.mainFontFace();
    this.contents.fontSize = $gameSystem.mainFontSize();
    this.resetTextColor();
};

Anyway I hope this helps some. :)
 

Cryranos

Veteran
Veteran
Joined
Jun 24, 2012
Messages
64
Reaction score
34
First Language
English
Primarily Uses
RMMV
I'm not particularly worried about overwriting these functions since this plugin is for use in my own project and not for general use, and I'm pretty close to just changing the values in the default scripts and moving on because I'm really, really short on patience these days.

There is also no default method of 'standardFontSize'. not sure if your overwriting that from some other plugin or if its a function you are intending to add for yourself.

Default windows use the $gameSystem.fontXXX functions to get the information:
Code:
Window_Base.prototype.resetFontSettings = function() {
    this.contents.fontFace = $gameSystem.mainFontFace();
    this.contents.fontSize = $gameSystem.mainFontSize();
    this.resetTextColor();
};

Anyway I hope this helps some. :)
This doesn't help but not because this isn't helpful information, but because I'm a total dunce right now.

I found that changing the number in line 50 of RPG_Windows changed the size of the in-game font, so I copied that into this plugin to overwrite it. I'm not trying to create anything new, I'm just doing this so I don't have to go back into the default scripts if I change to a different font later on.
 

Aerosys

Veteran
Veteran
Joined
Apr 23, 2019
Messages
728
Reaction score
698
First Language
german
Primarily Uses
RMMZ
There is also no default method of 'standardFontSize'. not sure if your overwriting that from some other plugin or if its a function you are intending to add for yourself.
In RMMV there's a function with this name.

Have you ever tried to press F12, to go into the Source Code, make a breakpoint and then to debug it? Your code looks good as far as I scanned it.
 

Kaelan

Veteran
Veteran
Joined
May 14, 2012
Messages
811
Reaction score
570
First Language
Portuguese
Primarily Uses
RMMV
Just gonna drop my feedback on the code. Feel free to take it or leave it. :)

What you mentioned is only relevant in MZ, the OP is writing code in MV.

@Cryranos Your code is actually mostly correct, you just mistyped the name of your own variables.

You declared your parameters as Kryrzanos.Parameters, but then later tried to access them as Kryrzanos.Param. If you just fix that, it should work.

A quick way to find these sorts of problems is open up the dev console and checking whether variables have the values you expect them to have. I found the above issue by typing Kryrzanos.Param.Fontsize in the console and seeing that it was undefined.

You can also clean the code up a bit, you don't really need to set the font size on both Bitmap and Window_Base, the Window_Base resetFontSettings function already changes its internal bitmap font size to standardFontSize . Cleaning things up a bit:

Code:
var Imported = Imported || {};
Imported.KRY_Fontsize = true;

var Kryrzanos = Kryrzanos || {};
Kryrzanos.Fontsize = {};
Kryrzanos.Parameters = PluginManager.parameters('KRY_Fontsize');

Kryrzanos.Parameters.Fontsize = Number(Kryrzanos.Parameters['Font Size']) || 28;

Window_Base.prototype.standardFontSize = function() {
    return Kryrzanos.Parameters.Fontsize;
};
 

Cryranos

Veteran
Veteran
Joined
Jun 24, 2012
Messages
64
Reaction score
34
First Language
English
Primarily Uses
RMMV
You declared your parameters as Kryrzanos.Parameters, but then later tried to access them as Kryrzanos.Param. If you just fix that, it should work.

A quick way to find these sorts of problems is open up the dev console and checking whether variables have the values you expect them to have. I found the above issue by typing Kryrzanos.Param.Fontsize in the console and seeing that it was undefined.

You can also clean the code up a bit, you don't really need to set the font size on both Bitmap and Window_Base, the Window_Base resetFontSettings function already changes its internal bitmap font size to standardFontSize . Cleaning things up a bit:

<CODE>
So I changed it to that and now the window text has completely disappeared. Now the parameter is undefined AND the text isn't showing up. I made another snippet to change the enemy/actor MHP/MMP/parameters and that one is returning correct variables and otherwise working as intended now that I've fixed the aforementioned misnamed variables.
 

Cryranos

Veteran
Veteran
Joined
Jun 24, 2012
Messages
64
Reaction score
34
First Language
English
Primarily Uses
RMMV
I actually figured it out. Both of my snippets are in separate plugins and both use Kryrzanos.Parameters to store their variables. I assume if i either collapsed them into one plugin or renamed the parameters category in one that would fix the new issue?
 

Kaelan

Veteran
Veteran
Joined
May 14, 2012
Messages
811
Reaction score
570
First Language
Portuguese
Primarily Uses
RMMV
You have to store the parameters from different plugins in different places, yeah. If you name them the same thing, one plugin would be overwriting the other.

There's a bunch of different ways to do this, there's no real "correct" way. You can look at other people's plugins if you want examples. I do mine like this:

Code:
// One plugin
var Knight = Knight || {};
Knight.Parameters = PluginManager.parameters('KNT_VisualParts');

Knight.Param = Knight.Param || {};
Knight.Param.Parts = {};
Knight.Param.Parts.RootFolder = String(Knight.Parameters['Root Folder']);
Knight.Param.Parts.DefaultCategory = String(Knight.Parameters['Default Part Category']);
Knight.Param.Parts.DefaultPriority = JSON.parse(Knight.Parameters['Part Drawing Order']);

// ...other parameters

Code:
// Another plugin
var Knight = Knight || {};
Knight.Parameters = PluginManager.parameters('KNT_Editor');

Knight.Param = Knight.Param || {};
Knight.Param.Editor = {};
Knight.Param.Editor.KEFilterType = String(Knight.Parameters['Doodad Selection Effect']);
Knight.Param.Editor.KEFont = String(Knight.Parameters['Editor']);
Knight.Param.Editor.KEPanelFont = String(Knight.Parameters['Edit Panel']);
Knight.Param.Editor.KEToggleKey = String(Knight.Parameters['Editor Toggle Key']).toLowerCase();

So I overwrite Knight.Parameters with each plugin, but it doesn't matter because I store all of the values I actually care about somewhere else that isn't overwritten.
 

Cryranos

Veteran
Veteran
Joined
Jun 24, 2012
Messages
64
Reaction score
34
First Language
English
Primarily Uses
RMMV
You have to store the parameters from different plugins in different places, yeah. If you name them the same thing, one plugin would be overwriting the other.

Alright, I combined them into a single "Core Parameters" plugin in this case. Now only the default values are returning no matter how I set them in the editor.
 

Kaelan

Veteran
Veteran
Joined
May 14, 2012
Messages
811
Reaction score
570
First Language
Portuguese
Primarily Uses
RMMV
You did the same thing again. You stored your parameters in Kryrzanos.Param, but you're trying to read them from Kryrzanos.Parameters
 

Cryranos

Veteran
Veteran
Joined
Jun 24, 2012
Messages
64
Reaction score
34
First Language
English
Primarily Uses
RMMV
I figured out what was wrong just before your response; it was just some typographical errors. I'm all good now I think. I'm definitely feeling the big dumb these days
 

Latest Threads

Latest Profile Posts

If you are a fan of TRPGs like Fire Emblem, take a moment to help me by filling out this:

Camping inside a hidden cave.
LzSHByh.jpg
I don’t believe in astrology. I’m a Sagittarius and we’re skeptical.
senary_concept_art.png
The concept art for the sprite of Senary, a major character in my upcoming (as-of-yet-unnamed) project. She is known as the Timelord because she can "stop time" by making eye contact with a person; Paralyzing them for a short period of time through a type of hypnosis. Tell me what you think about her. I'm thinking of changing the color of her coat.

Forum statistics

Threads
124,377
Messages
1,163,201
Members
163,175
Latest member
ChibiLily
Top