Is it good to organise lua code into Main function and other functions like in python?

I recently learned that python code is often organised into smaller segments - each of which has their own job - so that there’s a main function which then calls other functions to do the actual “job”. Is this good practise in lua, especially in the roblox studio? I hope my explanation was understandable enough…

Are you only talking about organising code?

It’s what makes the code easy to access and read for you.

1 Like

I think it’s a general programming rule to keep code organised regardless which language you use. What you regard as organised however can be dependent on what you are doing and who else needs to be able to read your code.

Personally I tend to create one main script and a whole bunch of modulescripts organised in some way (which do everything except for initialising the game), e.g a single ‘class’ or a group of related functions/tables etc.

1 Like

I think what I mean is, if I have a module script for example, in which I have a function that I call from a script. Then should I put everything in that one function in my module script or make several functions and call them one by one from my main function. So far I have put everything in one function - if possible - and oftentimes the function becomes very long. But I guess that’s not a good practise in sense of code readability.

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