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,897
Reaction score
14,526
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 Posts

Latest Profile Posts

Worked over a week on a new BGM, and I'm finally happy with it.

Here are some screenshots of the area it will be used in
EzLHppdVIAMY7DP


EzLHpqsVIAEZ7jt
#WIP Metal Tactics's TBS (2015 vs 2021)
VSt9pWc.png
ZXnpNYY.png
RPG Maker News #14 | Diffused Screen Effects, Unsellable Items, Ambient Synths, Adult Woman Set
If kids are going to be taught on computers and have access to the Internet, some basic knowledge of copyright should be a part of the grade school curriculum.
I have some news that I want to share - I've been accepted to university ^-^
I received some offers just over a month ago, but I wanted to make my choice and get things in place before sharing the news.
I'm super excited, and I'm very happy with my choice of program and school.

Forum statistics

Threads
110,513
Messages
1,053,869
Members
143,604
Latest member
arby
Top