Nooblet Ques re:Variables

This is probably a really stupid question but I'm gonna ask it anyway because I cannot get this to work.


So here we go . . .


I have a picture gallery (using the Mog Picture Gallery plugin) and I'm trying to set up chests that give the players posters. These "posters" are stored in the picture gallery rather than in the inventory, so really what the chests are doing are enabling pictures in the gallery rather than giving actual items.


However, to make things interesting, I want the chests to enable random pictures (instead of each chest opening a specific image each time).


I coded this in Ace no problems using the following:


Control Variables: [0014😛oster] = Random No. (2...318)


Script: enable_picture($game_variables[14])


Text: -,-, Normal, Bottom


: You got poster number \v[14]


Now, however, I cannot get MV to recognize the random variable number as the image to unlock when I do it as a Plugin Command. If I specifically tell it what number to unlock it's fine. For example if I type enable_picture : 1 it will happily unlock picture 1. But if I try to get it to use the variable number it doesn't enable anything.


I have also tried doing it as a script command but then it tries to apply it to another plugin and gets all confused.


I'm guessing I'm typing the variable code incorrectly in the Plugin Command line but I cannot figure out the correct way to type it. I'm hoping this is a super easy fix and someone here can help me out with how to format that command or can point me to another post that has the information.


Thanks so much, and sorry for what I am betting is a very basic question. I just switched to MV and I'm still trying to figure out the code differences.
Please post a screenshot of how exactly you wrote that plugin command (javascript and plugin syntax are different from Ace syntax), and a link to the plugin so that we can check the command for its syntax and options.


I've moved this thread to Plugin Support. Please be sure to post your threads in the correct forum next time. Thank you.
Sorry about posting in the wrong spot, thanks for moving it.


Here's what the working chest looks like in VX Ace


ace.png


Here's a working chest in MV, but notice that I have specifically told the program which image to open (it's not a random number using a variable)


workingmv.png


What I want is for it to chose a random number between 2 and 318 and enable that picture. Unfortunately I'm not sure how to make the plugin command recognize the random number the variable has spit out. I've got the variable set up like this in MV and I've been trying to use the $gameVariables.value(0001) or $gameVariables.value(1) but it doesn't enable any pictures.


variablemv.pngnotworkingmv.png


The plugin I'm using can be found at https://atelierrgss.wordpress.com/rmv-picture-gallery/


Thanks!
Try $gameVariables.value(1) instead of $gameVariables.value(0001) and see if it works.


If it does, it's because you put the leading zeros (which you should never put with scripts, which is what you're passing through to the plugin).  If it doesn't, it's because the plugin is expecting a number, not a script command that needs to be evaluated.


Edit: just saw that you'd already tried (1) and it didn't work.  I suspected that would be the case.  I'm not into doing big downloads of projects just to look at a single script.  So if you feel comfortable searching through the plugin and making a change, I'll tell you what to look for and what to do with it; if you don't feel comfortable doing that then I'll ask you to find the Game_Interpreter.prototype.pluginCommand function and post all of that function here, and I'll tell you what to change.


What you're looking for is the function called Game_Interpreter.prototype.pluginCommand.  Within that, there will be a condition that checks for the command being enable_picture.  And after that, there'll be a reference to args[0] or Number(args[0]).  What you need to do is change args[0] to eval(args[0]).
never use leading zeroes with IDs - that very often breaks script commands.


It's value(1), NOT value(0001)


However, it might be that the plugin can't reference anything other than direct numbers - if the above change doesn't work, you'll have to ask someone to make a plugin modification for that.
can you post a link to Mog's plugin so that we can check if there's something wrong with the way you called the command?

However, to make things interesting, I want the chests to enable random pictures (instead of each chest opening a specific image each time).

Just wanna say that as a player I find that kind of thing bad... I mean ur basically making the chances of me getting all posters too  based on luck, if I'm unlucky all chests might even unlock the same poster for me every time...
There's already a link, but it's to a demo/project download, not the plugin itself.
Oh didn't see that. I cant download it here and open though, at work. XD
I gave a solution a few posts ago.  The plugin just isn't set up to take commands as parameters, and needs an 'eval' thrown in there.
Try $gameVariables.value(1) instead of $gameVariables.value(0001) and see if it works.


If it does, it's because you put the leading zeros (which you should never put with scripts, which is what you're passing through to the plugin).  If it doesn't, it's because the plugin is expecting a number, not a script command that needs to be evaluated.


Edit: just saw that you'd already tried (1) and it didn't work.  I suspected that would be the case.  I'm not into doing big downloads of projects just to look at a single script.  So if you feel comfortable searching through the plugin and making a change, I'll tell you what to look for and what to do with it; if you don't feel comfortable doing that then I'll ask you to find the Game_Interpreter.prototype.pluginCommand function and post all of that function here, and I'll tell you what to change.


What you're looking for is the function called Game_Interpreter.prototype.pluginCommand.  Within that, there will be a condition that checks for the command being enable_picture.  And after that, there'll be a reference to args[0] or Number(args[0]).  What you need to do is change args[0] to eval(args[0]).



Fantastic, thanks for the help. I'll dig through the plugin and see what I can do.


Edit: I went in and made the args change as you suggested and everything works perfect now. Thank you very much!

Original thread: https://forums.rpgmakerweb.com/threads/nooblet-ques-re-variables.72883/