What's wrong with anonymous functions?

Galenmereth

Retired
Veteran
Joined
May 15, 2013
Messages
2,248
Reaction score
2,158
First Language
English
Primarily Uses
N/A
@ArkDG: If you look at previous examples there are far better ways to do it. Like:

Code:
TDD_Example = {}; // Makes an empty object(function($) {  // All your plugin code goes into this anonymous function  $.myPublicFunction = function() {}; // Binds myPublicFunction to TDD_Example, so it can be accessed with TDD_Example.myPublicFunction()})(TDD_Example); // Here we pass in TDD_Example as the value $ will get inside the enclosure.
 
Last edited by a moderator:

Milena

The woman of many questions
Veteran
Joined
Jan 26, 2014
Messages
1,281
Reaction score
106
First Language
Irish
Primarily Uses
N/A
Noob question, when and only when should we use that function with the $ thing?
 

DarknessFalls

Rpg Maker Jesus - JS Dev.
Veteran
Joined
Jun 7, 2013
Messages
1,393
Reaction score
210
First Language
English
Noob question, when and only when should we use that function with the $ thing?
I would suggest you don't at all. These specific functions like $gameBla or $dataX are the way MV has done things but if you look they are just calls to classes or static classes, Just create a static class or object and assign getters (and/or setters) to it and make that public.
 

Iavra

Veteran
Veteran
Joined
Apr 9, 2015
Messages
1,797
Reaction score
863
First Language
German
Primarily Uses
$ is just a variable name, like anything else. It originates from jQuery/Prototype (i think) and usually is used to mark a "context" the function is run in. In Galenemereth's example, you could write "TDD_Example" everytime, but it's easier to just pass it to the function and use the short name, instead.


It also makes it easier to rename the module, afterwards, sind you only need to change it at 2 positions, and not everywhere.
 

Milena

The woman of many questions
Veteran
Joined
Jan 26, 2014
Messages
1,281
Reaction score
106
First Language
Irish
Primarily Uses
N/A
I kind of want to make a core script module. How would you give me a proper example or a way to do it, that stores my variables very well? I know it kinda sound off with the original topic, but any help would really be nice.
 

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

Latest Threads

Latest Posts

Latest Profile Posts

Just beat the last of us 2 last night and starting jedi: fallen order right now, both use unreal engine & when I say i knew 80% of jedi's buttons right away because they were the same buttons as TLOU2 its ridiculous, even the same narrow hallway crawl and barely-made-it jump they do. Unreal Engine is just big budget RPG Maker the way they make games nearly identical at its core lol.
Can someone recommend some fun story-heavy RPGs to me? Coming up with good gameplay is a nightmare! I was thinking of making some gameplay platforming-based, but that doesn't work well in RPG form*. I also was thinking of removing battles, but that would be too much like OneShot. I don't even know how to make good puzzles!
one bad plugin combo later and one of my followers is moonwalking off the screen on his own... I didn't even more yet on the new map lol.
time for a new avatar :)

Forum statistics

Threads
106,017
Messages
1,018,356
Members
137,802
Latest member
rencarbali
Top