MV Asking for help for my plugin (Show choices during Scene_Battle.prototype.onActorOk)
BMM Archive · July 15, 2026
Original Source
- Original title: MV Asking for help for my plugin (Show choices during Scene_Battle.prototype.onActorOk)
- Original author: rawang45
- Original date: July 19, 2021
- Source thread: https://forums.rpgmakerweb.com/threads/asking-for-help-for-my-plugin-show-choices-during-scene_battle-prototype-onactorok.138674/
- Source forum path: Game Development Engines > RPG Maker Javascript Plugins > Learning Javascript
Summary
First of all, this is my first time posting something on the forum, please tell me if I did something wrong. I hope I am not posting my thread on the wrong forum... Secondly, I only have limited knowledge of Javascript, and I do not have much experience in coding, so there are possibilities that I make some silly mistakes here and there. So,basically I want to achieve something like this: {
Archived First Post
Secondly, I only have limited knowledge of Javascript, and I do not have much experience in coding, so there are possibilities that I make some silly mistakes here and there.
So,basically I want to achieve something like this:
After players select themselves as target of item/skill, the code check if the certain skill/item is being used, then give player choices to proceed or to return.
I would like to achieve that when the player is using something on themselves, they can choose where they want to use the item for
for example, to use it on mouth, hand, leg, or to not use it, you get the idea.
For your information, I implement this plugin with YEP_BattleEngineCore plugin enables, but it should not affect much, as I have tried to run my plugin in new project, it seems to "work" just fine.
(By work I mean have the same problem lol)
Problems: Most of them work just fine, but problems appear as I am trying to code the red part. (I did not implement the skill part as I have no idea how to implement it, I only implement the item part)
I will post my code here, but for your convenience, please just go to my github to look at my code, it is basically the same thing, and I will also mention what I have tried there : My plugin in github
var Rawang = Rawang || {};
//Make changes to onActorOk
Rawang.Scene_Battle_onActorOk = Scene_Battle.prototype.onActorOk;
Scene_Battle.prototype.onActorOk = function() {
switch (this._actorCommandWindow.currentSymbol()) {
//Check if used certain item
case 'item':
switch ($gameParty.lastItem().id){
case 12:
this.checkConfirmation();
break;
default:
Rawang.Scene_Battle_onActorOk.call(this);
}
break;
//Default
default:
Rawang.Scene_Battle_onActorOk.call(this);
alert("default");
}
};
};
//If used certain item,show text & choices
Scene_Battle.prototype.checkConfirmation = function() {
$gameMessage.add("Hello!");
const choices = ["Continue", "Cancel"];
$gameMessage.setChoices(choices, 0, 0);
$gameMessage.setChoiceBackground(0);
$gameMessage.setChoicePositionType(1);
$gameMessage.setChoiceCallback(
//I have no idea how this work
function(choice){
this.calresolution();
});
//this is basically the Original code of Scene_Battle.prototype.onActorOk;
Scene_Battle.prototype.calresolution = function() {
var action = BattleManager.inputtingAction();
action.setTarget(this._actorWindow.index());
this._actorWindow.hide();
this._skillWindow.hide();
this._itemWindow.hide();
this.selectNextCommand();
};
I want to make that code will run after players make their choice, then decided whether procceed or return to the item page.I have no idea this is possible or not.
I think I am using the word "this" wrongly in the callback function, however, I have no idea how to make it work anymore. I tried instead using Scene_Battle.prototype.calresolution.call/bind/apply, or simply just put Scene_Battle.prototype.calresolution(). None of those works, they either show "xxx is not a function", "cannot read index of undefined" , or they will simply cause the game to freeze.
I tried to save the "this" keyword from Scene_Battle.prototype.checkConfirmation to a gameVariable: $gameVariables.setValue(52, this);
and save it in another variable in the next function (Scene_Battle.prototype.calresolution)
var calobj = $gameVariables.value(52);
then change all "this" keyword in calresolution function to calobj
eg. this._actorWindow.hide(); => calobj._actorWindow.hide();
When I test run after making these changes, it simply freezes my game after the calresolution function is called.
I know, to achieve what I want to do, I would need to write code that return player to the item/skill page. Here is the code that will run successfully, if completely overwrites Scene_Battle.prototype.onActorOk with these code:
Scene_Battle.prototype.onActorOk = function() {
this._actorWindow.hide();
this._helpWindow.clear();
switch (this._actorCommandWindow.currentSymbol()) {
case 'skill_type':
this._helpWindow.hide();
this._skillWindow.show();
this._skillWindow.activate();
break;
case 'item':
this._itemWindow.show();
this._itemWindow.activate();
break;
}
};
Maybe this can be achieved using other way. If so, please tell me how to do it. I really hope I can implement this as it will play an important role in my game
I am not a native English speaker, so I hope I have not messed up my grammar too much Have a nice day!
Downloads / Referenced Files
Log in, then follow the RPG Maker Developers Group to see these download links.
Log in to downloadCreator Claims / Removal
If you are the original creator and want this listing reassigned, edited, or removed, join BMMPlay and contact the moderators with proof that matches the original RPG Maker Web profile, linked GitHub, itch.io page, or another public creator identity.
Replies (0)
No replies yet.
Topic Summary
Loading summary...