Choosing a sprite from variables

I have a slight problem that I'm struggling to resolve.

Say that in-game, I want to be able to take an event and make it have the correct image for one of a deck of cards. So if we had the 52 cards in a deck, I want the player to be able to choose a number (between 1 and 52) and have the event change to the sprite for that card.

What is the best way to accomplish this?

Ive thought of a few possible approaches, but I've ran into problems with each. The two main issues I'm having are...

1) It isn't possible for me to put 52 card images on one sprite sheet (as far as I'm aware?)
2) The "change image" option in the event editor only allows us to select a specific image, rather than the ability to specify the image by variable. I could have 52 "if" branches, but that doesn't seem particularly elegant.

Can anyone point me to a better way to do this?
It is possible to put 52 card images into one spritesheet, you'll just treat the steps like different sprites. No plugins needed, MV does it by default.
So instead of left leg step - standing - right leg step - you'll have ace of clubs, 2 of clubs, 3 of clubs. Just be prepared that you always have to select the concrete sprite when you select it.
The rest is just basic variable operation.
It is possible to put 52 card images into one spritesheet, you'll just treat the steps like different sprites. No plugins needed, MV does it by default.
So instead of left leg step - standing - right leg step - you'll have ace of clubs, 2 of clubs, 3 of clubs. Just be prepared that you always have to select the concrete sprite when you select it.

I assume, in this case, every sprite has to be the size of a 1x1 tile? That might be a problem, as I need them to be larger.

The rest is just basic variable operation.

Yes, but there's an issue - it's not so much the use of variables; it's mapping the variables to the outcome.

So to take an example, say 42 is "the 5 of Hearts". Is it possible to write a statement which can take that number and find the appropriate card? Or would I have to make a script page with 52 if statements ("Is it 1? Do this. Is it 2? Do this" and so on).

Like in a general coding sense, you would probably do this with a function, something like:

GetCardSprite(number) which returns a reference to the sprite in question.
The simplest, although most tedious thing to do, would be to just set each event page to condition variable X >= X.
For example:
card on the left:
page 1: variable 1, value 1, ace of hearts.
Page 2: variable 1, value 2, 2 of hearts.
Page 14: variable 1, value 14, ace of spades.

Middle card:
page 1: variable 3, value 1. ace of hearts.
page 2: variable 3, value 2. 2 of hearts.
And so on.

In other words each event has 52 pages, has its own variable, and the sprite will depend on the variable number.

The disadvantage of that is, you can only have 20 pages per event, although I have made a plugin that goes around this issue, it's an event spawner plugin.

And you can streamline a deck of cards into variables. You have values 0-51. Your number / 13 is equal to color: 0 is hearts, 1 is clubs, etc. Your number % 13 is card value. 0 is ace, 1 is 2, etc. A simple, yet effective system. Building a function upon that is not too hard.

Nevertheless, if the problem is that sprites would be too large, you can always use the change image option.
Instead open a decent text editor, open rpg_objects.js and search for Change image. There you'll have the code of the function. Then you just call it with proper parametring (for example implement "card" + $gameVariables.value(1) for the picture's name.
I assume, in this case, every sprite has to be the size of a 1x1 tile? That might be a problem, as I need them to be larger.
The sprites can be any size you want as long as the frames are a consistent size and the sheet is formatted correctly (one characters worth of frames prefaced by a $ or a full eight characters worth of frames). The only barrier is performance and I don't think that would be a worry when it comes to a mini game.

Original thread: https://forums.rpgmakerweb.com/threads/choosing-a-sprite-from-variables.102521/