RPG Maker MV

RPG Maker MV

mydeza 12/abr./2017 às 11:28
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!
Última edição por mydeza; 12/abr./2017 às 11:29
< >
Exibindo comentários 13 de 3
Caethyril 12/abr./2017 às 11:42 
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. =)
Última edição por Caethyril; 12/abr./2017 às 11:43
mydeza 12/abr./2017 às 12:27 
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/abr./2017 às 12:44 
Escrito originalmente por 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
< >
Exibindo comentários 13 de 3
Por página: 1530 50