Bricabrac

The Storyteller
Veteran
Joined
May 24, 2016
Messages
113
Reaction score
218
First Language
Italian
Primarily Uses
RMMV
Just wondering if there's a quick way to change the value of a plugin parameter though an event. The magical script calls file has this entry about it:
var aliasPluginCommand = Game_Interpreter.prototype.pluginCommand;

Game_Interpreter.prototype.pluginCommand = function(command, args) {
aliasPluginCommand.call(this, command, args);
if (command === 'plugincommandtextname') {
dostuff(args);
}
};
Now, my knowledge of JS is pretty limited, but this looks like a method to retrieve a plugin's value and do something based on the result. Not what I was looking for.
Can someone help me?
 

Shugo

Low Life Hiomaika Enthusiast
Member
Joined
Feb 21, 2017
Messages
27
Reaction score
41
First Language
Portuguese
Primarily Uses
RMMV
/*
*@param passed value
*@desc just a value
*@default 0
*/
(function(){

var params = PluginManager.parameters('yourpluginnamehere');

// an object to keep our valeus
var savedValues = {};

// gets the value on the plugin manager from what is called 'passed value'
savedValues.value = String(params['passed value']).trim();

var aliasPluginCommand = Game_Interpreter.prototype.pluginCommand;

Game_Interpreter.prototype.pluginCommand = function(command, args) {

aliasPluginCommand.call(this, command, args);

if (command === 'plugincommandtextname') {

dostuff(args);

}

};

// you change this to a method later(or not), but for this example sake

function dostuff(receivedValue){

if(receivedValue != savedValues.value && receivedValue!=undefined){

// if the new value isn't the same as the old one and isn't undefined, change it to the new one.

savedValues.value = receivedValue;

}

}

}());

Now all that is needed is calling the command on an event and passing it's new value, but I don't remember if automatically turns the args into an array or not, or if it only turns if you're using spaces.

Ex: plugincommandtextname 0 1 2 3
^ the args would be [0,1,2,3]

Maybe this could help I guess? There probably is a better way to do this tho
 

DoubleX

Just a nameless weakling
Veteran
Joined
Jan 2, 2014
Messages
1,832
Reaction score
980
First Language
Chinese
Primarily Uses
N/A
I think it actually depends on the plugins themselves.
In short:
If the plugins have designed to let users change the parameter values in game, then they should have relevant instructions.
If the plugins aren't designed with that in mind, users will probably have a hard time trying to do that themselves.
Also, whether the changes need to be saved is also important, as they'll lead to totally different solutions :)
 

Latest Threads

Latest Posts

Latest Profile Posts

I THINK I have a slightly better grasp on drawing my maps now... sorta. I still need to figure out how to draw a city of sorts. I've only got the abstract going so far.
One day, I'll not have this lingering cough and we'll have another make a game stream.
A music I create while practicing E Major scale. :D
Too bad the Boss Battle Build Bout isn't also for VXAce.

Forum statistics

Threads
115,180
Messages
1,087,898
Members
149,746
Latest member
Nesutokung
Top