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,698
Reaction score
937
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,698
Reaction score
937
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,143
Reaction score
14,205
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

AeroPergold wrote on LUKElcs's profile.
Its-a me, Pergold from Gamejolt!
I added footstep sounds to our content that I posted in a previous thread. I was unable to edit the post, so if you're interested, see below.

DOWNLOAD LINK

I've started working on rpg maker again, and I can see a lot of improvement from when I was 13. I still have a long way to go, but I'm proud that I've gotten this far.
Animated Title screen is by SharkerrBlue(SB)
I am using the Nightmare Land pack.
I just can't walk to the store for lunch without walking past people smoking. It not only smells bad, it's probably poisoning me. I'm afraid I'll eventually have to be hospitalized. I can't take another path because there's too much traffic and drivers in the plaza are reckless sometimes. I almost got run over once, even after looking both ways.
RyanYe wrote on whtdragon's profile.
Your art works about Wyrvens and Dragons are sooooooooo cooooooooool~! I like them so bad
Can you create more? like Archangels, Devils, Titans, Cyclops!!

Forum statistics

Threads
108,811
Messages
1,039,658
Members
141,258
Latest member
Faxion
Top