MZ Little Help Please

RPG Maker MZ. So I wrote my own script to change my actors graphic to display off of "_Tools" and switch back to "_Walking" when done. The only problem is I installed Visustella MZ Character Class Change System. Upon doing this my script no longer is working. Before it would switch the graphics for me now it doesn't. Can anyone help?

//Get the Actor ID of the Player
var actorId = $gameVariables.value(34);
//Find the actor with the specified ID
var actor = $gameActors.actor(actorId);
//Add "_tools" to the filename
var newGraphic = (Actor + actorId + "_tools");
//Changes the actor graphic
actor.setCharacterImage(newGraphic, 0);
actor.setFaceImage(newGraphic, 0);
actor.setBattlerImage(newGraphic);
// Refresh the actors appearance
$gamePlayer.refresh();
//Log the Switch
console.log(newGraphic);

So what this does is essentially calls Actor()_Tools.png
I don't think it has anything to do with a plugin, you're going back and forth between capitalizations. Code is case-sensitive, so when you declare
Code:
var actor =
and then do
Code:
Actor + actorId
that will result in undefined, since there's no such thing as Actor.
Also, actor is $gameActors(actorId) which is an actor object. This is not a string, so you can't have a filename that starts with an actor object.

Maybe that should be newGraphic = "Actor"+actorId+"_Tools"?


Please use more meaningful thread titles in future. Everyone who posts wants "a little help" - put in the title a few words that point at what you need.
I also see that you're doing the same thing in your post - you're calling it "tools" in the code but then typing "Tools" later. You need to actually match the filename on your hard drive.
Spoiler: Old Post
"Sorry the tools was a typo I did while switching it over to here it should be "_Tools" as the filename and code.
The "Actor" though is supposed to be just that static no change. I'm trying to get it to search essentially for the filename based off this template.
"Actor(# searched for)_Tools"
Also thank you all for the replies that was way faster than I thought itd be and i'll try those suggestions out now. Edit in a minute"

Ok so I tried out the suggestions. Now the code is not switching the character graphic at all anymore for me. I'm using a script command in a event to add this in.

Spoiler: Code
//Get the Actor ID of the Player
var actorId = $gameVariables.value(34);
//Find the actor with the specified ID
var actor = $gameActors.actor(actorId);
//Setup the automatic filename finder
var newGraphic = ("Actor" + actorId);
//Changes the actor graphic and adds the extension onto the end.
actor.setCharacterImage(newGraphic + "_Walking", 0, actor.characterIndex());
actor.setFaceImage(newGraphic + "_Face", 0);
actor.setBattlerImage(newGraphic + "_Battler");
// Refresh the actors appearance
$gamePlayer.refresh();
//Log the Switch
console.log(newGraphic);
So the console log is displaying, "Actor1" or "Actor2" which is what i'm looking for. But the graphic ingame doesn't change. This works fine though until I switch classes and then it no longer works to change my graphic

Also thank you all for helping a novice who has no clue what their trying to ask for

So I tried changing to this. Not much better though

Spoiler: Newest Code
var actorId = $gameVariables.value(34);
var actor = $gameActors.actor(actorId);
var newGraphic = "Actor" + actorId + "_Tools";
actor.setCharacterImage(newGraphic, 1, actor.characterIndex());
actor.setFaceImage(newGraphic + '_Face', 0);
actor.setBattlerImage(newGraphic + '_Battler');
$gamePlayer.refresh();

Starting to think it may be easier to just track class than this
Can you confirm that removing the Visustella plugin causes this to work again? We need to be sure whether the issue is caused by the plugin or not.

What about if you change your event to use event commands rather than script calls? I know that's not what you eventually want, but for troubleshooting purposes it will help narrow down the search for the cause.
Hi there!
It will also be nice if you put your code, inside the code tag on the post, like this:
JavaScript:
//Get the Actor ID of the Player
var actorId = $gameVariables.value(34);
//Find the actor with the specified ID
var actor = $gameActors.actor(actorId);
//Setup the automatic filename finder
var newGraphic = ("Actor" + actorId);
//Changes the actor graphic and adds the extension onto the end.
actor.setCharacterImage(newGraphic + "_Walking", 0, actor.characterIndex());
actor.setFaceImage(newGraphic + "_Face", 0);
actor.setBattlerImage(newGraphic + "_Battler");
// Refresh the actors appearance
$gamePlayer.refresh();
//Log the Switch
Event commands do not work I think what's happening is that the plugin is attempting to keep my graphic the same and I'm trying to switch it. I may just remove the plugin and use event commands for class changes and use this for switching. Also would it be better to search class and name my variable off of it instead of using a common event in game variable to switch?
So after some more testing this script works until the plugin changes the actor graphic after that it still searches but the plugin overrides it and switches the graphic back
Ok sorry for such a late reply and also really thankful for all the help. Especially with you all putting up and attempting to decode my scatterbrain. We'll consider this a bump and some new questions to the current topic.
I'll post the script I have working and see what you all think.
*Current Win*
VisuMZ_ClassChangeSystem and my script are compatible, problem lies in frames.
*Problem though*
VisuMZ_ClassChangeSystem overrides my script at the next available frame.
*possible solution*
Override VisuMZ for 12 frames to prevent it switching and then I don't even need to switch back because VisuMZ will cover that for me.

var actorId = $gameVariables.value(34); var actor = $gameActors.actor(actorId); var newGraphic = "Main" + actorId + "_Tools"; actor.setCharacterImage(newGraphic, 1); $gamePlayer.refresh(); console.log(newGraphic); //--->Potential Code that may or may not be used<--- //These are simply codes that I may use in the future or //not alongside the //actor.setFaceImage(newGraphic + '_Face', 0); //actor.setBattlerImage(newGraphic + '_Battler'); //========================================

This I would like to use though to replace "var actorId = $gameVariables.value(34);"
Currently i'm using a common event with a conditional branch stating essentially
if Actor #001 Class = 3,
Control Variables (34) = 3
This would help because it would allow me to automatically tie in the number of the actors class to the filename template i'm using. Such as search "Main(classId)_Tools" I'm just not sure how I would implement the code, I just found it in the scripts archives.

// Get the current class of the party leader $gameParty.leader().currentClass()

Image of my currentl Event to aid in assistance.

1684944768527.png


Just to say it one more time I am very thankful to everyone that's replied.
I know it's been awhile since this was posted and this may count as a double post but we'll call it a bump. I solved the issues with this script. While the console.log is not a requirement, while testing I like it active until I know the transition is cooperating appropriately. Place this in a javascript file and load it into your plugins. The use your function such as, YourNameHere() to call this from a custom moveroute script command.

function YourNameHere() { var actor = $gameActors.actor(1); var currentClassId = actor.currentClass().id; var currentClass = $dataClasses[currentClassId]; var newGraphic = "Actor" + currentClassId + "_Tools"; actor.setCharacterImage(newGraphic, 0); $gamePlayer.refresh(); console.log(newGraphic);}

To use additional spritesheet templates edit this portion of the code
actor.setCharacterImage(newGraphic, (No () edit here));

Original thread: https://forums.rpgmakerweb.com/threads/little-help-please.157733/