The situation is that, sometimes you want some notetags to store javascript codes directly, or at least the names of some javascript functions that will be bound to the appropriate contexts upon being called.
The constraint is that, all notetag values should be read upon game start.
Storing javascript codes directly
While users don't have to edit any js file directly, it should be crystal clear and obvious that, if some users uses all those notetags for the same skill/item, and all those notetags store exceptionally long javascript codes, the notebox can be cluttered by them badly.
Also, there can be some cases where many skills/items are using the exact same javascript codes, or at least the major parts of them are exactly the same javascript codes. When users want to change those commonly shared parts, they'll have to change them in all those skills/items.
Storing the names of some javascript functions
Note that decent Javascript coding proficiency(experienced Javascript plugin developers having written dozens of decent plugins and a solid understanding to the default RMMV codebase) is needed to fully utilize this plugin.
Off topic:
Users can use some STCX and STAX as building blocks to form complete STCX and STAX that will be actually used by notetags to(with the cost of added function calls) ensure all STCX and STAX are written in a modular fashion(that's also the reason to separate conditions from actions) and promote reusing codes(thus conforming to Don't Repat Yourself). Also, when many notetags use the same STCX/STAX and users want to change those STCX/STAX, they can just change those STCX/STAX directly instead of changing every of those notetags(The same applies to many complete STCX/STAX using the same STCX/STAX building blocks).
However, they'll have to edit the plugin js file directly(unless users can add new params in the plugin manager directly), because the number of params in the plugin manager can't be edited from there directly, meaning that:
- If I provide hundreds of STCX and STAX in the plugin manger directly to ensure all users will always have enough STCX and STAX to use(1 user I know is indeed using hundreds of STAX and none of them are modular nor reusable at all), it'll effectively kill user-friendliness by bloating the plugin manager.
- If I provide just dozens of STCX and STAX in the plugin manager directly to ensure they won't bloat the plugin manager and hence effectively kill user-friendliness, the plugin will fail to serve its purposes for those who do need lots of STCX and/or STAX(even if they totally abandon code modularity to reduce the number of STCX and/or STAX needed).
On a side note: If users have to add more params in the plugin js file directly in order to use more STCX/STAX, it'll just defeat the purpose for using params in the plugin manager in the first place. In this case, I think the current setup is actually easier, simpler and more user-friendly.
Note that the point here is that users now have to edit js files. It still applies even if that files isn't the plugin itself as that's the point of using plugin manager in RMMV in the first place.
Exchanging the above setups
Users would have to edit the plugin js file directly to use those notetags, but they could write modular notetag values that can be effortlessly reused, thus avoiding repetitive typing and preventing them from cluttering the noteboxes.
If DoubleX RMMV State Triggers used the Yanfly Engine Plugins - Battle System - Active Turn Battle setup, it would be something like this:
Users wouldn't have to edit any js file directly to use that notetag, but they couldn't write modular nor reusable codes in that notetag(especially if they need to write some long Javascript codes), thus being likely prone to cluttering the noteboxes and changing the same Javascript codes repetitively.
The above examples showed what this topic's about: Editing js files directly vs cluttering the noteboxes.
If it's indeed a false dilemma, like it might turn out that users do have ways to add params in the plugin manager directly, I'd like to know some setups that can let users write modular and reusable javascript codes(to avoid cluttering the noteboxes and changing the same things repetitively) as notetag values without forcing them to edit any js file directly.
If it's indeed a true dilemma, which of the aforementioned setups will you choose if you had to? I want you to answer this as both plugin developers and users.
The constraint is that, all notetag values should be read upon game start.
Storing javascript codes directly
For example, these notetags in the lunatic mode of Yanfly Engine Plugins - Battle System - Active Turn Battle needs users to write javascript codes to be used via eval():
Yanfly's lunatic mode's supposed to be for advanced users that can write codes themselves:
Skill and Item Notetags:<Target ATB Eval>speed = x;charge = x;</Target ATB Eval>You can omit speed and/or charge. Whatever you set ‘speed’ to will change the ATB speed of the target. If the target is charging, ‘charge’ will cause the target’s charge to change to that value. To make things more simple, ‘max’ will be the full gauge value.Here is an example:<Target ATB Eval>speed = target.hp / target.mhp * max;charge = target.hp / target.mhp * max;</Target ATB Eval>The above code will set the user’s current ATB gauge to position equal to the target’s HP ratio. If the target has 25% HP, the ATB gauge will go to 25% full for the target.— — — — —<After ATB Eval>speed = x;</After ATB Eval>This is the ATB set after the user has used the skill/item and the custom ATB amount you want the user to be at after. ‘max’ be the value of the full gauge value. Whatever you set ‘speed’, the user’s ATB speed value will change to that much:Here is an example:<After ATB Eval>speed = user.mp / user.mmp * max;</After ATB Eval>The above code will set the user’s ATB gauge after using the skill/item to equal the user’s MP ratio. If the user has 25% MP, the ATB gauge will go to 25% full for the user.— — — — —<ATB Interrupt Eval>interrupt = true;</ATB Interrupt Eval>This will allow you to set custom conditions for interrupting a target. Keep in mind that even though it is a custom condition, it still requires the target to be in the charging phase for the interrupt to work. By setting ‘interrupt = true’, the target will be interrupted.Here is an example:<ATB Interrupt Eval>if (user.hp > target.hp) { interrupt = true;}</ATB Interrupt Eval>The above code will state that if the user has more HP than the target, the target will be interrupted.
Yanfly's lunatic mode's supposed to be for advanced users that can write codes themselves:
Skill and Item Notetags:<Target ATB Eval>speed = x;charge = x;</Target ATB Eval>You can omit speed and/or charge. Whatever you set ‘speed’ to will change the ATB speed of the target. If the target is charging, ‘charge’ will cause the target’s charge to change to that value. To make things more simple, ‘max’ will be the full gauge value.Here is an example:<Target ATB Eval>speed = target.hp / target.mhp * max;charge = target.hp / target.mhp * max;</Target ATB Eval>The above code will set the user’s current ATB gauge to position equal to the target’s HP ratio. If the target has 25% HP, the ATB gauge will go to 25% full for the target.— — — — —<After ATB Eval>speed = x;</After ATB Eval>This is the ATB set after the user has used the skill/item and the custom ATB amount you want the user to be at after. ‘max’ be the value of the full gauge value. Whatever you set ‘speed’, the user’s ATB speed value will change to that much:Here is an example:<After ATB Eval>speed = user.mp / user.mmp * max;</After ATB Eval>The above code will set the user’s ATB gauge after using the skill/item to equal the user’s MP ratio. If the user has 25% MP, the ATB gauge will go to 25% full for the user.— — — — —<ATB Interrupt Eval>interrupt = true;</ATB Interrupt Eval>This will allow you to set custom conditions for interrupting a target. Keep in mind that even though it is a custom condition, it still requires the target to be in the charging phase for the interrupt to work. By setting ‘interrupt = true’, the target will be interrupted.Here is an example:<ATB Interrupt Eval>if (user.hp > target.hp) { interrupt = true;}</ATB Interrupt Eval>The above code will state that if the user has more HP than the target, the target will be interrupted.
Also, there can be some cases where many skills/items are using the exact same javascript codes, or at least the major parts of them are exactly the same javascript codes. When users want to change those commonly shared parts, they'll have to change them in all those skills/items.
Storing the names of some javascript functions
For example, the setup of DoubleX RMMV State Triggers(Its purpose's to let users sets some states to trigger some additional effects under some timings when some conditions are met) is this:
Each state can have as many <timing state trigger: STCX, STAX> notetags as users want, and all those notetags will be effective:
* # State Notetags: * 1. <timing state trigger: STCX, STAX> * - Sets a state to trigger STAX when timing and STCX are met * - timing can be add, turn, remove or custom timings set by you * - add means the state's just added * - turn means the state's remaining turn's just reduced by 1 * - remove means the state's just removed * - timing must only consist of alphanumeric characters * - STCX can be set in State Trigger Condition Functions * - STAX can be set in State Trigger Action Functions The below part can only be accessed by opening the plugin js file directly:
/*------------------------------------------------------------------------ * State Trigger Condition Functions * - Setups STCX used by this script's notetags *------------------------------------------------------------------------*/ /* STCX are used at: 1. Game_BattlerBase - if (st[trigger[0]].call(this)) { in exec_state_triggers STCX are Javascript functions which will be bound to the battler upon use STCX names can only use alphanumeric characters The below STCX are examples added to help you set your STCX You can freely use, rewrite and/or delete these examples */ // Sets the state trigger condition as always true STC1: function() { return true; }, // Sets the state trigger condition as needing switch with id x to be on STC2: function() { return $gameSwitches.value(x); }, // Adds new STCX here /*------------------------------------------------------------------------ * State Trigger Action Values * - Setups STAX used by this script's notetags *------------------------------------------------------------------------*/ /* STAX are used at: 1. Game_BattlerBase - st[trigger[1]].call(this); in exec_state_triggers STAX are Javascript functions which will be bound to the battler upon use STAX names can only use alphanumeric characters The below STAX are examples added to help you set your STAX You can freely use, rewrite and/or delete these examples */ // Sets the state trigger action as what Special Effect Escape does STA1: function() { this.hide(); }, // Sets the state trigger action as setting the battler's hp to full STA2: function() { this._hp = this.mhp; }, // Adds new STAX here
Each state can have as many <timing state trigger: STCX, STAX> notetags as users want, and all those notetags will be effective:
* # State Notetags: * 1. <timing state trigger: STCX, STAX> * - Sets a state to trigger STAX when timing and STCX are met * - timing can be add, turn, remove or custom timings set by you * - add means the state's just added * - turn means the state's remaining turn's just reduced by 1 * - remove means the state's just removed * - timing must only consist of alphanumeric characters * - STCX can be set in State Trigger Condition Functions * - STAX can be set in State Trigger Action Functions The below part can only be accessed by opening the plugin js file directly:
/*------------------------------------------------------------------------ * State Trigger Condition Functions * - Setups STCX used by this script's notetags *------------------------------------------------------------------------*/ /* STCX are used at: 1. Game_BattlerBase - if (st[trigger[0]].call(this)) { in exec_state_triggers STCX are Javascript functions which will be bound to the battler upon use STCX names can only use alphanumeric characters The below STCX are examples added to help you set your STCX You can freely use, rewrite and/or delete these examples */ // Sets the state trigger condition as always true STC1: function() { return true; }, // Sets the state trigger condition as needing switch with id x to be on STC2: function() { return $gameSwitches.value(x); }, // Adds new STCX here /*------------------------------------------------------------------------ * State Trigger Action Values * - Setups STAX used by this script's notetags *------------------------------------------------------------------------*/ /* STAX are used at: 1. Game_BattlerBase - st[trigger[1]].call(this); in exec_state_triggers STAX are Javascript functions which will be bound to the battler upon use STAX names can only use alphanumeric characters The below STAX are examples added to help you set your STAX You can freely use, rewrite and/or delete these examples */ // Sets the state trigger action as what Special Effect Escape does STA1: function() { this.hide(); }, // Sets the state trigger action as setting the battler's hp to full STA2: function() { this._hp = this.mhp; }, // Adds new STAX here
Off topic:
Fully comprehending this plugin actually just need some Javascript coding proficiency(inexperienced Javascript plugin developers having written few easy, simple and small plugins and a basic knowledge to the default RMMV codebase). It's one of those rare plugins where fully comprehending them is in fact easier than fully utilizing them.
In this case, this plugin still has its values, because:
- For those who can write such state triggers themselves from scratch(by writing some snippets of course), if they end up writing lots of those state triggers, they'll want to write a plugin that can manage all such state triggers systematically, which will likely lead to one that's similar to this plugin. So this plugin can save them from having to write such plugins themselves.
- For those having just little(beginning Javascript coders having written and read the most rudimentary codes) to no Javascript coding proficiency at all, they can still ask for help to get their desired state triggers.
In this case, this plugin still has its values, because:
- For those who can write such state triggers themselves from scratch(by writing some snippets of course), if they end up writing lots of those state triggers, they'll want to write a plugin that can manage all such state triggers systematically, which will likely lead to one that's similar to this plugin. So this plugin can save them from having to write such plugins themselves.
- For those having just little(beginning Javascript coders having written and read the most rudimentary codes) to no Javascript coding proficiency at all, they can still ask for help to get their desired state triggers.
However, they'll have to edit the plugin js file directly(unless users can add new params in the plugin manager directly), because the number of params in the plugin manager can't be edited from there directly, meaning that:
- If I provide hundreds of STCX and STAX in the plugin manger directly to ensure all users will always have enough STCX and STAX to use(1 user I know is indeed using hundreds of STAX and none of them are modular nor reusable at all), it'll effectively kill user-friendliness by bloating the plugin manager.
- If I provide just dozens of STCX and STAX in the plugin manager directly to ensure they won't bloat the plugin manager and hence effectively kill user-friendliness, the plugin will fail to serve its purposes for those who do need lots of STCX and/or STAX(even if they totally abandon code modularity to reduce the number of STCX and/or STAX needed).
On a side note: If users have to add more params in the plugin js file directly in order to use more STCX/STAX, it'll just defeat the purpose for using params in the plugin manager in the first place. In this case, I think the current setup is actually easier, simpler and more user-friendly.
Note that the point here is that users now have to edit js files. It still applies even if that files isn't the plugin itself as that's the point of using plugin manager in RMMV in the first place.
Exchanging the above setups
If Yanfly Engine Plugins - Battle System - Active Turn Battle used the DoubleX RMMV State Triggers setup, the lunatic part would be something like this:
Skill and Item Notetags:<Target ATB Function: TATBX>You can omit speed and/or charge. Whatever you set ‘speed’ to will change the ATB speed of the target. If the target is charging, ‘charge’ will cause the target’s charge to change to that value. To make things more simple, ‘max’ will be the full gauge value.TATBX is the name of a javascript function under Target ATB Notetag Function, which can only be accessed by opening the plugin js file directly— — — — —<After ATB Function: AATBX>This is the ATB set after the user has used the skill/item and the custom ATB amount you want the user to be at after. ‘max’ be the value of the full gauge value. Whatever you set ‘speed’, the user’s ATB speed value will change to that much:AATBX is the name of a javascript function under After ATB Notetag Function, which can only be accessed by opening the plugin js file directly<ATB Interrupt Function: ATBIX>This will allow you to set custom conditions for interrupting a target. Keep in mind that even though it is a custom condition, it still requires the target to be in the charging phase for the interrupt to work. By setting ‘interrupt = true’, the target will be interrupted.ATBIX is the name of a javascript function under ATB Interrupt Notetag Function, which can only be accessed by opening the plugin js file directlyThe below part can only be accessed by opening the plugin js file directly:
/*------------------------------------------------------------------------ * Target ATB Notetag Functions * - Setups TATBX used by <Target ATB Function: TATBX> *------------------------------------------------------------------------*/ // Adds new TATBX here /*------------------------------------------------------------------------ * After ATB Notetag Functions * - Setups AATBX used by <After ATB Function: AATBX> *------------------------------------------------------------------------*/ // Adds new AATBX here /*------------------------------------------------------------------------ * ATB Interrupt Notetag Functions * - Setups ATBIX used by <ATB Interrupt Function: ATBIX> *------------------------------------------------------------------------*/ // Adds new ATBIX here
Skill and Item Notetags:<Target ATB Function: TATBX>You can omit speed and/or charge. Whatever you set ‘speed’ to will change the ATB speed of the target. If the target is charging, ‘charge’ will cause the target’s charge to change to that value. To make things more simple, ‘max’ will be the full gauge value.TATBX is the name of a javascript function under Target ATB Notetag Function, which can only be accessed by opening the plugin js file directly— — — — —<After ATB Function: AATBX>This is the ATB set after the user has used the skill/item and the custom ATB amount you want the user to be at after. ‘max’ be the value of the full gauge value. Whatever you set ‘speed’, the user’s ATB speed value will change to that much:AATBX is the name of a javascript function under After ATB Notetag Function, which can only be accessed by opening the plugin js file directly<ATB Interrupt Function: ATBIX>This will allow you to set custom conditions for interrupting a target. Keep in mind that even though it is a custom condition, it still requires the target to be in the charging phase for the interrupt to work. By setting ‘interrupt = true’, the target will be interrupted.ATBIX is the name of a javascript function under ATB Interrupt Notetag Function, which can only be accessed by opening the plugin js file directlyThe below part can only be accessed by opening the plugin js file directly:
/*------------------------------------------------------------------------ * Target ATB Notetag Functions * - Setups TATBX used by <Target ATB Function: TATBX> *------------------------------------------------------------------------*/ // Adds new TATBX here /*------------------------------------------------------------------------ * After ATB Notetag Functions * - Setups AATBX used by <After ATB Function: AATBX> *------------------------------------------------------------------------*/ // Adds new AATBX here /*------------------------------------------------------------------------ * ATB Interrupt Notetag Functions * - Setups ATBIX used by <ATB Interrupt Function: ATBIX> *------------------------------------------------------------------------*/ // Adds new ATBIX here
If DoubleX RMMV State Triggers used the Yanfly Engine Plugins - Battle System - Active Turn Battle setup, it would be something like this:
* # State Notetags: * 1. <timing state trigger> * Javascript codes * </timing state trigger> * - Sets a state to run Javascript codes when timing's met * - timing can be add, turn, remove or custom timings set by you * - add means the state's just added * - turn means the state's remaining turn's just reduced by 1 * - remove means the state's just removed * - timing must only consist of alphanumeric characters * - Javascript codes will be evaluated using eval()
The above examples showed what this topic's about: Editing js files directly vs cluttering the noteboxes.
If it's indeed a false dilemma, like it might turn out that users do have ways to add params in the plugin manager directly, I'd like to know some setups that can let users write modular and reusable javascript codes(to avoid cluttering the noteboxes and changing the same things repetitively) as notetag values without forcing them to edit any js file directly.
If it's indeed a true dilemma, which of the aforementioned setups will you choose if you had to? I want you to answer this as both plugin developers and users.