Conditional branch that checks actor's images?

Hello guys!

I'm working in rmmv and I managed to make the actor to be able to sit on the floor when hitting a key. I did it by using yanfly's button common events, and assigning a key to a common event in which the actor sprite changes to a sprite of him sitting, and another one that changes it back to the sprite of the actor standing. It worked fine, but here's the problem:

My actor changes sprites at various points of the game. I made sitting graphics for each different sprite and what i'm trying to do is that when the actor has x sprite, it changes to it's corresponding sitting graphic. So yeah, my question is if there is a way to use a conditional branch that checks which image the actor currently has, probably via script call?. I hope I'm making sense ^^;

Also just in case, I'm a noob so I apologize if I posted this in the wrong forum
You can use those if it's your leader :
  • to get the image file name : $gamePlayer._characterName
  • to get the image file index : $gamePlayer._characterIndex
If you need it for other party members (where x is the member number) :
  • $gameParty.members()[x]._characterName
  • $gameParty.members()[x]._characterIndex
Thank you so much for the fast reply!

Just another dumb question: do i replace characterName with the name of the png file, right?
I'm sorry if it's pretty obvious, I'm just not very familiar with script calls yet! ^^;;;;;;;
Sorry I wasn't really clear.
If you want to check those in a conditional branch with a script call,
If your standing sprites are in the same file you'll just need to check the index number like this :
Code:
$gamePlayer._characterIndex == Your picture index
if they're on different files, you'll need to check the file name like this :
Code:
$gamePlayer._characterName == 'Your picture file'
Just replace Your picture index or Your picture file by the values you're looking for.
Wouldn't it be easier to just use a single variable, with each possible value referring to a version of your sprite? Then you just need to do a Conditional Branch to see if the variable is equal to each version, and use the appropriate "sitting" version.

Or if you have, say, 8 different versions of your character, you can put them all onto a single character sheet (so one character sheet will contain your character walking, in all 8 forms, one will contain them sitting, one will contain them, say, swimming and another riding a horse). So the character name refers to the pose, and the character index refers to the version. Or if you have more than 8 versions, but 8 or less poses, do it the other way around.

Then you just need to do a script call to change either the character name or the character index, and you don't have to bother with checking what they currently are.
It's working perfectly, thank you! 😂

Wouldn't it be easier to just use a single variable, with each possible value referring to a version of your sprite? Then you just need to do a Conditional Branch to see if the variable is equal to each version, and use the appropriate "sitting" version.

Or if you have, say, 8 different versions of your character, you can put them all onto a single character sheet (so one character sheet will contain your character walking, in all 8 forms, one will contain them sitting, one will contain them, say, swimming and another riding a horse). So the character name refers to the pose, and the character index refers to the version. Or if you have more than 8 versions, but 8 or less poses, do it the other way around.

Then you just need to do a script call to change either the character name or the character index, and you don't have to bother with checking what they currently are.

Yes that's kinda what I did, I have a spritesheet with the walking cycle of each version of the character, and another one for the sitting version. I made sure that the sitting version and the standing version had the same index.

I just didn't thought of making a variable at first because i'm more familiar with the branches than the variables, but it sounds more effective
The most effective way to do this with eventing would be to store a key number for the current graphics into a variable when you change the graphics, and then check the variable whenever you need to know the current image.
The only requirements here is to always use a control variable command to change the value whenever you use change actor graphics.

Original thread: https://forums.rpgmakerweb.com/threads/conditional-branch-that-checks-actors-images.93501/