This post aims to incite you to think about the design decision about the degree of control and freedom given to script users and share some ideas about it here. Let's start by sharing mine.
In some cases like writing scripts without user input at all(i.e., 100% plug and play scripts), this design decision doesn't even exist. But when your scripts let users input something(like notetags, script calls, configuration values), I think this design decision will likely be extremely important as it'll most likely drastically affect your script implementations and sometimes, even the user editable regions. This implies that it should be decided even before writing the script implementation, especially when your scripts are massive, to avoid wasting time changing huge parts of it. Of course, it isn't uncommon that that design decision will have to change after you've finished at least quite some parts of the script implementations, it also isn't uncommon that you've little say about the degree of control and freedom the users need(like doing some user commissions, especially the paid ones), but let's stick to cases where you've the final say.
I'll first talk about the degree of control and freedom given to script users itself first, which can both be viewed on the script level and the user input level, then talk about the factors needed to consider in the decision making.
Degree of control and freedom given to script users
Level 3 - Normal control and freedom. The user input's always constant but it's used to set which switch or variable's used for the corresponding output. Users can change that output at runtime by changing the state or value of the associated switch or variable respectively.
Example(YSA Battle System: Classical AT😎:
Level 4 - High control and freedom. The user input's always constant but it's RGSS3 codes stored in a string. The corresponding output's determined by evaluating that string at runtime. The degree of control and freedom users have depend on their scripting proficiency and most likely, their understanding of the corresponding parts of the script implementation.
Example(DoubleX RMVXA State Triggers):
Level 5 - Insane control and freedom. The user input, which is RGSS3 codes stored in a string, can be changed at runtime by users via associated script calls. The corresponding output's determined by evaluating the latest version of that string at runtime. The degree of control and freedom users have depend on their scripting proficiency and most likely, their understanding of the corresponding parts of the script implementation.
Example(DoubleX RMVXA Enhanced YSA Battle System: Classical AT😎:
(Actually the Level 4 RGSS3 codes can reach Level 5 control and freedom, but those codes would most likely be extremely messy)
Factors to be considered for deciding the degree of control and freedom given to users
If I wasn't able to write, document and maintain it, and I couldn't think of any other way, I'd be screwed as I wanted to give level 5 control and freedom to users. Therefore, before I decided to change the configuration values to be method contents, I've asked myself if I've the required scripting proficiency. As the answer was positive, I decided to go for it. If I only want the script to give level 4 control and freedom to users, using module_eval can already implement the user written RGSS3 codes.
4. Other potential developers' scripting proficiency - Sometimes other scripters want to writing addons, bug fixes, compatibility fixes, and/or other edits to your scripts, sometimes one wants them to do those for him/her. Sometimes one even might become unable to support his/her scripts. In general, the more control and freedom a script gives to its users, the higher scripting proficiency its developers need to have. Things will likely be much worse when the script isn't written by those developers. If they don't have the required scripting proficiency and the aforementioned cases come, things might be screwed. One might need to think of ways to counter these situations before proceeding.
Example: As I write DoubleX RMVXA Enhanced YSA Battle System: Classical ATB, I realized it demands more and more scripting proficiency for even myself, let alone other developers. In fact, it ended up demanding advanced scripting proficiency from them. I've been worrying about they won't be able to support it in case I become unable to support it, so I tried to counter that by writing useful documentations and even script developer tutorials. I also tried to make the script conform to the MVC(Model View Controller) pattern to help other developers understand the script more effectively and efficiently.
5. The likelihood of the degree of the use of the control and freedom - Even if the functions and purposes of features using the user inputs suggest letting them give high control and freedom to users, even if almost all of the target ones can fully utilize it, even if one is able to provide it to users, and even if many other scripters are able to support the script, sometimes it may still end up having almost none ever using it to that extent, effectively making providing such control and freedom excessive. While almost no one can always tell for sure, he/she should at least think if going that extra mile worths putting so much more effort.
Example: At the very beginning, I suspected that DoubleX RMVXA Enhanced YSA Battle System: Classical ATB will give tons of ridiculously excessive control and freedom to most users, but I still decided to go for it, as I've seen lots of insane requests that I could never think of, and I wanted that script to be able to deal with such requests. Also, I treated writing it as a way to improve and test my scripting proficiency, and fortunately I ended up improving a lot during that 7 months.
Do you think this design decision's important? What do you think about what I said? Do you have other points and/or examples about this design decision you wish to share here? I hope I've incited you to think about all these 🙂
In some cases like writing scripts without user input at all(i.e., 100% plug and play scripts), this design decision doesn't even exist. But when your scripts let users input something(like notetags, script calls, configuration values), I think this design decision will likely be extremely important as it'll most likely drastically affect your script implementations and sometimes, even the user editable regions. This implies that it should be decided even before writing the script implementation, especially when your scripts are massive, to avoid wasting time changing huge parts of it. Of course, it isn't uncommon that that design decision will have to change after you've finished at least quite some parts of the script implementations, it also isn't uncommon that you've little say about the degree of control and freedom the users need(like doing some user commissions, especially the paid ones), but let's stick to cases where you've the final say.
I'll first talk about the degree of control and freedom given to script users itself first, which can both be viewed on the script level and the user input level, then talk about the factors needed to consider in the decision making.
Degree of control and freedom given to script users
As that of the whole script is determined by the entirety of those of its user inputs, I'd like to focus on talking about the latter. I think it usually gives either of the below 5 levels of control and freedom:
Level 1 - No control and freedom at all. The user input just doesn't exist. Users has no way to set the corresponding output.
Example: The maximum atb value in DoubleX RMVXA Enhanced YSA Battle System: Classical ATB is hardcoded as 100.0 and no user input can change that.
Level 2 - Basic control and freedom. The user input's always constant and the same input always gives the same output. Users can only use fixed predetermined values to set the corresponding output.
Example(DoubleX RMVXA Enhanced YSA Battle System: Classical AT😎:
# Sets if configuration values that can crash the game will be rescued # If it's set as true, players will be informed that the values of those # configurations are invalid and will be reset to their default ones # If it's set as false, the game will crash and the error log will be shown # It can;t be changed once set # Example: To let invalid configuration values crash the game to have the # error log, set this as false RESCUE_CONFIG_VAL = true
Level 1 - No control and freedom at all. The user input just doesn't exist. Users has no way to set the corresponding output.
Example: The maximum atb value in DoubleX RMVXA Enhanced YSA Battle System: Classical ATB is hardcoded as 100.0 and no user input can change that.
Level 2 - Basic control and freedom. The user input's always constant and the same input always gives the same output. Users can only use fixed predetermined values to set the corresponding output.
Example(DoubleX RMVXA Enhanced YSA Battle System: Classical AT😎:
# Sets if configuration values that can crash the game will be rescued # If it's set as true, players will be informed that the values of those # configurations are invalid and will be reset to their default ones # If it's set as false, the game will crash and the error log will be shown # It can;t be changed once set # Example: To let invalid configuration values crash the game to have the # error log, set this as false RESCUE_CONFIG_VAL = true
Example(YSA Battle System: Classical AT😎:
TICK_COUNT = 600 # Turn after TICK_COUNT TICK_COUNT_VARIABLE = 0 # Change TICK_COUNT by variable.
Example(DoubleX RMVXA State Triggers):
#--------------------------------------------------------------------------| # State Trigger Action Notetag Values | # - Setups STAX used by this script's notetags | #--------------------------------------------------------------------------| # STAX are used at: # 1. Game_Battler # - eval(trigger[timing][1]) if trigger[timing] && # eval(trigger[timing][0]) in eval_state_triggers # STAX are strings of RGSS3 codes # 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 = "hide"
Example(DoubleX RMVXA Enhanced YSA Battle System: Classical AT😎:
# 2. $game_system.ecatb_config = val |# - Sets the value of :ecatb_config as val |# Example: $game_system.ecatb_base_fill_t = $game_variables[x] sets the|# value of :ecatb_base_fill_t as that of variable with id x |# 3. create_ecatb_def(config, validate) |# - Updates the corresponding method of configuration config |# That method will be validated if validate is true |# Example: BattleManager.create_ecatb_def🙂ecatb_base_fill_t, true) |# updates and validates the corresponding method of |# :ecatb_base_fill_t |
Code:
# Sets something to happen right before updating the atb clock # Its corresponding method's created under Scene_Battle # Example: To support changing atb, charge and cooldown bar colors of all # battlers per frame, set this as # %Q(%Q(all_battle_members.each { |member| # member.ecatb_note_change[:color] = true # })) :pre_ecatb_update => %Q(%Q()),
Factors to be considered for deciding the degree of control and freedom given to users
1. Functions and purposes of a script feature - Normally, each user input is used to run at least 1 script feature. By thinking of those features' functions and purposes, one should be able to figure out that user input's minimum and maximum needed degree of control and freedom given to the users.
Example: 1 of the reasons I decided to hardcode the maximum atb value in DoubleX RMVXA Enhanced YSA Battle System: Classical ATB is that, I think that what really matters is the atb fill percentage and changing the maximum atb value does nothing other than scaling things up or down.
2. The user proficiency demand vs the targeted users - In general, the more control and freedom users have, the more proficient they need to use the increased freedom. If a script wants to target the less able users, giving them high level freedom can actually scare them off, unless it managed to hide those advanced stuffs from them and only expose them to more advanced users(like by separating them into addon scripts).
Example: As DoubleX RMVXA Enhanced YSA Battle System: Classical ATB tries to integrate everything of YSA Battle System: Classical ATB into 1 script and give users as much control and freedom as possible, decent scripting proficiency is needed to fully utilize it. I still made this decision at the very beginning as I want it to be an alternative from YSA Battle System: Classical ATB, which implements each feature as an addon and gives significantly less control and freedom to users but also significantly demand their capabilities less(the countdown and escape addons are the only exceptions).
3. One's own current scripting proficiency - While one can improve his/her own scripting proficiency, doing so generally needs quite some extra time. In cases where such time isn't available(like doing some users' commissions), one will have to take their own scripting proficiency into account, to ensure no parts of the script will ever be out of his/her control. In general, the more control and freedom the script gives, the more proficient its scripter needs to be.
Example(DoubleX RMVXA Enhanced YSA Battle System: Classical AT😎: As the user configuration values are method contents, which will be validated, I made the below abstract method creator and validator -
# Stores create_ecatb_defs, check_ecatb_def and reset_ecatb_def under all # classes and modules having methods created using the configurations CHECK_RESET_DEF = {} [:BATTLEMANAGER, :GAME_BATTLER, :GAME_ACTOR, :GAME_PARTY_TROOP, :WINDOW_BATTLESTATUS, :ECATB_CLOCK_WINDOW, :ECATB_CLOCK_BAR, :ECATB_FORCE_WINDOW, :ECATB_POOL_WINDOW, :SCENE_BATTLE].each { |key| CHECK_RESET_DEF[key] = %Q( def create_ecatb_defs #{key == :GAME_ACTOR || key == :GAME_ENEMY ? "super" : ""} DoubleX_RMVXA::ECATB::#{key.id2name}.each_key { |config| create_ecatb_def(config) } end def check_ecatb_def(config, check) percent = act = "" cur_clock = max_clock = turn_count = index = rule = 0 vals = [] val = eval(config + check[0]) reset_ecatb_def(config, check, "is invalid.") unless eval(check[1]) #{RESCUE_CONFIG_VAL ? %Q(rescue reset_ecatb_def(config, check, "could crash the game.")) : ""} end def reset_ecatb_def(config, check, type) #{SUPPRESS_RESET_CONFIG_VAL_TEXT ? "" : %Q(msgbox("The value of " + config + " is\n" + eval("$game_system." + config) + "\nwhich " + type))} eval("$game_system." + config + " = " + check[2]) create_ecatb_def(config.to_sym, false) #{SUPPRESS_RESET_CONFIG_VAL_TEXT ? "" : %Q(msgbox( "Its value is reset to its default:\n" + eval(check[2])))} end ) }
Example: 1 of the reasons I decided to hardcode the maximum atb value in DoubleX RMVXA Enhanced YSA Battle System: Classical ATB is that, I think that what really matters is the atb fill percentage and changing the maximum atb value does nothing other than scaling things up or down.
2. The user proficiency demand vs the targeted users - In general, the more control and freedom users have, the more proficient they need to use the increased freedom. If a script wants to target the less able users, giving them high level freedom can actually scare them off, unless it managed to hide those advanced stuffs from them and only expose them to more advanced users(like by separating them into addon scripts).
Example: As DoubleX RMVXA Enhanced YSA Battle System: Classical ATB tries to integrate everything of YSA Battle System: Classical ATB into 1 script and give users as much control and freedom as possible, decent scripting proficiency is needed to fully utilize it. I still made this decision at the very beginning as I want it to be an alternative from YSA Battle System: Classical ATB, which implements each feature as an addon and gives significantly less control and freedom to users but also significantly demand their capabilities less(the countdown and escape addons are the only exceptions).
3. One's own current scripting proficiency - While one can improve his/her own scripting proficiency, doing so generally needs quite some extra time. In cases where such time isn't available(like doing some users' commissions), one will have to take their own scripting proficiency into account, to ensure no parts of the script will ever be out of his/her control. In general, the more control and freedom the script gives, the more proficient its scripter needs to be.
Example(DoubleX RMVXA Enhanced YSA Battle System: Classical AT😎: As the user configuration values are method contents, which will be validated, I made the below abstract method creator and validator -
# Stores create_ecatb_defs, check_ecatb_def and reset_ecatb_def under all # classes and modules having methods created using the configurations CHECK_RESET_DEF = {} [:BATTLEMANAGER, :GAME_BATTLER, :GAME_ACTOR, :GAME_PARTY_TROOP, :WINDOW_BATTLESTATUS, :ECATB_CLOCK_WINDOW, :ECATB_CLOCK_BAR, :ECATB_FORCE_WINDOW, :ECATB_POOL_WINDOW, :SCENE_BATTLE].each { |key| CHECK_RESET_DEF[key] = %Q( def create_ecatb_defs #{key == :GAME_ACTOR || key == :GAME_ENEMY ? "super" : ""} DoubleX_RMVXA::ECATB::#{key.id2name}.each_key { |config| create_ecatb_def(config) } end def check_ecatb_def(config, check) percent = act = "" cur_clock = max_clock = turn_count = index = rule = 0 vals = [] val = eval(config + check[0]) reset_ecatb_def(config, check, "is invalid.") unless eval(check[1]) #{RESCUE_CONFIG_VAL ? %Q(rescue reset_ecatb_def(config, check, "could crash the game.")) : ""} end def reset_ecatb_def(config, check, type) #{SUPPRESS_RESET_CONFIG_VAL_TEXT ? "" : %Q(msgbox("The value of " + config + " is\n" + eval("$game_system." + config) + "\nwhich " + type))} eval("$game_system." + config + " = " + check[2]) create_ecatb_def(config.to_sym, false) #{SUPPRESS_RESET_CONFIG_VAL_TEXT ? "" : %Q(msgbox( "Its value is reset to its default:\n" + eval(check[2])))} end ) }
4. Other potential developers' scripting proficiency - Sometimes other scripters want to writing addons, bug fixes, compatibility fixes, and/or other edits to your scripts, sometimes one wants them to do those for him/her. Sometimes one even might become unable to support his/her scripts. In general, the more control and freedom a script gives to its users, the higher scripting proficiency its developers need to have. Things will likely be much worse when the script isn't written by those developers. If they don't have the required scripting proficiency and the aforementioned cases come, things might be screwed. One might need to think of ways to counter these situations before proceeding.
Example: As I write DoubleX RMVXA Enhanced YSA Battle System: Classical ATB, I realized it demands more and more scripting proficiency for even myself, let alone other developers. In fact, it ended up demanding advanced scripting proficiency from them. I've been worrying about they won't be able to support it in case I become unable to support it, so I tried to counter that by writing useful documentations and even script developer tutorials. I also tried to make the script conform to the MVC(Model View Controller) pattern to help other developers understand the script more effectively and efficiently.
5. The likelihood of the degree of the use of the control and freedom - Even if the functions and purposes of features using the user inputs suggest letting them give high control and freedom to users, even if almost all of the target ones can fully utilize it, even if one is able to provide it to users, and even if many other scripters are able to support the script, sometimes it may still end up having almost none ever using it to that extent, effectively making providing such control and freedom excessive. While almost no one can always tell for sure, he/she should at least think if going that extra mile worths putting so much more effort.
Example: At the very beginning, I suspected that DoubleX RMVXA Enhanced YSA Battle System: Classical ATB will give tons of ridiculously excessive control and freedom to most users, but I still decided to go for it, as I've seen lots of insane requests that I could never think of, and I wanted that script to be able to deal with such requests. Also, I treated writing it as a way to improve and test my scripting proficiency, and fortunately I ended up improving a lot during that 7 months.
Do you think this design decision's important? What do you think about what I said? Do you have other points and/or examples about this design decision you wish to share here? I hope I've incited you to think about all these 🙂