How important is IIFE in RMMV?

Trihan

Speedy Scripter
Veteran
Joined
Apr 12, 2012
Messages
2,602
Reaction score
1,933
First Language
English
Primarily Uses
RMMV
Yeah, I didn't mean it in a regulatory kind of way, more like what the W3 Consortium does for web design. "This is the recommended way to do this stuff, but ultimately it's up to you."
 

Solar_Flare

Veteran
Veteran
Joined
Jun 6, 2020
Messages
526
Reaction score
230
First Language
English
Primarily Uses
RMMV
@Trihan maybe you would be better to start updating the thread and add "How to expose your variable to global window" because your example in your thread suit best for my example as of "you can not patch someone's plugin without directly edit the file" :p

Because with IIFE is on the way, I could not make an overwrite patch that does an edit like from this
Code:
    Scene_Map.prototype.createAllWindows = function() {
        _Scene_Map_createAllWindows.call(this);
        this.createMinimapWindow();
    };
to this (a separate file plugin that must be placed directly below the plugin)
Code:
    Scene_Map.prototype.createAllWindows = function() {
        _Scene_Map_createAllWindows.call(this);
        do_something_in_between()
        this.createMinimapWindow();
    };
Because _Scene_Map_createAllWindows is private in IIFE.
There was never been a problem like this in RGSS.

Because many people would refer to your tutorial when it comes to plugin making. And not sure if they would bother to read the comments.
You literally just did exactly what you said you can't do - you wrote an overwrite function that does something before creating the minimap window. Sure, it might be ugly to copy-paste the whole function and add your extra line, but if it's just a patch to fix a bug or something, who cares?

An actual plugin (add-on or whatever) however shouldn't be relying on some other plugin's aliased methods.
 

Tsukihime

Veteran
Veteran
Joined
Jun 30, 2012
Messages
8,556
Reaction score
3,811
First Language
English
I dunno, actually. Would people adhere to its guidelines, or even knew it existed for that matter? It'd depend largely on how much of a reach it was able to have.
Ya it's mostly about reach.

If you create 100 plugins and literally everyone uses them, and compatibility was terrible with other people's plugins, you still own the market share and everyone else needs to figure out how to work with your stuff lol

The first thing people ask is "is this compatible with Yanfly Engine" and I'm always like "I don't know, there are dozens of plugins which one are you talking about"
 

Hudell

Dog Lord
Veteran
Joined
Oct 2, 2014
Messages
3,510
Reaction score
3,650
First Language
Java's Crypt
Primarily Uses
RMMZ
Since rpg maker doesn't use import syntax, I think it's important to use IIFE to avoid filling the global context with your stuff. Anything that should be "modifiable" by other plugins should then be exported from the IIFE.
 

Eliaquim

Hakuen Studio
Veteran
Joined
May 22, 2018
Messages
1,560
Reaction score
904
First Language
Portuguese - Br
Primarily Uses
RMMV
I personally don't like the use of IIFE. I like to type(or let the autofill feature type for me) Namespace.pluginNameSpace.functionName(or variable). It feels more readable for me and it looks nice to my eye xD.

Also, with a namespace for the author, and another namespace for the plugin, it almost impossible to have a clash in the global scope( in the context of plugins for Rpg Maker MV).

There are other things that are more important to make a plugin compatible with others than using IIFE or not. In my last commissions, I have to make a thing compatible with two plugins from different authors. One of them use IIFE and it was an easy thing to do. The others don't, and it was hard because of the way the plugin has coded.

So I guess it's up to the coder on what it will take for use to make his own plugins.
Yeah, I didn't mean it in a regulatory kind of way, more like what the W3 Consortium does for web design. "This is the recommended way to do this stuff, but ultimately it's up to you."
I think that is a nice idea. As long as it does not take sides to choose, like:
"This coder follows the guide, this coder is nice and welcome"
"That coder don't follow the guide, so let's say that this kind of coder is not nice for the community"

Because, although, we coders will understand that it is not a big deal(I mean it will make no difference if this plugin is good or not), the users who don't know how to code can take it differently and somehow avoid using the plugins from this author.

So it's a good idea, but I also don't see that the community must have it.
 

Tsukihime

Veteran
Veteran
Joined
Jun 30, 2012
Messages
8,556
Reaction score
3,811
First Language
English
I personally don't like the use of IIFE. I like to type(or let the autofill feature type for me) Namespace.pluginNameSpace.functionName(or variable). It feels more readable for me and it looks nice to my eye xD.

Also, with a namespace for the author, and another namespace for the plugin, it almost impossible to have a clash in the global scope( in the context of plugins for Rpg Maker MV).
The clash that usually is problematic is when two methods decide they need to overwrite the same method.

