I'm trying to reference an actor's magic attack parameter without using a variable as an intermediary.
The end goal is for a weapon's attack bonus to be equal to the character's mat. Since the weapon can only be equipped by one specific character I'm directly referencing his stats, but I'm open to anything that works. Everything is working except the call for this value.
I'm currently using this:
<Custom Parameters>
atk = $gameActors.actor(2).mat
</Custom Parameters>
I've tried a lot of different things, but this is the attempt that seems less wrong... it returns a range error that prevents the game from running. Most of my attempts result in this error. Though sometimes my attempts result in the game using the value "NaN".
If I put an integer to the right of the equal sign it works. If I put a parameter (mhp, mmp, atk, def, mat, mdf, agi, luk) right of the equal sign, it works but it uses the weapon's parameter rather than the actor's.
I've spent two nights google and forum searching for anything that might provide insight, but either there's nothing to be found or I'm not using the right keywords. Anyone able/willing to help?
Anyway. I figure I'm just a noob and this doesn't deserve a topic.
JavaScript questions that don't deserve their own thread
● ARCHIVED · READ-ONLY
-
-
Nevermind! Solved it!
<Custom Parameters>
atk = user.paramBase(4)
</Custom Parameters>
So proud of myself! -
So turns out my issue wan't the aliasing
What i had:
(function() {
var oldcanequip = Game_BattlerBase.prototype.canEquipWeapon;
Game_BattlerBase.prototype.canEquipWeapon = function(item) {
return false;
};
});
Turns out I was missing the () at the end:
(function() {
var oldcanequip = Game_BattlerBase.prototype.canEquipWeapon;
Game_BattlerBase.prototype.canEquipWeapon = function(item) {
return false;
};
})();
now works correctly
*Facedesking -
How can I determine which actor is currently active in Window_EquipStatus?
I'm adjusting the params to only display certain params depending upon which actor is currently selected:
Window_EquipStatus.prototype.refresh = function() { this.contents.clear(); // display max HP and MP for all actors if (this._actor) { this.drawActorName(this._actor, this.textPadding(), 0); for (var i = 0; i < 2; i++) { this.drawItem(0, this.lineHeight() * (1 + i), i); } } // display param 2 for actor 1 if (this._actor) { for (var i = 2; i < 3; i++) { this.drawItem(0, this.lineHeight() * 3, i); } } // display param 3 for actor 2 // display param 4 for actor 3 // display param 5 for actor 4};However, I am not sure which statement to use in place of this._actor in order to only display a param when, for example, Actor 1 is active.
Edit: Never mind. The answer is:
Code:if (this._actor === $gameActors.actor(1)) { for (var i = 2; i < 3; i++) { this.drawItem(0, this.lineHeight() * 3, i); } } -
Pretty sure that this doesn't deserve its own thread but...
How can I go about changing the color of the text used in the battle menu? I have tried scouring the base .js files and can't seem to get it to work. What I am specifically talking about is this:

I'd like to make this text color match a different color in the window.png file, but cant find where to edit the value.
Thanks a bunch!
Edit: Also is there any way to make the selection not cycle through so much opacity? Im trying to make the white selection bar just flash 0 and 150 opacity instead of going 0>10>20, etc. -
What is that window? A full screenshot would have been more helpful.
It's systemColor(). This is where it's done in the default scripts:
Code:but the default battle window doesn't look at all like your screenshot, so you must have a plugin that modifies it. That would have been helpful information to include (and maybe your question should go into the support thread for that plugin).Window_Base.prototype.drawActorHp = function(actor, x, y, width) { width = width || 186; var color1 = this.hpGaugeColor1(); var color2 = this.hpGaugeColor2(); this.drawGauge(x, y, width, actor.hpRate(), color1, color2); this.changeTextColor(this.systemColor()); this.drawText(TextManager.hpA, x, y, 44); this.drawCurrentAndMax(actor.hp, actor.mhp, x, y, width, this.hpColor(actor), this.normalColor());}; -
Thank you Shaz, I think i'll post this question in the Yanfly Script help. I appreciate your direction and response!
-
I want to make an accessory with Yanfly's Equip Core and it's custom parameters, that changes Element Rate based off of the characters level, and was wondering if that's even possible? (Or should I post it as a suggestion in Yanfly's thread?)
If it is, what I wanted to do is:
Element Rate % = 100 - Character's Level. -
In the help files of these two default plugins, ItemBook.js and EnemyBook.js, I've made an event where the player can talk to a person to get the books. They are read from the menu item screen (connected a common event to open). Then consecutive conversations adds individual entries and completes the entries. I want the player to unlock the entries by talking to people, so placing the plugin command directly into the event should unlock it but it doesn't work.
Where would I place the following commands: "ItemBook add 3" and "EnemyBook add 3" or "ItemBook Complete"?
EDIT: I've figured out what went wrong. I was typing the commands incorrectly. I wrote "Itembook add 1" when it should have been "ItemBook add item 1" and same goes for the Enemy Book.
I'm going to try the revised events in an older project to see if it was just a simple misspelling.
EDIT 2: Yep it was. It works now! :D Capitalization matters. -
I'm trying to make a skill that deals more damage if the actor is equipped with a Claw (type id 10).
if (a.equips[0].wtype == 10){x = a.atk * 2.5} else {x = a.atk}; x * (1 - (b.def / (b.def + 100)));but it returns me 0. is it wrong? I tried to follow the example in the script calls doc... -
I need to use the space key so I commented out this line in rpg_core.js:
Input.keyMapper = {
...
//32: 'ok', // space
...
}
This is the only mention I can find for the word "space". It doesn't work, space still triggers 'ok'.
Is it called somewhere else?
EDIT: It worked, it turned out to just be a caching issue.
. -
Not sure where to ask this, so I'll ask it here...
I've modified the pause menu's "Gold Window" to display the current playtime. It technically works, but it doesn't update while the menu is open. (So if it shows 5 minutes of playtime when the menu is opened, it won't change from that until the menu is closed and re-opened).
I've tried a few things to try to make the window update, but I'm not sure how to get it to work. Is there a way in the scene/window functions to call the refresh function every so many frames? -
Hey guys! I have a few questions when it comes to making a custom status menu.
My first step with every project is to try to swap around the status menu in order to compact everything in a reasonable way, and show more information. With this in mind, I have a few questions. How can I add flat text to the screen? For example, I would like to add the text "Class: " next to the class of the character, as well as add names of particular stats to the editor that usually aren't shown.
If possible, I would like to change the font size specifically while in the menu.
And how would I add extra parameters to the ones displayed in the menus already. For example, adding the critical hit rate, or the evasion rate so it sits under he luck stat for viewing. I may not fully understand Javascript yet, but I like to do something simple like this so I know I'm a bit more familiar with it. Can anyone please help with some general tips?
I've gotten as far as to reaching the Window_Status area in the editor, and have been able to edit certain assets, but I can't figure out much more than that. -
@TheGamedawg
I'm the same way with my status screen. For your first question, you could do something like
Window_Status.prototype.drawClassLabel = function(x, y) { this.changeTextColor(this.systemColor()); this.drawText('Class', x, y, 200, 'left'); this.resetTextColor(); }and then under Window_Status.prototype.refresh
Code:change yourX and yourLH in order to position it to your liking.I'm new to JavaScript as of MV, so there could be a more efficient way. But that's how I did it.this.drawClassLabel(yourX, lineHeight * yourLH);
(Edited to clarify who I'm replying to). -
I'm trying to make a skill that deals more damage if the actor is equipped with a Claw (type id 10).
if (a.equips[0].wtype == 10){x = a.atk * 2.5} else {x = a.atk}; x * (1 - (b.def / (b.def + 100)));but it returns me 0. is it wrong? I tried to follow the example in the script calls doc...Code:which you could shorten toif (a.equips()[0].wtypeId === 10){x = a.atk * 2.5} else {x = a.atk}; x * (1 - (b.def / (b.def + 100)));
Code:(a.equips()[0].wtypeId === 10 ? 2.5 : 1) * a.atk * (1 - (b.def / (b.def + 100)))
I don't think play time updates while the menu is open, does it? If you open the menu, wait 5 minutes, then close and open it immediately, does it show 5 minutes or so later than the previous play time? Or only a couple of seconds later? Either that, or you're not refreshing the window on each frame.I've modified the pause menu's "Gold Window" to display the current playtime. It technically works, but it doesn't update while the menu is open. (So if it shows 5 minutes of playtime when the menu is opened, it won't change from that until the menu is closed and re-opened). -
When I sit in the menu for, say, 20 seconds, then close and reopen the menu immediately, the playtime will update to 20-21 seconds more than the previous value. So I'm pretty sure the playtime is updating, I just don't know how to make the window refresh after each frame.I don't think play time updates while the menu is open, does it? If you open the menu, wait 5 minutes, then close and open it immediately, does it show 5 minutes or so later than the previous play time? Or only a couple of seconds later? Either that, or you're not refreshing the window on each frame.
For reference, this is the text call in the window's refresh function:
Code:Either the window's refresh function isn't being called every frame, or the "playtimeText" function isn't updating properly...this.drawText($gameSystem.playtimeText(), x, 0, 400, 'right'); -
I believe the refresh methods are only called on demand, and the update methods are called every frame.
Copy the refresh method into the update method and see if it updates. Or better yet, create an update method that simply calls this.refresh()
And be prepared for a possible slight performance hit as it is clearing and redrawing the contents on every frame. -
Still not working... I'm starting to wonder if the window is considered inactive or something. As far as I can tell, only one command window can be active at any one time. But this isn't a command window, so it should be able to be active... I know that's how the help window updates based on what item is selected in a command/select window.I believe the refresh methods are only called on demand, and the update methods are called every frame.
Copy the refresh method into the update method and see if it updates. Or better yet, create an update method that simply calls this.refresh()
And be prepared for a possible slight performance hit as it is clearing and redrawing the contents on every frame.
Edit: Found a fix. The window's update function doesn't seem to run each frame, but the scene's update function does. I created an update function for the scene and had it call the refresh for the playtime, and now it seems to work. Thanks for the hint.
Edit 2: Maybe it didn't work. The text updates, but now the command window can't be used because of the redraw every frame... [After checking again, just adding the update function to the scene caused it to freeze up.] -
@Jackkel Dragon
Maybe try to add some kind of timer to your update method to refresh it on every 60 frames ( == 1 second) ?
Scene_Menu.prototype.initialize = function(){ // Here goes the original code, and at the end add : this._updateTimer = 0;}Scene_Menu.prototype.update = function(){ // Original code ... this._updateTimer += 1; if(this._updateTimer >= 60) { this._updateTimer = 0; // And refresh the window here. }}Sorry, I'm still new to this, but I know how we did such things in VXAce.
On the other note, a question that I know it has been asked many times, what is the alias alternative in JS?
I know people asked that, I just can't find where... -
@Jackkel Dragon
@Kocka
or if you want it as a plugin.
Code:// protecting global namespace(function () { // Aliases var init = Scene_Menu.prototype.initialize; var update = Scene_Menu.prototype.update; // overriding initialize Scene_Menu.prototype.initialize = function () { init.apply(this, arguments); // calling alias this._updateTimer = 0; // start the timer at 0 or 1 if you want to skip the first update } // Overriding the function Scene_Menu.prototype.update = function () { if (this._updateTimer == 0) { // this runs on the first update too // INSERT YOUR CODE HERE... } // Let's update the timer over 60 frames this._updateTimer = (this._updateTimer + 1) % 60; // 60 frames = 1 sec // calling the alias update.apply(this, arguments); }})();