Hello everyone, this is the first time I'm posting here because I really don't know how to proceed.
I'm trying to make a very simple help window plugin for my custom combat system. The idea is simple enough; display a window at the top of the screen that gives context to basic actor commands, such as attack, magic, guard and the like. Help text appears when the cursor is placed over the command. I got the window working and the script can identify basic commands without any problems.
Here's the issue; I also decided to add some personalized commands to my actors. These are in fact regular spells that can be selected directly from the actor's command window, and I'm having a lot of trouble with providing a description for them.
As it stands, my plugin is unable to tell the difference between two different skills, it just retrieves "skillID" without being able to identify the precise ID and thus provide the appropriate text in the help window.
I have absolutely no idea how to get the skill's ID, and trust me, I've tried xD ...
Here's what I got so far;
It is probably a bit messy as my understanding of the code is pretty limited, but if anyone can take a look and help me out, I'd be eternally grateful.
Edit : added images for additional context, in case my English is too sucky.
I'm trying to make a very simple help window plugin for my custom combat system. The idea is simple enough; display a window at the top of the screen that gives context to basic actor commands, such as attack, magic, guard and the like. Help text appears when the cursor is placed over the command. I got the window working and the script can identify basic commands without any problems.
Here's the issue; I also decided to add some personalized commands to my actors. These are in fact regular spells that can be selected directly from the actor's command window, and I'm having a lot of trouble with providing a description for them.
As it stands, my plugin is unable to tell the difference between two different skills, it just retrieves "skillID" without being able to identify the precise ID and thus provide the appropriate text in the help window.
I have absolutely no idea how to get the skill's ID, and trust me, I've tried xD ...
Here's what I got so far;
Code:
// Custom descriptions
var commandDescriptions = {
"attack": "Description of attack",
"item": "Description of items",
"skill": "Description of skills",
};
// Trying to get skill ID
function getCommandDescription(command, index) {
if (command === "skillID") {
var skillId = index;
if (skillId && $dataSkills[skillId]) {
var skill = $dataSkills[skillId];
if (skill.description !== undefined) {
return skill.description;
} else {
return "No description available";
}
} else {
return "No description available";
}
} else {
// If the command is another predefined command, return the corresponding description
var description = commandDescriptions[command];
if (description !== undefined) {
return description;
} else {
return "No description available";
}
}
}
// Command checker
Scene_Battle.prototype.updateHelpWindow = function() {
if (this._helpWindow) {
var item = this._actorCommandWindow.currentSymbol();
var index = this._actorCommandWindow.index();
// Display in the console to check the current command and index
console.log("Current command:", item);
console.log("Current index:", index);
var description;
if (item === "skillID") {
description = getCommandDescription(item, index);
} else {
description = getCommandDescription(item);
}
if (description !== null) {
this._helpWindow.setText(description);
this._helpWindow.show();
} else {
this._helpWindow.clear();
this._helpWindow.hide();
}
}
};
var _alias_scene_battle_window_actor_command_select = Window_ActorCommand.prototype.select;
Window_ActorCommand.prototype.select = function(index) {
_alias_scene_battle_window_actor_command_select.call(this, index);
SceneManager._scene.updateHelpWindow();
};
It is probably a bit messy as my understanding of the code is pretty limited, but if anyone can take a look and help me out, I'd be eternally grateful.
Edit : added images for additional context, in case my English is too sucky.
