Best script configuration practices

Script configurations are usually just a number of constants or methods defined in a specific section of the script (typically near the top).

They allow users to customize your script without having to modify the script itself.

It also allows for better code because you will likely repeat yourself less throughout your own code since instead of hardcoding values you simply use a variable.

# Change this switch as neededSwitch_ID = 5 Regex = /<some[-_ ]regex>/Sometimes, you might be working with more complex syntax like arrays or hashes or even structs depending on your preferences
Code:
equip_types = [  :axe,  :sword,  :wand,]
Configurations are not necessarily code. They may be simply data that will be parsed. You might choose to reference an external file that will hold the data because things like spreadsheet programs are much better at maintaining tables in CSV files than an array or hash of arraysWhat are some of the best configurations you've seen?
Me personally don't really like if the notetag config become too complex or too long which is if you missed the tag, the configuration won't be applied. Notetag should simply put <notetag: 123>.

And for the rest is make it more artistic and easier to understand. Like

Settings = {}Settings[:keyword1] = value_hereSettings[:keyword2] = value_hereSettings[:keyword3] = value_hereSettings[:keyword4] = value_hereSettings[:keyword5] = value_hereIt also can be used for nested hash

Code:
Settings = {} # <-- Do not touchSettings[:keyword1] = {  :attr1 => value,  :attr2 => value,  :attr3 => value,  :attr4 => value,}Settings[:keyword2] = {  :attr1 => value,  :attr2 => value,  :attr3 => value,  :attr4 => value,}
I loved how Enu configure his general setting (NOT his skill configuration)

def max_patterncase idwhen 1 return [3,4]elsereturn [1,1] if id < 0return [3,4] if id > 0end endthis a simple use of when and permit a lot of  section 

I simply love the case method to
@nio - that's already a working method of the script, not a configuration. 🙂

Hmmm... Used to do hashes via something like

Code:
HASH = {  0 => value,  1 => value,}
Then switched to the same way Theo posted above a few scripts ago... Most other scripts that I've seen only uses either of those two approches
@nio - that's already a working method of the script, not a configuration. 🙂
If you ever seen Tankentai, it counts as configuration 🙂
@nio - that's already a working method of the script, not a configuration. 🙂

Hmmm... Used to do hashes via something like

HASH = { 0 => value, 1 => value,}Then switched to the same way Theo posted above a few scripts ago... Most other scripts that I've seen only uses either of those two approches
puhahah mere mortal! Enu use them like a configuration xD  this make the script a lot "scripter use" but for me this make me the system far more easy to use!
Well in a way, yes. I forgot we could use it that way. :3
I have previously written about how to structure the configuration section -> http://forums.rpgmakerweb.com/index.php?/blog/138/entry-697-structuring-the-customization-section/

The key part as I see it is to make sure each configuration value has an impact on one line only.

Hmmm... Used to do hashes via something like
 

HASH = { 0 => value, 1 => value,}
Here we have an example of why such a structure is bad. Of course scripters quickly discover what is wrong and fix the issue, but for non-scripters this can be a showstopper.

*hugs*

 - Zeriab

Original thread: https://forums.rpgmakerweb.com/threads/best-script-configuration-practices.34919/