Maybe don't make complex Scripts?

Maybe I'm alone in this, but I don't like including scripts in my project that do more than I want. If I am, in fact, not alone in this, maybe future JS scripters take note of this thread and make scripts that do only ONE thing instead of scripts that change, for example, the whole Item Menu.

The again, maybe it's just nonesense to only deal with single elements, because it's so easy to change a whole scene while you're at it?

In both cases, I'd be happy to spawn a discussion about this. 🙂
You mean.................

If I make an item scene where it modifies the window, then, I'll make a separate script that uses pictures for BG instead of giving you the option to use pictures/window/none at all?
... of this thread and make scripts that do only ONE thing instead of scripts that change, for example, the whole Item Menu.
But changing the Item Menu is more or less, just one thing...

People will do both, both have its uses, from Khaz Lights to Yanfly's CMS or An HP bar over the enemies...

Some systems like "materia" will arise, even more with the upcoming remake of the game that owns that system...
No, you're completely right.


The problem is that scripters can't know what each person would prefer. Take my Movement script, for instance: It's a very big script with several features, because different users will want different things.


If I made each feature in a separate script, it could get complicated for people who wanted to use many of them.


The solution I found was to add Enable/Disable options for each feature.


If a feature is disabled on it's configuration, all the code related to that feature will not be loaded at all. So even if the script has 2.000 lines, maybe only 700 of them are actually read by rpg maker because of that 🙂
Well, since I'm not a scripter and don't know much about how to script, I obviously don't have that clear of an idea. In some cases, it might make sense to make a script that changes a complete scene/menu.

But as a basic example, let's take critical hits.

If I only want to add a sound effect that plays on critical hit, I may only find scripts that deal with critical hits as a whole and include features I don't care about. The scripts add critical hit animation, change critical hit damage, add screen flashes and what not. Here, I, PERSONALLY, would prefer to have several scripts that do only one of these things each, and then I include the ones I really want.

As I said, I'm mainly here to start the discussion about it. 🙂
Well, you can always ask the scripter who wrote it to make a shorter version with just that one feature you want.
I agree with this. There are potentially great scripts out there that fall over themselves by bitting off more than what they can chew. This is very common in menu scripts.

You mean.................

If I make an item scene where it modifies the window, then, I'll make a separate script that uses pictures for BG instead of giving you the option to use pictures/window/none at all?
I think he means something more broad. Like a Menu script that changes all the sub-menus (items, skills, status, etc.), when all that he wants is how the item menu looks.
But as a basic example, let's take critical hits.

If I only want to add a sound effect that plays on critical hit, I may only find scripts that deal with critical hits as a whole and include features I don't care about. The scripts add critical hit animation, change critical hit damage, add screen flashes and what not. Here, I, PERSONALLY, would prefer to have several scripts that do only one of these things each, and then I include the ones I really want.
What's the problem with that ? As long as you're able to disable what you don't want i think it's not a problem.

This is why there is always a configuration module that allows you to skip the unwanted features.
It sounds to me like what you're really looking for isn't scripts as much as it is script snippets. There are a few scripters that like writing small snippets for just an extra feature or two, so I imagine they'll continue to do so.

The only challenge, really, is finding them. 🙂
I think most scripters do a pretty good job of this, but sometimes it's a whole bunch of things at once.  In my IGMC attempt I had a battle system script that I wanted to use but it also changed all sorts of other things like the menu and movement.  I had to figure out how to turn off about half the engine so I could replace it with scripts that did the same job better.  In that case having it broken down into smaller scripts would have saved a lot of trouble.  Hudell, your movement script is just right.
I can understand where you're coming from in this, as lengthy scripts tend to confuse me (more so) than the short ones with one or two main functions. However, if the scripter is kind enough to include an options area within their script or other means to disable the parts you don't need/want then that's great.

A lot are pretty reasonable, and if you have a simple request along the lines of 'Can I just get your X function from your XYZ script?' and are respectful of them they are usually more than happy to do something like that.
The problem with that approach is that sometimes you might end up having too many scripts because they all just do a single thing. And that is pretty confusing too IMHO. Plus there are I think a bit more people who look for scripts that are All-in-one packages.


Sometimes there are also features that are actually linked together in a way that one cannot exist without the other.


But yeah, a simple configuration option to disable things and so on will probably do...


Or better yet, learn how to script yourself so you can do those little snippets yourself.
I will put my pinch of salt and be honest here : 

it's better having ONE big engine who do everything's instead of multiple part all made by different scripters.

why? 

this obviously :

compatibility

