Is this possible? Creating a baseclass using strict

Hi, I want to create a movement game and i’m trying to organize it as much as possible. I had an idea to make a movement super class (base class) and inside the base class are a bunch of other movement classes such as Crouch, Slide, Wallrun, ETC… I’ve tried to do this before but I failed miserably. I feel like this is possible because roblox also uses base class but without strict mode…

Here’s how it would look like:
image

PREVIOUS ATTEMPT:

2 Likes

Think of a movement system based on the changing of state. The child modules would be listening to the Movement module for any state changes and react accordingly.

The main module in this case is Movement and would handle the switching of states. For example, when the player is holding SHIFT it would switch the state to “Running” and the Running module would detect that change maybe through a bindable event called StateChanged and transition to running.

Although I am not quite sure what you mean by strict and non-strict modes. These modes are just used for Luau’s type checking. Could you elaborate on how this is affecting your movement system?

2 Likes

If youve ever used a base class, it’s like a template, any class that uses the base class inherits all the functions and variables stored inside the base class. I was planning to put the state variable booleans inside the Base class and the classes would be able to use the state variables. Strict mode just makes it a lot more confusing…

3 Likes

Strict mode doesn’t (by itself) make things more organized. It’s the way you design your system, your comments (if necessary) and how you write the code.

Personally, I’ve never used strict mode because of the same reason you mentioned:

Strict mode just makes it a lot more confusing…

To stay organized, I don’t want to confuse myself or others. So, I just use normal mode and do what I said above. Plus, not many developers know how to work with strict mode. So, even if you write it very well, some developers would still have a hard time working with it.

In reality though, it’s not hard to learn strict mode. Just a bit more uncommon leading to more devs not being used to it.

3 Likes

Yeah and there aren’t many visual in depth type checking tutorials out there. Sometimes I just do nocheck mode or just normal. But I like writing in strict mode.

1 Like