Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
2

Is it better to use multiple scripts, or cram everything into one script?

Asked by 8 years ago

Putting aside what looks better, and just out of pure curiosity, what would be better? Having all your code in one script manage all tasks, or having multiple scripts to manage separate tasks?

Deficiency

The only deficiency I can see for using multiple scripts to handle separate tasks, would be the need to repeat the need to reference the same information over and over again (i.e, declaring game services at the beginning of the script, multiple times for different scripts).

Also, what's your opinion on this? Do you think using multiple scripts to manage different tasks would be more organized? Or is it not worth the repetition of getting the same information instead of it all being in one script? Any insight would be appreciated, thanks.

0
I try to base my games on the client so there is no lag, okay. UniversalDreams 205 — 8y
0
Multiple scripts would mean slightly more lag (I doubt it would be noticable in most situations, just small figures). For things like referncing, changing one thing, etc., multiple scripts would be better. Basically, the ownly upsides to one script is only defining things once, and less lag (that wouldn't be very noticable anyway). TheDeadlyPanther 2460 — 8y

3 answers

Log in to vote
2
Answered by 8 years ago

I think this is really up to user preference. The other answer is pro multiple scripts, but personally I prefer single script with bunch of modules containing logically sorted functions(for example module that has animation handling functions, or other module which handles projectiles).

I just really enjoy having a single main thread, that dictates the gameflow, so it's easier to track down faulty parts of code and generally makes everything easier to find.

Usually I go with one local script and one server script, and each has bunch of modules.

But remember, both methods will be slow when used incorrectly.

0
I think you need at least one local script and one server script in each of your games, since they cover each other's flaws. RedCombee 585 — 8y
0
Not really flaws, but it just makes sense to have one of each type. Everything server related goes on server script(regular script object) and all the fancy effects and usually the majority of code goes on client script. ZarsBranchkin 885 — 8y
Ad
Log in to vote
1
Answered by 8 years ago

Multiple scripts,
with ModuleScripts.

I just needed some way to keep my title style consistent, don't shoot me. What you want to do is use ModuleScripts for any code that is common between a lot of scripts, for example utility functions, and then use a new Script or LocalScript every time you're doing something different.

New subject, new script. You'll thank yourself later.

Log in to vote
-2
Answered by 8 years ago

its better to have tem separated because if cramped there are more erros or bugs than separated

Answer this question