the big pain in "single" thing's scripts are the damn  possibility of having this little snipset who modify example a little part of the item menu example.

after you want to add something who modify again the item menu and BAM

incompatibility Hit you man.

Honestly it's better to have One engine with 1000 features than 1000 snipset of scripts who do only 1 features
Not if you only need one feature 😉


One big engine, just to add a small bit of functionality, is overkill.


I don't know how many times I've seen someone ask how to increase the window size and people have told them to install a huge engine script. Also, I've seen a number of people who have several "engines" in their game because one provides a little bit of functionality that the other doesn't, only to wonder why their games crash or don't work.


I am of the opinion, "if you don't need it, don't install it". That's easy if you know how to script and can make something just for your own needs, or remove the extra functionality from someone else's script.


But it's hard for the developer who wants to make a script that will be useful for many things. They can't know which bits each individual will want or not want. The best they could do is allow you to enable/disable features, which has already been suggested, but that would take a longer development time.
The plugin nature of MV allows scripters to create a "basic" scripts with additional modules depending on what the user wants. It's more work, but easier to use.
Psss, the "plugins" are just a fancy way to say "scripts + metadata" in MV.

They are not really nothing more. Oh with metadata is...

Do you remember, how scripts come with a module (yea is a great example) with tons and tons of configurations and parameters ?

Well now your scripts will have a window when you can change that values visually.

Also they just added a way to see the name and a little description, but it's not like they changed the behaviour of scripts...

Some features can be separated, but separating too much leads to lag in your game you know, alias of alias of alias (worst yet, here is lambda call after lambda call, and people may know that lambda calls are expensive)

