MZ Move ActorCommand over SV Actor Sprite...

So I've tried a few lines of code to see if I could get the actor command to appear over a character's head as listed below:

JavaScript:
Scene_Battle.prototype.actor = function(index) {
    return $gameParty.battleMembers()[index];
};

Scene_Battle.prototype.actorCommandWindowRect = function() {
    const actor = this.actor(index);
    const ww = 504;
    const wh = 38;
    const wx = actor;
    const wy = 331;
    return new Rectangle(wx, wy, ww, wh);
};

Index is not defined. Anybody able to see what I've done with my code? I'm trying to get the command window to show over the actor's head in case anybody's wondering.
I'm not really down for trying to write out a solution for this at this exact second, but I can point out some of the problems in your solution, to try to help point you in the right direction. In no particular order:

  • As you pointed out, you're passing index to your this.actor call, yet index doesn't exist.
  • Scene_Battle.prototype.actorCommandWindowRect only ever gets called one time--when the actor command window is created at the very start of battle. If your intention is to have the command window reposition itself for each new actor, then that's not the right method to overwrite. You're probably going to want to alias Window_ActorCommand.prototype.setup, and have it call a function that repositions the window. It gets called every time the actor changes, and it even has the relevant actor as a function parameter, so it would be a good method to use. It would help solve both this issue, and the one mentioned above.
  • You're trying to use an actor object as the x property of the rectangle. The x property needs to be a number, not a whole actor object.
  • You're using a static y value, even though your actors are all (presumably) positioned at different y coordinates.
You're probably going to want to alias Window_ActorCommand.prototype.setup, and have it call a function that repositions the window
Really not sure how to do this. All I've really done is little edits. Could only figure this out:
wx = 96 * actor;

even though your actors are all (presumably) positioned at different y coordinates
It's actually technically front view, but with SvActors modified to be facing up. Like Lufia or Phantasy Star.

Basically I think I'll need to multiply wx by the actor's ID since I only want the x coordinate to change.

Take your time answering it if you want to elaborate on it. Although I want to see about this aliasing function. Again, I'm not really a coder, but I've taken a quick glance at some of the modifications through trial and error. I've already reached a road block.
"Aliasing" is a technique that allows you to add your own code to an existing function without completely overwriting it. In JavaScript, the correct term is actually "monkey-patching", but people often refer to it as "aliasing" in the RPG Maker community. It allows you to make your own modifications/additions to the core scripts, while still maintaining compatibility with other plugins and future core script updates. Sometimes you have no choice but to completely overwrite a function, but it's ideal to try to alias when possible. The general structure for aliasing Window_ActorCommand.prototype.setup would be something like this:

JavaScript:
// Save the original function into a new variable
const Art_Window_ActorCommand_setup = Window_ActorCommand.prototype.setup;

// Re-define the function
Window_ActorCommand.prototype.setup = function(actor) {
    /* Put your own code here if you want */

    // Call the original function that we had saved into a new variable
    Art_Window_ActorCommand_setup.call(this, actor);

    /* Put your own code here if you want */
};

Without more information, it's kinda hard to tell you exactly what to do, but here is an example that might get you on the right track. Put this into a .js file and add it to your project through the plugin manager:
JavaScript:
const Art_Window_ActorCommand_setup = Window_ActorCommand.prototype.setup;
Window_ActorCommand.prototype.setup = function(actor) {
    if (actor) {
        this.repositionWindow(actor);
    }
    Art_Window_ActorCommand_setup.call(this, actor);
};

Window_ActorCommand.prototype.repositionWindow = function(actor) {
    const startingX = 100;
    const actorSpacing = 150;
    const ww = 192;
    const wh = SceneManager._scene.windowAreaHeight();
    const wx = startingX + actorSpacing * actor.index();
    const wy = 331;
    this.move(wx, wy, ww, wh);
};

I changed the ww and wh values that you had, because they would have yielded a crazily-wide window that is only tall enough to fit one line, and I wasn't sure if that was intentional or not. But obviously, feel free to change them to suit your needs. You will almost definitely need to change startingX and actorSpacing, since I just chose random values there.

startingX is the x value that would put your window above the very first actor. actorSpacing is the horizontal distance that the window needs to travel to be above the next actor--in other words, the space between each actor. This code assumes that you have equal space between each actor, btw.
Splendid! Thanks for going through all that trouble.

So should I wish to do this for other windows, I just have to change the names of said window, correct?

Once again, thanks for getting me out of this little rut.
You're welcome. Unfortunately, for other windows, it's not necessarily quite as simple as just changing the name. Not all windows have a .setup method, and the ones that do have the method don't necessarily work the same way. It's kinda something that's gotta be judged on a case-by-case basis.
I do want to ask one more though: let's say I want to put the actor command in separate "x" coordinates per actor.index() as opposed to using a formula. I kind of want more control over my positions since they seem a bit off.

IE:
Actor 1 = 0;
Actor 2 = 96;

And so on.
I do want to ask one more though: let's say I want to put the actor command in separate "x" coordinates per actor.index() as opposed to using a formula. I kind of want more control over my positions since they seem a bit off.
JavaScript:
switch (actor.index()) {
    case 0:
        const wx = blah;
        break;
    case 1:
        const wx = blah blah;
        break;
    case 2:
        const wx = blah blah blah;
        break;
    case 3:
        const wx = blah blah blah blah;
}

Like that, but instead of the blahs, put the x coordinate that you desire.
Um, wx is already declared...
Well, you wanna replace the part where we already declared it with that construct instead--since you say you don't need the formula that we had previously declared. Though I also messed up and shouldn't have used const there. If you don't need the formula at all, your new plugin would look something like this:

JavaScript:
const Art_Window_ActorCommand_setup = Window_ActorCommand.prototype.setup;
Window_ActorCommand.prototype.setup = function(actor) {
    if (actor) {
        this.repositionWindow(actor);
    }
    Art_Window_ActorCommand_setup.call(this, actor);
};

Window_ActorCommand.prototype.repositionWindow = function(actor) {
    const ww = 192;
    const wh = SceneManager._scene.windowAreaHeight();
    switch (actor.index()) {
        case 0:
            var wx = 100;
            break;
        case 1:
            var wx = 250;
            break;
        case 2:
            var wx = 400;
            break;
        case 3:
            var wx = 550;
    }
    const wy = 331;
    this.move(wx, wy, ww, wh);
};

Just replace the values with the ones that will work for you.
Now I think I know where I'm going! You are a lifesaver! Sorry for all the pestering! Formulas I was trying to use to center battlers even were a bit wonky too...
Not a problem.
I’m so glad I found this!! @Arthran thank you for raking the time.

Original thread: https://forums.rpgmakerweb.com/threads/move-actorcommand-over-sv-actor-sprite.149562/