The principal idea is to do with through command plugin:
ASSIGN_VAR trying
And on the code I got this:
var parameters = PluginManager.parameters('VAR_PLUGIN');
var _Game_Interpreter_pluginCommand = Game_Interpreter.prototype.pluginCommand;
Game_Interpreter.prototype.pluginCommand = function(command, args) {
_Game_Interpreter_pluginCommand.call(this, command, args);
if(command == "ASSIGN_VAR") {
var1 = VAR_PLUGIN;
}
What's wrong with this code? I need that the string 'trying' will be assigned to var1.
It has to be in quotes.
ASSIGN_VAR trying isn't doing anything, I'm not sure what you're trying to do with that line.
Are you trying to store the string "trying" in a variable called ASSIGN_VAR?
But yeah,
var1 = trying;
creates a variable called var1, and attempts to assign it the value of a variable called trying.
do you mean to do
var1 = "trying";
?
I mean that the plugin command will be:
ASSIGN_VAR string-to-be-assigned-to-the-variable
and the "string-to-be-assigned-to-the-variable" will be assigned to var1
it will do the same thing as doing
var1 = "string-to-be-assigned-to-the-variable";
but the string word will be customly inserted via plugin command
I haven't messed with plugin commands in my plugins in a while, I prefer script calls.
But if you're looking for what was passed with the command, I think it's in the args argument.
However, if you're accepting a string longer than one word after the plugin command, you'll need a function to reassemble it, because the plugin manager will take the first word of the plugin command as the 'command', and everything else as 'parameters', which it will split into an array on empty spaces.
So if my command was like
Assign_Var I am a very cool guy
then command would be
Assign_Var
and args would be
["I", "am", "a", "very", "cool", "guy"].
So the string values are in the args argument, when you're writing the function.
If you need to use more than one word (like pass a sentence as the parameters)
You could do something like
let sentence =
args.reduce(
function(prev, curr, i){
return prev + curr + ' '
}, '')
.slice(0, -1);
var1 = sentence;