Conditional branch that checks actor's images?

yumo_nikki

Villager
Member
Joined
Mar 9, 2018
Messages
7
Reaction score
1
First Language
Spanish
Primarily Uses
RMMV
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
 

TWings

The Dragon Whisperer
Veteran
Joined
Jul 26, 2017
Messages
527
Reaction score
860
First Language
French
Primarily Uses
RMMV
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
 

yumo_nikki

Villager
Member
Joined
Mar 9, 2018
Messages
7
Reaction score
1
First Language
Spanish
Primarily Uses
RMMV
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! ^^;;;;;;;
 

TWings

The Dragon Whisperer
Veteran
Joined
Jul 26, 2017
Messages
527
Reaction score
860
First Language
French
Primarily Uses
RMMV
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.
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,098
Reaction score
13,704
First Language
English
Primarily Uses
RMMV
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.
 

yumo_nikki

Villager
Member
Joined
Mar 9, 2018
Messages
7
Reaction score
1
First Language
Spanish
Primarily Uses
RMMV
It's working perfectly, thank you! :kaojoy:

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
 
Last edited:

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
31,365
Reaction score
7,676
First Language
German
Primarily Uses
RMMV
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.
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

so hopefully tomorrow i get to go home from the hospital i've been here for 5 days already and it's driving me mad. I miss my family like crazy but at least I get to use my own toiletries and my own clothes. My mom is coming to visit soon i can't wait to see her cause i miss her the most. :kaojoy:
Couple hours of work. Might use in my game as a secret find or something. Not sure. Fancy though no? :D
Holy stink, where have I been? Well, I started my temporary job this week. So less time to spend on game design... :(
Cartoonier cloud cover that better fits the art style, as well as (slightly) improved blending/fading... fading clouds when there are larger patterns is still somewhat abrupt for some reason.
Do you Find Tilesetting or Looking for Tilesets/Plugins more fun? Personally I like making my tileset for my Game (Cretaceous Park TM) xD

Forum statistics

Threads
105,868
Messages
1,017,078
Members
137,580
Latest member
Snavi
Top