DangDut

Narratell Studios
Veteran
Joined
Jun 1, 2015
Messages
37
Reaction score
6
First Language
Indonesian
Primarily Uses
Hi,
 
How to run plugin command within a javascripts?
 
Sample:
Plugin command from YEP_ExternalLinks.js

OpenNewWindow http://www.google.com/Javascripts


Thanks.
 

Zalerinian

Jack of all Errors
Veteran
Joined
Dec 17, 2012
Messages
4,699
Reaction score
939
First Language
English
Primarily Uses
N/A
You need to alias the Game_Interpreter's pluginCommand function. It takes two arguments, command and args. Plugin commands are split into a list of words by spaces, so the 'command' argument is the first 'word' that was entered. In the case of what you're looking for, OpenNewWindow. args is an array of the rest of the 'words'. You'll have to check and/or combine them yourself. If you need to combine them, feel free to use args.join(" ") to put them back as a string, separated by spaces.

If you need more examples, take a text editor (please, don't use notepad) and open up any plugin that adds a plugin command. You'll be able to see how it's done from those.
 

kentaromiura

Veteran
Veteran
Joined
Nov 1, 2015
Messages
46
Reaction score
26
First Language
English
Primarily Uses
I think

Game_Interpreter.prototype.pluginCommand('OpenNewWindow', ['http://www.google.com'])should work

EDIT:

for full compatibility with other scripts I suggest though to use something like this:

var myInterpreter = new Game_Interpreter()
myInterpreter.pluginCommand('OpenNewWindow', ['http://www.google.com'])
 
Last edited by a moderator:

Zalerinian

Jack of all Errors
Veteran
Joined
Dec 17, 2012
Messages
4,699
Reaction score
939
First Language
English
Primarily Uses
N/A
I think

Game_Interpreter.prototype.pluginCommand('OpenNewWindow', ['http://www.google.com'])should work
I could be misinterpretting the question, but I believe they want to know how to replicate making a plugin command.

Anyway, this would not work. You can't call functions with 'prototype' in them without an object of that class. You could run it fine from a script command as this.pluginCommand('OpenNewWindow', ['http://www.google.com/]), however I don't think that's what the OP is asking for. I could, however, be wrong. It's happened before.
 

kentaromiura

Veteran
Veteran
Joined
Nov 1, 2015
Messages
46
Reaction score
26
First Language
English
Primarily Uses
I could be misinterpretting the question, but I believe they want to know how to replicate making a plugin command.
I think he asked how to run a plugin command from JavaScript.

Anyway, this would not work. You can't call functions with 'prototype' in them without an object of that class. 
Well, I tried and it worked.

If the function doesn't use this inside you can safely call it, in this particular case the original pluginCommand is just an empty function that does nothing, but of course, if any plugin that patch it uses `this` inside to call any Game_Interpreter methods it will not work. 

There are 4 instance of Game_Interpreter in the code of which are 2 always available in $gameTroop or $gameMap, but for the same reason as above, if anyone patches those you cannot rely on it, also those variables are not available before DataManager.createGameObjects, so the best way is, how you suggest, to create your own Game_Interpreter instance and call the method from there.

var myInterpreter = new Game_Interpreter()myInterpreter.pluginCommand('OpenNewWindow', ['http://www.google.com'])
You could run it fine from a script command as this.pluginCommand('OpenNewWindow', ['http://www.google.com/])
Not sure what you mean by script command, are you talking about the one in the event page?

EDIT:

Just checked and that's what you mean :)
 
Last edited by a moderator:

Shaz

Global Moderators
Global Mod
Joined
Mar 2, 2012
Messages
41,911
Reaction score
14,551
First Language
English
Primarily Uses
RMMV
I've moved this thread to JS Plugin Support. Please be sure to post your threads in the correct forum next time. Thank you.
 

Latest Threads

Latest Profile Posts

I almost thought it wouldn't happen, but a miracle has occurred, and IT'S HAPPENING!!!
xabileug wrote on thenerdmansion's profile.
TMCard - tomoaky
Hi i am currently working on a personal game using tomoaky TMCard in MV. i already have several modifications to it..

Screenshot-2021-04-18-at-19-32-48.png


Rest your weary legs in the Dancing Fox Inn!
Love to kick back and gamemak at the end of the day.
yay, i finally got around adding a profile pic! :guffaw:

Forum statistics

Threads
110,598
Messages
1,054,588
Members
143,731
Latest member
NateThe8
Top