For all the plugin makers: What is the best practice?

Status
Not open for further replies.

Eliaquim

Hakuen Studio
Veteran
Joined
May 22, 2018
Messages
1,681
Reaction score
1,095
First Language
Portuguese - Br
Primarily Uses
RMMZ
Hi there!
I'm making a plugin, and i have a doubt:

What is the best practice?
Code:
var _Elii_Game_Timer_update = Game_Timer.prototype.update;
    Game_Timer.prototype.update = function(sceneActive) {
        _Elii_Game_Timer_update.call(this, sceneActive);
                MY CODE STUFF HERE
or

Make my own function with the code and call it inside instead of putting the whle code.
Code:
var _Elii_Game_Timer_update = Game_Timer.prototype.update;
    Game_Timer.prototype.update = function(sceneActive) {
        _Elii_Game_Timer_update.call(this, sceneActive);
                $gameTimer.myFunction();
Or it is irrelevant?
 

Engr. Adiktuzmiko

Chemical Engineer, Game Developer, Using BlinkBoy'
Veteran
Joined
May 15, 2012
Messages
14,682
Reaction score
3,003
First Language
Tagalog
Primarily Uses
RMVXA
Unless you're gonna call that extra function from a different place or readying it for future aliasing/overwriting possibilities (that will only be for your custom added code lines not for the aliased function), I don't see much sense in doing it.
 

DrDhoom

Monkey Needs a Hug
Veteran
Joined
Mar 16, 2012
Messages
154
Reaction score
157
First Language
Indonesian
Primarily Uses
N/A
For update function I always create a new function, so that the update function won't be overcrowded and it'll be easier to find stuff because you'll know what the code is doing just based on the function name alone.
 

Poryg

Dark Lord of the Castle of Javascreeps
Veteran
Joined
Mar 23, 2017
Messages
4,125
Reaction score
10,639
First Language
Czech
Primarily Uses
RMMV
The first option is simpler, the second option is more readable. I myself prefer the first one.
 

MushroomCake28

KAMO Studio
Global Mod
Joined
Nov 18, 2015
Messages
3,705
Reaction score
4,670
First Language
English
Primarily Uses
RMMZ
I always do the first one, unless that extra bit of code will be called somewhere else.
 

waynee95

Inactive
Veteran
Joined
Jul 2, 2016
Messages
681
Reaction score
597
First Language
German
Primarily Uses
RMMV
I usually go with the first version, if the code is not really long.
 

Eliaquim

Hakuen Studio
Veteran
Joined
May 22, 2018
Messages
1,681
Reaction score
1,095
First Language
Portuguese - Br
Primarily Uses
RMMZ
Thank you for all the answers!! ^^
 

slimmmeiske2

Little Red Riding Hood
Global Mod
Joined
Sep 6, 2012
Messages
7,803
Reaction score
5,212
First Language
Dutch
Primarily Uses
RMXP

This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.

 
Status
Not open for further replies.

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

Latest Threads

Latest Posts

Latest Profile Posts


My only regret is the portal mirror effect is too subtle to show up in these GIFs. It probably just needs more sparkles. :LZSwink:
Microsoft: Hey, let's waste money advertising the Xbox Series X when nobody has any in stock, we don't seem to be making more, we aren't taking preorders and you can't get on a waiting list. BEST. IDEA. EVER.
So I'm practicing ITC with a spirit box, and decide to try to contact my deceased soulmate. It actually gave me multiple identifiers. Me, still a bit skeptical, asked aloud "Fine but does he still love me?" and the box spoke and printed the word "Forever" at the same time. Been a mess of tears since. :kaocry:
Been scratching away at my game and making progress, but just had a revelation. I'm working in full screen and adjusting all my pictures accordingly, but will they resize if someone's screen is smaller?? I hope this doesn't turn out to be a problem later.

Forum statistics

Threads
105,635
Messages
1,015,171
Members
137,309
Latest member
wagemuts
Top