RMMV: how to change an actor's image to file determined by variable?

Hi again! Still working on my game's character creation phase.
This time I need a way to have the character image change to X, where X is a variable that I get by combining various factors. That is, the player is prompted to make a few choices (sex, race, class). The combination of these choices should point to a unique sprite. I tried something really stupid: setting up a variable(x) to be = variable sex * variable race * variable class (I managed to make it so that the results are always different).
And then run this script
Code:
$gameVariables.setValue(11, $gameVariables.value(9) * $gameVariables.value(6) * $gameVariables.value(5));
$gameActors.actor($gameVariables.value(7)).setCharacterImage($gameVariables.value(11), 0);
$gameActors.actor($gameVariables.value(7)).setFaceImage($gameVariables.value(11), 0);
$gameActors.actor($gameVariables.value(7)).setBattlerImage($gameVariables.value(11));
$gamePlayer.refresh();
but it obviously results in an error where "filename.match is not a fuction".

Is there any way to script this shortcut, or do I have to write like 40 different if/else branches for each unique combination? Thank you!
That's because you don't put the filename, i think.
The code to change the character image is that:

Code:
"$gameActors.actor(actorId).setCharacterImage("name", index);
$gameActors.actor(actorId).setFaceImage("name", index):
$gameActors.actor(actorId).setBattlerImage("name");
$gamePlayer.refresh();"

Name = name of the file that contains the image you want.
Index = if is a image with an entire faceset(8 faces), so you have to especify the index 0-7. In the order below:
0 1 2 3
4 5 6 7

That means, $gameVariable.value(11) Must be a string(a text, a word) -[EDIT] (Unlesse your image has been named with a number xD).
You can put that in this way:
$gameVariables.setValue(11, "Alex");
Or
Using the Script field in Control Variables. Just make sure to put the name in quotes.

I dont know why you are making this by script call. But i think that would be more simple if you use the event commands(Control variable values and conditional branch). Maybe it can become bigger in the event page, but if it is only for character select does mean that it will do only one time?

Maybe i can do something for you. How many factor you have? How many actors, and race and classes?
Edit: Yep, images are named as numbers. Still getting that filename.match error.

That's the problem. It's about... Like 60+ different graphics. And you can do it for all party members. It's a lot, and that's why I'm trying to use shortcuts!

I thought that if a variable had a number the command would read that number as a word (and I was about to name character assets 17.png, 29373920000000.png, etc.)

Maybe I can try a longer script to write a text variable that merges words in a single one... So that I end up with (for example) malehumansoldier.png . I don't even know how to start this however. Thanks for the help anyway!
Edit: Yep, images are number as numbers. Still getting that filename.match error.

That's the problem. It's about... Like 60+ different graphics. And you can do it for all party members. It's a lot, and that's why I'm trying to use shortcuts!

I thought that if a variable had a number the command would read that number as a word (and I was about to name character assets 17.png, 29373920000000.png, etc.)

Maybe I can try a longer script to write a text variable that merges words in a single one... So that I end up with (for example) malehumansoldier.png . I don't even know how to start this however. Thanks for the help anyway!
Woww.. Theres a lot of work then!
I will see if i can try do this in a little scope. If i make it i let you know!
It's because match is a function for strings, not numbers. 😅

You can use String(input) to turn other types into text, e.g. Control Variables > Script:
Code:
String($gameVariables.value(9) * $gameVariables.value(6) * $gameVariables.value(5))
You could also do the multiplication beforehand with event commands if you want (less prone to typos!). I.e. set equal to variable 9, multiply by variable 6, multiply by variable 5, then set equal to String($gameVariables.value(11)). 🙂
It's working! IT'S WORKING! Thank you, you beautiful programmer!

Original thread: https://forums.rpgmakerweb.com/threads/rmmv-how-to-change-an-actors-image-to-file-determined-by-variable.108836/