I've been attempting to change the damage font size to 40 whenever damage critically hits as opposed to +4, so damage numbers would be bigger on critical hits. But I'm not sure how to place main.fontSize in this setupCriticalEffect bracket without causing the game to crash or to say this.fontsize doesn't exist. Either all the damage numbers ends up 40 size or +4 standard, or the game crashes, (this is from sprites.js) I'm not sure what line to put here. Thank you.
MV - Need help fixing a small line of code
● ARCHIVED · READ-ONLY
-
-
As you can see,
setupCriticalEffectis called aftermakeDigits, which is where the font size is referenced. You will either need to acknowledge the critical hit earlier and use that to alter the font size (recommended), or redraw all critical hit popups in the larger font size.
This might work:
This is intended for use as a plugin:Plugin code suggestionJavaScript:(() => { 'use strict'; let crit = false; // internal flag, passes status between independent methods (alias => { Sprite_Damage.prototype.setup = function(target) { crit = target.result().critical; // update crit flag alias.apply(this, arguments); // default setup }; })(Sprite_Damage.prototype.setup); (alias => { Sprite_Damage.prototype.fontSize = function() { if (crit) return 40; // font size 40 if crit return alias.apply(this, arguments); // otherwise default size }; })(Sprite_Damage.prototype.fontSize); })();
- Copy+paste into a text editor (e.g. Notepad)
- Save As > File Type: All Files, Filename: whatever.js
- Import as a plugin through the Plugin Manager
- Save your project to apply Plugin Manager changes
- Test!
Note on code styleThe following snippets are all essentially identical:
JavaScript:(function() { let cake = 'tasty'; alert(cake); })();JavaScript:(() => { let cake = 'tasty'; alert(cake); })();JavaScript:This is called an IIFE, more info here:(cake => { alert(cake); })('tasty');
-
you explained it really well and the script works great, thanks for the script, link, and easy explanation. :)
-
[move]Javascript/Plugin Support[/move]