I have taken a look about the methods of scripting. I am novice and still I am learning. I have tried making modules and call the module functions in the main script. Also I have tried making and calling functions in the same script. Which way is more future proof and approachable to updates.
Module scripts are better for things that are going to be reused, such as certain methods or operations in your game (such as updating a players currency which you wouldn’t wanna rescript everytime there is a script needing to update the players currency). Functions within in the script are opposite to that, something that you wont need anywhere else (such as creating the players leaderstats).
It seems like you’re still learning ways to use ModuleScripts and that’s good! Don’t overwhelm yourself too much though. The way your code is structured will change over time. It’s happened to me quite a lot over the years.
I personally use MVC(model, view, controller), SRP, and the Service/Controller paradigm when structuring my code. I do not follow the classic approach of MVC where the Model is considered top-level individual state/data components. Instead I encapsulate my Model components w/ Controllers to have better control over the state of my systems. This isn’t necessary but, for my use case it makes sense since I don’t want multiple controllers touching the same states/data.
You’ll often find people mentioning Services/Controllers when they make games. A lot of people have adopted this paradigm due to frameworks like Knit. It usually comprises of one Server/Client script that requires all your Service/Controller modules at run-time. Pretty much a single source of instantiation for all the logic to be run for your game. Other people use multiple server/client scripts combined w/ module scripts for data-sharing, re-usability, and more. There’s nothing wrong w/ either approach. The only thing that matters is the user experience of your game at the end of the day.
Yeah, I understand that if i want to reuse some functions then i will use the module scripts. But, I have seen others they are using the structure of java. They may not use OOP but they use the main script just for running the functions from the module script.
So it’s pretty much the scripter’s preference. But using these types of frameworks maybe come to some advantages or disadvantages. I will try other frameworks and see what fits for me. I believed that using a specific framework is important to make an organized and readable code.
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.