Template for MV plugins - a possible recommendation

@Shaz

Not having seen how these plug-ins work, I'm operating in the dark.  But do they mean that an end user never has to go in and do any configuring?

I'm thinking of such existing scripts as

Quest Journals, where each quest has to be carefully defined in terms of objectives etc.  

Lighting scripts which each 'light' has to be defined

More tricky ones like Iavra's Animate Everything script where the user has to define any additional classes.
not really! 

this not because they create the plugin manager they meant people don't have to do coding! 

some script may are core where sometime you need to go edit inside the script due the fact it's impossible to do via notetag or the plugin command 

likes my AI where you need to edit it via the JS files : 

Var AI_Personality = AI_Personality || {};AI_Personality[1] {//stuff};AI_Personality[2] {//again_stuff};so it's pretty much depends of the programmer!
not really! 

this not because they create the plugin manager they meant people don't have to do coding! 

some script may are core where sometime you need to go edit inside the script due the fact it's impossible to do via notetag or the plugin command 

likes my AI where you need to edit it via the JS files : 

Var AI_Personality = AI_Personality || {};AI_Personality[1] {//stuff};AI_Personality[2] {//again_stuff};so it's pretty much depends of the programmer!

This particular piece of code could be written better, you could have one core AI class and then extend each particular AI class off the parent allowing you to preset a set of rules for all AI.

What you have written gets messy real quick.

A good example is something as I have demonstrated else where:

var AIClass = { functionName: function(){ ... }, // All core logic for all AI's go here.}// As a programmer or even non programmer I need to set a series of rules ok:var MyAiClass = _.extend(AIClass, { // My Stuff here.});Its a lot cleaner and keeps the concept of scope.
I actually support the idea of using
 

/** * Multiplies two numbers * @param x Description of x * @param y Description of y * @return the multiplication between x and y */function mul(x, y) {   return x * y;};This type of parameters, but for a good reason:

This is the format than programs like doxygen and other manual generators works.

This is good, because you can pass your folder of plugins to programs like that and creates a good html manual for you ready to use.

This may be "harder" to read to some non scripters, but having html documentation is a blessing sometimes.
I actually support the idea of using

/** * Multiplies two numbers * @param x Description of x * @param y Description of y * @return the multiplication between x and y */function mul(x, y) {   return x * y;};This type of parameters, but for a good reason:

This is the format than programs like doxygen and other manual generators works.

This is good, because you can pass your folder of plugins to programs like that and creates a good html manual for you ready to use.

This may be "harder" to read to some non scripters, but having html documentation is a blessing sometimes.

For readability I would put a line break between the description and the params.... hahaha - I do code review all day >.>
this not because they create the plugin manager they meant people don't have to do coding! 

some script may are core where sometime you need to go edit inside the script due the fact it's impossible to do via notetag or the plugin command 

likes my AI where you need to edit it via the JS files : 

Var AI_Personality = AI_Personality || {};AI_Personality[1] {//stuff};AI_Personality[2] {//again_stuff};so it's pretty much depends of the programmer!
I don't think that should be in the code itself.

If someone really liked your script and wanted to write a nice, user-interface that will allow users to create AI's without having to write any javascript code, do you want to force them to modify your javascript file?

Input should really be separate from the script.
I actually support the idea of using

/** * Multiplies two numbers * @param x Description of x * @param y Description of y * @return the multiplication between x and y */function mul(x, y) {   return x * y;};This type of parameters, but for a good reason:This is the format than programs like doxygen and other manual generators works.

This is good, because you can pass your folder of plugins to programs like that and creates a good html manual for you ready to use.

This may be "harder" to read to some non scripters, but having html documentation is a blessing sometimes.
This is how Java comments work and i support this way of commenting, too. However, i also add separators like

// ====================================================================================================// attributes// ====================================================================================================Between certain sections (attributes, constructors, methods, accessors) and will do similar for my scripts./edit: This is actually known as JSDoc and works similar to Javadoc: https://en.wikipedia.org/wiki/JSDoc
This is how Java comments work and i support this way of commenting, too. However, i also add separators like

// ====================================================================================================// attributes// ====================================================================================================Between certain sections (attributes, constructors, methods, accessors) and will do similar for my scripts./edit: This is actually known as JSDoc and works similar to Javadoc: https://en.wikipedia.org/wiki/JSDoc

This is not JS Doc. And Java doc is not done like this. Its done like this https://en.wikipedia.org/wiki/Javadoc

The doc method you support is not professional, its what script kiddies use.

Ruby doc is even done: https://en.wikipedia.org/wiki/Ruby_Document_format which some people followed and others did not ....

Lets use proper documentation standards instead of "hacker doc" 
My edit was targeted at Ramiro's comment. My addition is to make the code more readable by dividing it into segments. These comments aren't recognized by a doc parser and thus won't hurt.
My edit was targeted at Ramiro's comment. My addition is to make the code more readable by dividing it into segments. These comments aren't recognized by a doc parser and thus won't hurt.

they make the code unreadable and should not be apart of the system. If you want to break your code into "sections" learn how to write ES6 code that is then compiled by babel to be concatenated. a good example is the following:

/** * Description * * Longer Description */var ClassName = { /** * Description */ functionName: function(){...}, /** * Description * * @param param ... */ anotherFunction: function(param){ ...}};// Export the modulemodule.exports = ClassName//Else where:var ClassName = require('./class_name.js');// Do stuff ... The above is ONE way to write modular code. Tools like Gulp, Mincer, Babel will compile this down into something thats concatenated. Proper modular development in javascript is not to use one large file, thats your end result (which should also be minified) it is a series of seperate components weather they are written my way or any other way that are properly documented and compiled for distribution.

And for a little fun:

[IMG]http://blogs.perl.org/users/kirk_kimmel/Research-Meme-Blog-Content.png[/IMG]
I don't think that should be in the code itself.

If someone really liked your script and wanted to write a nice, user-interface that will allow users to create AI's without having to write any javascript code, do you want to force them to modify your javascript file?

Input should really be separate from the script.
the sad thing's is WHO who will write that? I am not a software programmer so write interface is a Big no I do thinked to use Simple JSON files but still I had conversation about it with Galenmereth I do also thinked to use Text files  who can simplify the process but after they have also a LIMIT of what I can allow too

however the process of text files was the most interesting for friendly user without having to touch the JS file EVEN it's a PROGRAMMER tools it's not intended to be used alone or for normal user who didn't know how to program.

I do thinked to program the system to take the system recognize a text files depending the ID 

and it's load a files likes this ("AI + the currentid" ) and example and say example I didn't think about the layout yet in the text files you could have : 

Greeting : "text"

Byebye  :  "other text" 

but I also think seriously? I know it's have to be usefriendly but they have limits if the guys is unable to bother to open a JS files where's everything's is explained how to modify or to add stuffs and only rely on the plugin Manager it's will be a little lazy and lacks of motivations 
Json is the preferred way to go its how most applications that have plugins written in javascript deal with configuration options. even if its not valid json you can still make objects for configuration.
yes I will have sadly to learn the structure of JSON structure I will ask to Galenmereth how it's works because he is the one who know the thing's who will suit better my AI_Core
yes I will have sadly to learn the structure of JSON structure I will ask to Galenmereth how it's works because he is the one who know the thing's who will suit better my AI_Core

Here is an example of what I would do in your case:

Code:
AIController: {  AIOptions: [{ OptionOne: "Value"}]}// This way you have an AI Controller that can have multiple Option objects thus each AI // obect can have its own Object of options.// This also allows you to implement immutability so that no aspect of your "Script" can // alter, directly, the AI Controller Option.
I see this not a bad idea! 

Game_AI.prototype.interaction = function(interaction_type) { switch (interaction_type) { case 'normal' : this.dialogue_system.add("text"); this.change_expression(1); break; }};Game_AI.prototype.curtain_interactions = function(curtain_type) { switch(curtain_type){ case "entering" : this.entering_interaction(); break; case "quitting" : this.quitting_interaction(); }};Game_AI.prototype.entering_interaction = function() { this.call_effect("inhori_slide",2,100); this.change_expression(1); this.dialogue_system.add(this.greeting);};Game_AI.prototype.quitting_interaction = function() { this.change_expression(2); this.dialogue_system.add(this.byebye); this.call_effect("outhori_slide",2,100);};but the problem I got explained from JSON is the fact it's can slow the process

and people will need to edit this part for add more "option" to the AI

or simply edit how the AI will react ect 

I know the thing's of prototype it's not please you but I just follow how MV works 

also the thing's I don't want my code

"Immutability" 

Since it's a base who people can freely edit as their need 
I see this not a bad idea! 

Game_AI.prototype.interaction = function(interaction_type) { switch (interaction_type) { case 'normal' : this.dialogue_system.add("text"); this.change_expression(1); break; }};Game_AI.prototype.curtain_interactions = function(curtain_type) { switch(curtain_type){ case "entering" : this.entering_interaction(); break; case "quitting" : this.quitting_interaction(); }};Game_AI.prototype.entering_interaction = function() { this.call_effect("inhori_slide",2,100); this.change_expression(1); this.dialogue_system.add(this.greeting);};Game_AI.prototype.quitting_interaction = function() { this.change_expression(2); this.dialogue_system.add(this.byebye); this.call_effect("outhori_slide",2,100);};but the problem I got explained from JSON is the fact it's can slow the process

and people will need to edit this part for add more "option" to the AI

or simply edit how the AI will react ect 

I know the thing's of prototype it's not please you but I just follow how MV works 

also the thing's I don't want my code

"Immutability" 

Since it's a base who people can freely edit as their need 

First: http://www.sitepoint.com/immutability-javascript/

Do your research.

Second: The json I provided is more of an object of configuration then it is valid json.

Again: 

Do you research.

You are free to stick with what ever convention you feel gets the job done but your code is unreadable and mess. You are essentially creating functions on an object thats global. My approach allows the configuration to be in one place and then for you to use the concept of immutability which states that out side logic should not directly change the variables and configuration set by internal object. That is if I give you options to configure your script you should not directly change configuration options. Other scripts should also not directly change the configuration options.

Please do some reading on these subjects, your skills as js programmer will vastly improve. You can still use the concept of immutability with prototypes.
if you want to separate areas in doxygen you could use groups to (just for the sake of it)

/** * @group Thing's attributes *//** @{ */ /* Put your content here *//** @} */ /* End of thing's attributes */Javadoc and doxygen are not really too different now, if you are working with java you should follow javadoc, because it's the most people agree with, and it's official.

ECMA still don't include anything to documment oficially, but Doxygen is an old one (and used widely) and most docummentation tools are more or less the same.

you can mix of course the style of 

//====================================================// **Section//====================================================or use both:

//====================================================/** @group Thing's attributes *///====================================================/** @{ *//* Put your content here *//** @} */ /* End of thing's attributes */I won't view it badly while if I can check an html document with that info, because usually I don't review other scripter's code, but just the API parts...
That looks really bad I suggest staying the way the community as a whole suggests doing docs
Hi there,

as i have seen in a plugin the comments should look like this:

//=============================================================================// Plugin Configuration Section// !!!This is used by RPG-Maker MV and MUST stay intact!!!//=============================================================================/*: * @plugindesc A simple Plugin-Template * @author Churanos * * @param Enable Console * @desc Enables a console window on startup * @default true *///=============================================================================Note the block comment, this is the way RMMV finds the options for the given plugin.

This example is shortend, a bigger example can be found in Yanfly's plugin.

I think all other comments are up to the developer and should strip of in production.

I think that the Module Pattern for plugins is best suited. I use mostly Typescript to avoid mistakes and to write clean code.

There are some supersets to JavaScript, I think you can speak so most developers.

A simple example in TypeScript:

module CPM { export class Console { static Params = PluginManager.parameters('Plugin-Template'); static EnableConsole = Boolean(Console.Params['Enable Console']); static openConsole(): void { if (Console.EnableConsole || isDebugEnabled()) { if (Utils.isNWjs()) { var _debugWindow = require('nw.gui').Window.get().showDevTools(); } } } } export function isDebugEnabled(): boolean { return location.search.slice(1).split("&").indexOf("debug") >= 0; } Console.openConsole();}in JavaScript it looks like this: 

var CPM;(function (CPM) { var Console = (function () { function Console() { } Console.openConsole = function () { if (Console.EnableConsole || isDebugEnabled()) { if (Utils.isNWjs()) { var _debugWindow = require('nw.gui').Window.get().showDevTools(); } } }; Console.Params = PluginManager.parameters('Plugin-Template'); Console.EnableConsole = Boolean(Console.Params['Enable Console']); return Console; })(); CPM.Console = Console; function isDebugEnabled() { return location.search.slice(1).split("&").indexOf("debug") >= 0; } CPM.isDebugEnabled = isDebugEnabled; Console.openConsole();})(CPM || (CPM = {}));The result is works the same way like using the prototype or using static functions.

I dont like using the prototype, too. This way i can use my favorite coding tools and the result is just the same.

GZ Churanos.

Original thread: https://forums.rpgmakerweb.com/threads/template-for-mv-plugins-a-possible-recommendation.45521/