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,912
Reaction score
14,554
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

Progress on one of my projects has been slow, but I'm at a spot now where I feel like sharing the four main characters.

From left to right we have: Amabel, Tibby, Dusty, and Wren.

tibbyrpgcast.jpg
I'm in a much better mood about my game than I was 2-3 days ago. I keep switching between sideview and front because of the amount of assets needed for side (I'm drawing it all myself)... but I've decided to stick with front, for my own sanity. sidenote... people, planning is important. I've spent so long on just getting my game's ideas off the ground because I didn't plan ahead.
unknown.png

"Fight me."
I'll finally wash my clothes today!
SA46ATTACK.gif :kaojoy:New Arab character in action.

Forum statistics

Threads
110,608
Messages
1,054,678
Members
143,736
Latest member
EmBee
Top