One plugin wants to return 1, another plugin wants to return 2.
I don't think there's really a way to get around this, especially if it's a common object.

For example think of battle systems: some want to have have turn-based, some wants to have real-time.
You might be able to get away with

Code:
if (mode == "turn based")
   // turn-based update
else if (mode == "real-time") {
  // real-time update
}
But sometimes this isn't possible. It needs to be designed from the ground-up to improve flexibility.
 

Eliaquim

Hakuen Studio
Veteran
Joined
May 22, 2018
Messages
1,560
Reaction score
904
First Language
Portuguese - Br
Primarily Uses
RMMV
The clash that usually is problematic is when two methods decide they need to overwrite the same method.

One plugin wants to return 1, another plugin wants to return 2.
I don't think there's really a way to get around this, especially if it's a common object.

For example think of battle systems: some want to have have turn-based, some wants to have real-time.
You might be able to get away with

Code:
if (mode == "turn based")
   // turn-based update
else if (mode == "real-time") {
  // real-time update
}
But sometimes this isn't possible. It needs to be designed from the ground-up to improve flexibility.
Oh yes, that's right. Totally agree with your last phrase. I think that is what I mean this, but I do not make myself very clearly:
There are other things that are more important to make a plugin compatible with others than using IIFE or not. In my last commissions, I have to make a thing compatible with two plugins from different authors. One of them use IIFE and it was an easy thing to do. The others don't, and it was hard because of the way the plugin has coded.
I think in this case there is no workaround besides looking at the two plugins and make a change in the code or a totally new plugin taking it into consideration.
 

TheoAllen

Self-proclaimed jack of all trades
Veteran
Joined
Mar 16, 2012
Messages
5,573
Reaction score
6,497
First Language
Indonesian
Primarily Uses
RMVXA
You literally just did exactly what you said you can't do
Which is why I said it is suited best for my example.
Sure, it might be ugly to copy-paste the whole function and add your extra line, but if it's just a patch to fix a bug or something, who cares?
I've been doing this practice over the years to help people in RGSS and it worked really well. They don't need to know anything, just apply the patch below the script to either change the script behavior, fixing the bug or provide compatibility patches. It is technically not editing people's code which, in theory, shouldn't matter and I don't need permission.

I even do that in my project to preserve the original code in case I need to look back on what is the original code looks like. There are a lot of overwriting. I wanted to do the same thing in JS plugins.
 

DoubleX

Just a nameless weakling
Veteran
Joined
Jan 2, 2014
Messages
1,728
Reaction score
877
First Language
Chinese
Primarily Uses
N/A
I can't read Japanese yet, and I don't know if I'd be too unreasonable to ask someone to make a summary here on why and how exactly the officials endorse the IIFE that intentionally seals off some important variable/function accesses :)
 

TheoAllen

Self-proclaimed jack of all trades
Veteran
Joined
Mar 16, 2012
Messages
5,573
Reaction score
6,497
First Language
Indonesian
Primarily Uses
RMVXA
Here is the machine translation because apparently, my chrome auto-translate any page that is not English/Indonesia.

Screenshot_71.jpg
 

DoubleX

Just a nameless weakling
Veteran
Joined
Jan 2, 2014
Messages
1,728
Reaction score
877
First Language
Chinese
Primarily Uses
N/A
Assuming that the translation's correct, to me, these reasons aren't strong enough to seal off access of some variables/functions that can be useful for some other plugins(compatibility issues, plugin A using plugin B, etc), as the same issues can also be solved by passing a plugin container(that can be accessed globally) designated to the plugin inside the IIFE and stores everything that would be otherwise private into that plugin container, and it not only won't seal off access of any variable/function, but also assign them to a proper namespace, so they can be identified as being under the designated plugin :)
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts


And now to face my worst enemy... adding color :kaocry:
Power has been restored FINALLY to our home in Lake Charles. Hurricane Laura tried to wreck our lives and disrupt my work on the commercial project i have going with Cloud 9 but the key word is TRIED!!! Slowly moving from the shelter to home over the next week or so. I WILL NOT QUIT!
I am happy because the RPG Maker MZ character comes with extra bust and full body art, but I am disappointed because the quality of the character's PIxel art has decreased.
Only My Opinion that Pixel art MV is better.
I think my SV will be weird, but I would love to change it up.

"Signature characters" - the mascots of your game. Cute, quirky, lovable, recognizable.
i.e.
Kirby, Disgaea prinnies, creepers, Sonic, Mario, DQ slimes, pikachu (all starters), chocobos.

You see what I'm saying.
Getchu one.

Forum statistics

Threads
103,224
Messages
998,123
Members
134,709
Latest member
katana100
Top