Is there a way to get this to work with intellisense? Intellisense works up until we start getting into the advanced part of the tutorial where we enable the possibility of inheritance, then it just stops detecting anything :<
Thank you for this resource, It was a very interesting read!
The way I’ve got around the issue of intellisense, is to define object types within each class module script and exporting them so those types can be used outside of the module script. Types can use the concept of inheritance too! When I create an object, I specify that the variable is of the object type found in the class module script.
I’ve actual developed a pattern of how I develop classes using this system now. In short, I first define the type of the object (the properties and functions). Then I write the class and its logic following the type I created.
The only issue with this is if you don’t keep the type up to date with what’s actually in the class, the mismatch can be confusing and can lead to errors.
Yeahh I should’ve specified if it was possible to do typeof() on the class modules and not having to set up manual types, but it makes sense that we would have to manually create the types.
inheritance is a generally bad way to structure your code IMO. I’d recommend to switch to something like an ECS. The type definitions can be pretty annoying to see and write and separating everything into components is preferable.
I’m still an avid defender of the OOP paradigm. I know it seems to be pretty popular to hate on OOP nowadays, but there’s definitely still a reason for its existence, plus inheritance is very useful if used correctly, avoiding deep inheritance. OOP is great for organizing code, so I think it works great for large games.
The ECS pattern can get pretty complex when you have a large number of components that all interact with each other though systems. And lua devs tend to implement ECS in a way that removes all of the efficiency gains it’s known for.
In the end, code in whatever pattern / paradigm that makes the most sense for you. But don’t be afraid to learning new patterns / paradigms as well, you might find one that works better for you! My mind thinks in an OOP way, so I usually use OOP in my games.
I’m currently developing an OOP based Archetype ECS system in Lua, trying to tie in some of the benefits of ECS and OOP together. It’s a fun project!
yeah I fully understand that, I still use OOP too, It’s very convenient for small independent objects, I just prefer ECS for games as a whole, you can also use composition in OOP instead of inheritance. As you said, to each their own.