Changing Actor sprites dependent on variable?

I haven't messed around with it much since I'm just getting into working on this new game of mine, but the most prominent system is a karma system a la Fable where the character's graphic will morph based on Karma (so a karma variable). 

Setting up the karma is easy. 

How would you go about changing the graphic though? 

I could make a common event that checks karma and switches sprites if applicable and then plug that into all my Map changes / major events but that seems...messy. Is there a more eloquent way to do this? I feel like there is and I'm just too damn tired to see it. 

Sorry if I mixed up my languages, I've been working in several different programs (Gamemaker, Python/Pygame, Stencyl) in the past few days and I may have mixed up some terminology! 
You'd need to provide more information on what you're trying to do.


Are all your graphics for the character in a single character sheet? Or are there several? How will the variable determine which one to use?


You can run

Code:
$game_actors[id].set_graphic(character_name, character_index, face_name, face_index)
in a Call Script event command, where id is the actor's id, and the parameters are pretty self-explanatory. Depending on how your images are set up, you should be able to use the variable to either form the character and face name, or as the index.
For an event-only option, use a common event set to parallel process. Obviously, a switch is needed to make it run, so don't forget to turn this switch on at the beginning of the time.


In this common event, have a bunch of conditional branches check the value of the variable. So if your 'karma' is at 50, or 100, or 500 etc. make a conditional branch for each stage you want to show, and be sure to pick the less than or equal to, and to put all other conditional branches in the 'else' branch of each other. Obviously, in each conditional branch, change the actor sprite accordingly.


This should make the actor sprite change when his 'karma' hits a certain value.
Is there a way to change the SPRITE only and leave the face intact with just the one script call? (need to use a script)

Or, it is more involved than that with saving the old values... ?
Is there a way to change the SPRITE only and leave the face intact with just the one script call? (need to use a script)
I'm not 100% this is what you are asking for.  But just in case:

You can change just the sprite graphic by using the options inside the Set Move Route/Change Graphic commands on page 2 under your event commands. 

There are probably other ways.  But that's how I do it when I just want to change the sprites but keep the face the same.  Your focus seems to be on script calls though so I am not sure if this is what you are looking for.  So if not just ignore me.
Yeah.. I need to do it in a script...
So if you want to change the sprite only but leave the face intact, do this:

Code:
$game_actors[id].set_graphic(character_name, character_index, $game_actors[id].face_name, $game_actors[id].face_index)
where you're passing it the new character (sprite) name and index, and telling it to use the face that's already assigned. Here, you'll need to replace id with the actual id of the actor (no leading zeros) three times.
Sweet. 

Is there a script call I can make to force an update to the actor graphic? I can refresh it in a messy way... but would like to have it refresh immediately, without any intervention.
That's it. I just gave it to you. Did you try it?


If it doesn't change straight away, try adding $game_player.refresh afterwards
try to call $game_player.refresh or $game_player.update or try refreshing the $game_map's spriteset
Actually, I just realized you aren't the OP. You should probably create your own thread next time, since your requirements aren't quite the same as the question originally asked.
Apologies. And thanks
oldbone don't necro-post nor hijack someone else's thread. Please create your own, thank you.


Closing this unless OP returns and wants it reopened.

Original thread: https://forums.rpgmakerweb.com/threads/changing-actor-sprites-dependent-on-variable.19653/