Javascript plugin input to variable

KravenarGames

Veteran
Veteran
Joined
Feb 19, 2017
Messages
120
Reaction score
15
First Language
English
Primarily Uses
N/A
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.
 

standardplayer

Keeper of Kitties
Veteran
Joined
Apr 6, 2016
Messages
538
Reaction score
2,451
First Language
English
Primarily Uses
N/A
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";
?
 

KravenarGames

Veteran
Veteran
Joined
Feb 19, 2017
Messages
120
Reaction score
15
First Language
English
Primarily Uses
N/A
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
 

standardplayer

Keeper of Kitties
Veteran
Joined
Apr 6, 2016
Messages
538
Reaction score
2,451
First Language
English
Primarily Uses
N/A
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;
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

What can I sing for my sisters birthday...?

>.<'
Well, I'll have you know that I'm still around, looking for opportunity to resurface with some stuffs.
I like to think of Profile Posts as tiny homes, full of all kinds of unsuspecting suckers "future" friends.... Many of which are of course only going to be excited when a strange man in black suddenly shows up to say hi. :LZSexcite:
Stream will be live shortly with some more Haunting Ground! Today, we encounter a new stalker! Feel free to drop by!
Tried the new Samsung Galaxy S20 Plus today. Very nice device overall, but flagship smartphone prices are getting completely out of control.

Forum statistics

Threads
94,499
Messages
921,451
Members
124,357
Latest member
ianhendrawan
Top