RPG Maker MV

RPG Maker MV

mydeza 12 Apr, 2017 @ 11:28am
Use random var to show image
OK, i am stuck!

I know how to show a specific image:'

$gameScreen.showPicture(1, 1, 0, 34, 6, 100, 100, 255, 0);

I know that the second number is the picture name (in this case 1.png)
I have a random variable before the event, but how can i use the variable to trigger any image that has same number as the vari +.png.

I have 1-10.png, and the variabale is 1-10, how can i capture the variable?

BTW, I know that it is possible to use nested if statements, but is it so messy!

Thanks for supporting!
Last edited by mydeza; 12 Apr, 2017 @ 11:29am
< >
Showing 1-3 of 3 comments
Caethyril 12 Apr, 2017 @ 11:42am 
Just double-checked to be sure, and you're right, the second parameter is the picture name.
function(pictureId, name, origin, x, y, scaleX, scaleY, opacity, blendMode)
Now, to your question. Try this, replacing X with the ID of your "random variable":
String($gameVariables.value(X)) + ".png"

Explanation:
  • To get the value of variable ID X:
    $gameVariables.value(X)
  • To concatenate (a.k.a. join) strings in Javascript, the + operator is used.
  • To make sure the compiler recognises the correct form of the operator, the String() method is invoked to convert the variable value to a string. =)
Last edited by Caethyril; 12 Apr, 2017 @ 11:43am
mydeza 12 Apr, 2017 @ 12:27pm 
Many thanks! Works perfectly! And so much easier than having 10 nested ifs... Surprise it is not documented anywhere, but perhaps it is too easy, and just me being a noob...
Caethyril 12 Apr, 2017 @ 12:44pm 
Originally posted by mydeza:
Many thanks! Works perfectly! And so much easier than having 10 nested ifs... Surprise it is not documented anywhere, but perhaps it is too easy, and just me being a noob...
To my knowledge there isn't any documentation on MV scripting...

What I do is just use the file search function to look for likely terms, in this case "picture" and "variable". Then see if I can puzzle out the JS...I'm learning, albeit slowly. xD
< >
Showing 1-3 of 3 comments
Per page: 1530 50