I early in developing a game right now but trying to keep the code organized is basically a disaster

Alright so right now I am creating a survival game and, I have made a few assets and I’ve coded some basic movement for the character and an inventory open and close thing, but I know its going to get out of hand very fast…

Is there like anyway I can organize my game/code so that I dont have a bunch of different scripts and like having to switch back and forth then losing my train of thought then just wasting hours of time trying to get back to where I was at???

Is there just anyway that I can have all the code in one script, but Im thinking that could be better but Im honestly not really sure

Use module scripts for functions you use often in scripts
Dont make seperate scripts for the same systems, cram them into one single script

those are my suggestions

1 Like

Alright so as of now I am creating my “dream game”, so everything is mostly just gonna be client side since the game is just for me

But I was thinking of having a single local script and then having a object oriented module script that I require that has all the stuff I want to do in the game, does that sound good or no?

I suggest you make not one but multiple module scripts.
Like InventoryModule, HealthModule, etc. not actually cram every single thing into one

1 Like

Oh I see what your saying, thanks so much I will try that

It would also make errors way harder to detect if theres one line of code that errors something like “attempt to index nil with xd” without giving u which line it was, making you go through pain and suffering to find it, so making multiple is way better

1 Like

to add on what he is saying, add comments to your code as much as possible so you can come back later and not be confused. You can also use comments to organize sections of different code in the same scripts

1 Like

Or add asserts on arguments so you know for sure theyre correct.

Using it only in the debugging stage as they can affect the function performance if there were many validations.

DUDE thank you a million man, my code is much shorter, easier to read and I know exactly what file im working on and having the modules organized is so USEFUL, DUDE THANK YOU SO MUCH


image

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.