Yes, the luna engine, as a huge script may need to be multiple scripts (turn off "Luna Engine - Menu", or "Luna Engine - Battle" if you don't need them, etc.

But scripts to play a critical animation, then a critical sound to be entirely separate scripts is like, "this is so small"

Sometimes you may want that little snippet, but remember than people often publish script for more than one person, so they have many request and they try to do the most they can.
As much as possible it is better to make your scripts (or any code library you write) as modular as you can. Logically separate functionality (or heavily connected groups of them) where possible both for your own sanity and your users. It's easier to maintain, and it's easier to use. I'll see if I can't write up a tutorial on this when MV hits, but it's not much use before that as it depends on the internal structure quite a bit.
You can see people on both ends of the spectrum: some people prefer to have one script do everything for them, while others prefer to have one script do only one thing and would even refuse to use a script if it just happens to do a little more.


In general, each script I write serves one purpose and typically does not do anything else than what is described.


This becomes a bit complicated when you start getting picky


Example A


Suppose you have a script that allows you to add some feature to actors, classes, weapons, armors, states, and enemies. Do you want this to be provided as 6 different scripts?


Example B


Or suppose you have a script that allows you to control random encounters on a map, and you have different options


1. Control encounters based on the map


2. Control encounters based on a state


3. Control encounters based on who is in the party


And so on. Should these all be separate scripts? Or just build them all into one large script?


Example C


As another example, suppose you have a script that adds custom event triggers. Should each type of trigger be a separate script?


My criteria for separating a script into its own file is based on how complex that portion of code would be (eg: whether it could introduce compatibility issues).


The whole script shouldn't break just because one method doesn't work with your project, especially if you don't even need that feature. In that case, if I determine that there is a likely chance that this one feature may cause problems, it would be provided as an "add-on"
That's a very interesting point, Tsukihime. But I would actually prefer all of them being separate scripts. They could be bundled in a ZIP file maybe. Or there could be clear instructions in the script itself which parts to remove if you don't want that feature. There is already commentary in scripts, of course, but maybe the script could be constructed in a way that makes it save to delete the lines between "# Start State Encounter Rate" and "#End State Encounter Rate".

Maybe MV's plugin system is actually designed to do exactly this?
I think it all starts with a very fundamental design decision: Does the script aims for specific requests/commissions/projects, or does it aims for more widespread uses?

For the former case:

Simply ask those users and listen to what they really want(sometimes you're the user as well). Just pay extra attentions to what that "one thing" the users mentioned truly points to.

For the latter case:

Spoiler
Again, the most important thing is what the "one thing" actually means.

For example, one can say Luna Engine just does 1 thing: To be an extremely customizable custom hud and menu system by giving users extreme degree of control and freedom.

One can also say Luna Engine does ridiculous amounts of stuffs that aren't closely related to each other:

- It changes the window skins

- It changes the window positions

- It changes the window colors

- It changes the bars' positions

- It changes the bars' colors

- It changes the bars' sizes

- It changes how the bars show how much they're filled

- It changes the text fonts

- It changes the text sizes

- It changes the text colors

- It changes the text positions

- etc

(If Luna Engine were divided into the smallest elements possible by implementing each of them in a separate script, I guess it'd lead to 300+ scripts instead)

As in this case, the scripts are designed for more widespread uses, scripters will have to figure out whether the "one thing" the scripters defined will work for their targeting audiences as well.

Then, just like what Galanmereth said, modularity is the key here.

In 1 extreme, everything is integrated into 1 single advanced complex script(up to nearly 10000 lines in some cases).

In another extreme, everything is separated into the smallest possible unit which is implemented by a separate addon(although a core script is probably needed to make those addons manageable).

When everything is integrated into 1 single advanced complex script, the point is modular user interface design.

For example, some advanced complex scripts clearly states which features they've. They're normally classified as core features and optional features.

Core features are those being necessary for the scripts to function, while optional features are to expand the scripts' feature sets.

Those scripts then treat each feature or each group of closely related and/or inherently coupled features as a module, and design the user interface around that so users can clearly view which features belong to which modules and navigate to the desired modules effortlessly..

They're designed in such a way that even if a module left untouched, it still won't interfere with any other module on the user level(whether the same can apply to the code level is entirely another matter).

Users just have to check the listed features and pick what they want to touch, then go to the associated user interface modules to edit what they want/need. Such navigation can be easy and simple if the scripts taught them how to do so effectively and efficiently.

To ensure users won't get lost, each user interface module can even be separated configuration regions each taking a field in the script editor(in incredibly extreme cases, users can even delete those they don't need and the scripts can still work as intended).

When the core and addon script system approach is used, the point is modular addon design.

The core script will contain all/most common base codes that are used by all/most addons, and those addons will just integrate their corresponding feature into the core feature set.

Scripters will then have to decide whether the addons must be placed according to some strict rules(some addons must be placed above/below some other addons) or can be placed as freely as they can achieve.

The former decision will generally avoid complicated n-way addon dependencies(like having lots of if $imported[:addon_x] stuffs among those addons themselves) but will also generally reduce flexibility given to users(sometimes addon x must be placed above addon y to solve some compatibility issues in some specific cases but doing so would violate the addon relative positioning rules), while the reverse generally holds for the latter.

Usually, the hierarchies among those addons are purely parallel, meaning no addon will need another addon in order to work(That doesn't mean they won't depend on each other though). Each of them just needs the core script in order to work.

Users just have to use the core script and all the addon scripts they're interested. Those getting in their way can be safely ignored and the whole system will still work as intended.

Sometimes the number of features in the same feature set also matters.

For instance, if a feature set has just 4 features, then it'll be easy to use the core addon script system approach.

On the other hand, if a feature set has 20+ features(there's at least 1 advanced complex script I know that's exactly the case), managing 20+ addons in the same system by the same user(let alone scripter) can be really painful(like cluttering the script editor fields).

When the core addon script system approach's used, the scripters will have to think about how many features the feature set will eventually include as they can grow over time. They've to ensure the growth will always be under their control, otherwise they can end up facing insane n-way addon dependencies which might even kill their systems at the end(you'll likely know what I'm talking about if you're experienced in dealing with such utter messes).
There's also differences between distinctive features and various degree of control and freedom given to users among the same feature.

For instance, like the Example A of what Tsukihime said, should they be separated into 6 scripts(The same applies to Example B and Example C)?

The underlying question is, are they separate features, or do they belong to the same feature just expressing various degree of control and freedom given to users?

If they're indeed separate features, then making a core script wrapping up their commonalities and another 6 addons to implement their differences will make sense; If they belong to the same feature just expressing various degree of control and freedom given to users, then are those 6 scripts still called for?

For a even more concrete example, check these:

DoubleX RMVXA State Triggers

DoubleX RMVXA Item Triggers

Are they covering 2 distinct features because states and skills/items are 2 completely different things? Are they covering the same feature just applying it to 2 different parts of the database because they both let users sets some specific things to trigger some specific actions at some specific timings when some specific conditions are met?

Anyway, they're so insanely similar on both the user and implementation level that they can be easily integrated into 1 single script instead. Do you want them to be kept separate into 2 different scripts, or do you want them to be integrated into 1 single script instead? Do you think most of the others will think like what you think?

TL;DR: Sometimes what the "one thing" is isn't as crystal clear and obvious as you think.

Original thread: https://forums.rpgmakerweb.com/threads/maybe-dont-make-complex-scripts.43935/