Checking Actor's Image?

I know the title is confusing, so allow me to explain in detail.

I have this system where the player can crawl or walk by pushing a button. I'm using Galv's Character Animations to achieve this effect. After pushing the key, the player goes into a "kneel" position and moving allows them to crawl.

Basically, I'd like the player to be able to toggle between kneeling or standing at the push of a button/key.

My initial thought was to make a conditional branch that checks the Actor's Image. Something like below:

◆If:Script:$gameActors.actor(0)._characterName === Aelina(main).png
◆Set Movement Route:Player (Wait)
:Set Movement Route:◇Speed:2
:Set Movement Route:◇Image:Aelina (crawl)(0)
◆Wait:10 frames
◆
:Else
◆Set Movement Route:Player (Wait)
:Set Movement Route:◇Speed:4
:Set Movement Route:◇Image:Aelina(main)(0)
◆Wait:10 frames
◆
:End

I've tried to go through the .js files for a hint on how to check the actor's image/spritesheet. And obviously, I've failed.

Is there a "script-call" I can use or a better way to do this?

Thanks!
There is no actor(0). Actor ids are as you see in the actor's tab. Actor 1 is $gameActors.actor(1).

=== "Aelina(main)"

in quotes, no extension.
Well, the good news is that I no longer get any errors.

The bad news is that when I press the key again, she doesn't revert to the other image. ;_;

(However, I am super glad I almost got the script call right!)
Your script conditional is fine, but actually it is the "Move Route-Change Image" command that isn't working the way that you want it to.

Try this: With your event set up as it currently is, trigger the crawling animation. Press F8 to open the console and type
"$gameActors.actor(1)._characterName"
Notice that it still is the same file name as before? This is why the 'else' branch of your conditional statement never gets triggered.

Instead of "Move Route-Change Image", try the "Change Actor Images" event command, I think you will find that it works as you expect.


EDIT:
You can also change the script check to $gamePlayer_characterName .
The concept is that the Move Route-Change Image only changes the image for that map. You can test this by changing the image with Move Route and then transferring to a new map. Notice that your player is back to the normal image?
As far as I can tell, $gamePlayer is refreshed when you go to a new map so it's more like temporary data.
That actually works! I have ONE question, however.

Am I able to also temporary change the player's speed using a script call too?
Isn't there a Change Actor Speed command? If not, you can do it through the move route.
Yeah, but didn't @Aloe Guvner say that method wouldn't work (using move routes)?
I don't actually see why the move route method wouldn't work to change the image. The only issue I can see that you might have is the wait 10 frames. If you have all of that wrapped in a "is button pressed" condition, you may just not be pressing the button at the exact moment it's checking for a button press.
The move route method didn't work, even when I took out the wait 10 frames. 🙁
I think I didn't explain it well enough:

Both the "Move Route-Change Image" and "Change Actor Images" commands will work to change the image on the screen. The difference is in the depth with which they change the data.

"Move Route-Change Image"
  • Changes the image in $gamePlayer._characterName (this is what is shown on the screen to you)

"Change Actor Images"
  • Changes the image in $gamePlayer._characterName (this is what is shown on the screen to you)
  • Changes the image in $gameActors.actor(X)._characterName (this persists from map to map)

@StrawberrySmiles The question is whether you want the changed image to persist to the next map.
  • If the player 'crawls' to the next map, should they still be 'crawling' when the next map loads?

Make sure to check the appropriate property in the script conditional based on the method you choose.
I'd like for the player to begin "standing" when the next map loads. So I wouldn't have a problem with the "Move Route-Change Image" but the image only changes when using the "Change Actor Image" instead.
I'd like for the player to begin "standing" when the next map loads. So I wouldn't have a problem with the "Move Route-Change Image" but the image only changes when using the "Change Actor Image" instead.

I think you mean 'the image only changes back when using the "Change Actor Image" instead (the Else branch).

Check what I listed above and make sure that your script conditional is checking the correct condition - if you use the Move Route option then you have to check $gamePlayer, not $gameActors.
When I change it to $gamePlayer it gives me an error straight up.
Sorry, I was being general in order to try to explain the theory behind it.
$gamePlayer._characterName is the one you need.

$gamePlayer is the overall structure that holds the data about the player when she/he is on the map (like X coordinate, Y coordinate, etc.). So if I wanted to know where the player is on the map I could access their coordinates by doing $gamePlayer.x and $gamePlayer.y
  • Similarly, to know the name of the character sprite I can do $gamePlayer._characterName

You can see this visually by testing your game and pressing F8. Then, just type $gamePlayer. It will show all the properties of the player.

Below is a sample event that worked for me. Of course, replace Actor1 with the appropriate name and add your other commands.
Spoiler
Changing Character Graphic.png

Spoiler
Developer Console.png
Why not use a switch? Press the button, do your change actor image, then move route command to slow the player then switch on crawl switch. Then in your conditional branch check to see if switch is on or off. When the switch is on and the player presses the button again you change image movement speed and flip the switch off
@Aloe Guvner - Oh! This worked perfectly! Thanks!

@OnslaughtSupply - Well, probably because I couldn't think of how to work such a thing in my mind. That probably would've worked the same to be honest. I just went about the most complicated way. XD
@StrawberrySmiles gotta save them switches lol. Nothing wrong with script calls, its actually less complicated your way.

Original thread: https://forums.rpgmakerweb.com/threads/checking-actors-image.87884/