Windows i7

Veteran
Veteran
Joined
Nov 4, 2017
Messages
429
Reaction score
1,341
First Language
English
Primarily Uses
RMMV
I'm assuming that plugin code executes after all the base code does, and that you can thus override base functions.

As for this bit though... I read that this is a self-invoking function. Is this the entry point for plugins like main in C++?
(function() {})();

What exactly is this doing in the sticky template?
var parameters = PluginManager.parameters('template');
 

Poryg

Dark Lord of the Castle of Javascreeps
Veteran
Joined
Mar 23, 2017
Messages
4,125
Reaction score
10,660
First Language
Czech
Primarily Uses
RMMV
Not sure how C++ works, but a self invoking function is an entry point for plugins that need to be executed immediately and won't be executed repetitively.
And the parameters template is responsible for taking care of plugin parameters (you can see how it works in any yanfly plugins that have parameters you can set in the plugin manager).
 

Jonforum

Veteran
Veteran
Joined
Mar 28, 2016
Messages
1,634
Reaction score
1,452
First Language
French
Primarily Uses
RMMV
I'm not sure I understood the whole question but.
PHP:
// auto execute when read (no wait to be call)
(function() {
// do something
})();


// not executed when read, but storing, and wait for call
function name(){
// do something
};

name(); // now its execute
 

Kino

EIS Game Dev
Veteran
Joined
Nov 27, 2015
Messages
562
Reaction score
805
First Language
English
Primarily Uses
RMMV
(function() {})();

Creates a new scope for functions and code to be executed in JavaScript. So for example, you could use a self-invoking function to immediately execute code 1, and again create a sense of privacy with all your variables. That's because a function defines new scopes in JavaScript.

var parameters = PluginManager.parameters('template');
Allows you to access parameters defined in the pluginManager or the $plugins object in RPGMakerMV. "template" would be looking for the plugin named 'template'; if 'template' isn't found the parameters will be undefined.

http://endlessillusoft.com/functions-scoping-namespacing/ Talks about scoping and namespacing; take a look.

This might also help: http://endlessillusoft.com/rpgmaker-mv-es6-part-5-block-scope-variables/
 

Windows i7

Veteran
Veteran
Joined
Nov 4, 2017
Messages
429
Reaction score
1,341
First Language
English
Primarily Uses
RMMV
Thanks everyone. I just successfully made my first plugin. I cleaned up the template a bit to focus on the code itself (way too many comments for my liking). It successfully runs with MV 1.6.0 beta.
Code:
/*:
 * @plugindesc Test plugin
 * @author Windows i7
 */

 (function(){
     
    var _Scene_Title_MV = Scene_Title.prototype.drawGameTitle;
   
    Scene_Title.prototype.drawGameTitle = function(){
        _Scene_Title_MV.call(this);
        this._gameTitleSprite.bitmap.drawText("Test", 20, 90, Graphics.width - 20 * 2, 48, 'center');
    }   
    
 })();
 

Joy Diamond

Talkative
Veteran
Joined
Nov 12, 2017
Messages
135
Reaction score
174
First Language
English
Primarily Uses
RMMV
Thanks everyone. I just successfully made my first plugin.
Congratulations :cool:

I cleaned up the template a bit to focus on the code itself (way too many comments for my liking).
I completely 100% agree -- way too many comments make the code unreadable. I've been doing the same thing & removing comments.
 

WickedWolfy

Touch Fluffy Tail!
Veteran
Joined
Nov 27, 2017
Messages
115
Reaction score
50
First Language
En
Primarily Uses
RMMZ
Sorry I am late to the parade, but a note on C++ versus JavaScript.

C++ is a top-down execution (in most cases). While you can setup states with C++, it becomes a very different language.
JavaScript, in comparison, is a "state machine design" operation. As Kino mentioned - scopes are created and the code is executed "in scope".
An easy way to think about it is "event-based system", where you attach your JS code to an event.
Example: User clicked on "Items" menu item -> default function runs to display appropriate window.
You attach your code to the same event to display a message, or add/remove items.
Another example would be UI control: on UI ready and loaded -> create windows to display content.
 

Latest Threads

Latest Profile Posts

The dolls are complete Shizukuandyuki.pngyunaandyuka.png what do you guys think of them i worked really hard on them
TFW you finally defeat an obnoxious bug in your project. B)
Made a showcase, guide, and tutorial to using GENE Scene Builder with RPG Maker MV :kaoslp:

For a long time I always consider XP soundtracks as the best one.
Just listened to some of MZ tracks from the free version.
It's... Quite mindblowing. xD
Only listened to the battles, towns, and fields.
But I'm sure the rest are equally good. :D
What do you guys want to see for the new Jump into Javascript? A continuation of the rpg_objects, or would you prefer a "lesson 0" where I go back to the absolute basics of Javascript and cover the fundamentals of the language and its construction?

Forum statistics

Threads
112,458
Messages
1,068,416
Members
146,116
Latest member
kulebyaka
Top