Hello everyone,
When I was writing my first plugin yesterday, I have gone through several other plugins to see how to write the code properly.
In RGSS, I am always aliasing method to make it less likely to crash with other plugin. In JavaScript, I saw Yanfly's plugin doing alias with something like this:
Wora_SkillHPCondition_GameBatBase_meetSkC = Game_BattlerBase.prototype.meetsSkillConditions;Game_BattlerBase.prototype.meetsSkillConditions = function(skill) {// do something here// aliasreturn Wora_SkillHPCondition_GameBatBase_meetSkC.call(this, skill);}(This is taken from my first plugin here: http://forums.rpgmakerweb.com/index.php?/topic/49474-skill-hp-condition-enable-this-skill-when-hp-is-higher-lower-than-50/)
I have also discovered that if the function you're aliasing ends with 'return', you have to use 'return' with aliased function name. It will crash if I don't put 'return' in the code above.
Is there any downside for doing this ? If there is none, I think we should promote the use of aliasing since I have seen many plugin developers just copy the core function and edit in their own plugin, which can make it crash with other plugin very easily.
When I was writing my first plugin yesterday, I have gone through several other plugins to see how to write the code properly.
In RGSS, I am always aliasing method to make it less likely to crash with other plugin. In JavaScript, I saw Yanfly's plugin doing alias with something like this:
Wora_SkillHPCondition_GameBatBase_meetSkC = Game_BattlerBase.prototype.meetsSkillConditions;Game_BattlerBase.prototype.meetsSkillConditions = function(skill) {// do something here// aliasreturn Wora_SkillHPCondition_GameBatBase_meetSkC.call(this, skill);}(This is taken from my first plugin here: http://forums.rpgmakerweb.com/index.php?/topic/49474-skill-hp-condition-enable-this-skill-when-hp-is-higher-lower-than-50/)
I have also discovered that if the function you're aliasing ends with 'return', you have to use 'return' with aliased function name. It will crash if I don't put 'return' in the code above.
Is there any downside for doing this ? If there is none, I think we should promote the use of aliasing since I have seen many plugin developers just copy the core function and edit in their own plugin, which can make it crash with other plugin very easily.