[SOLVED] Show a picture based on a variable

I use a variable to show pictures.
Currently its this:
imagevariable.png

basically:
if variable=1 -> show "map1"
if variable=2 -> show "map2"
... and so on

but when you have ~100 different pictures, this event code would be horrible.
How can I change this to a single command that basically says
show "map(variable)"

I'm not really into java script, I can often deduce what a script does when I read it, but I don't know how to write this line of script correctly^^
(or maybe there is another way that I didn't even thought of yet)
Code:
Script: $gameScreen.showPicture(8, 'Map%1'.format(this._mapId), origin, x, y, 100, 100, 255, 0)

replacing x and y with the position, and origin with 0 for upper left, or 1 for center.
Thank you, this is working fine 🙂
Just for better understanding:

- the "%" in the name is the marker for a variable number?
- and the ".format(this.[])" is the definition for this?
- the "%" in the name is the marker for a variable number?
no, the %1 (including the 1>) is the placeholder for the number resulting from the format method
'Map%1'.format(this._mapId)

So to use a different number, you would have to replace the this._mapID (which would always give the number of the current map)
thanks for the explanation 🙂
%1 is simply a placeholder that says whatever is the first argument in brackets will go in this spot.

'Map%1'.format(this._mapId)

will replace %1 with the current map ID (from the Game_Interpreter class, which is this), so for map 3 it'll be Map3, for map 18 it'll be Map18.

If you had multiple versions of each map (let's say you have a coloured version and a greyscale version), but it's the same map id and you just change tilesets at some point in the game, you could use a variable to say which version to show - say variable 15 = 1 means coloured version, and variable 15 = 2 means greyscale version, and you wanted the picture to also be the coloured or greyscale version, you could do this:

'Map%1-%2'.format(this._mapId, $gameVariables.value(15))

then it'll change it to Map3-1 or Map3-2 depending on what's in the variable.

Thread closed

Original thread: https://forums.rpgmakerweb.com/threads/solved-show-a-picture-based-on-a-variable.156530/