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,298
Reaction score
14,277
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

Anybody know how to make an enemy have a line of sight? I'm trying to make Persona-like enemies.
zomboars.jpg

Concept art

Zomboars- main enemies in my story
mutant pigs addicted to beer
SF_People1_3 added!
index.php

I haven't been on here in forever wow(missed my forum birthday T-T). Anyways, I'm dabbling in BGMs, here's something I'm actually willing to share.

Forum statistics

Threads
109,203
Messages
1,043,022
Members
141,713
Latest member
Quincy_
Top