man this is very nice, i always like the "factory functions" design pattern you used to make up for absence of classes.
@erinlane9503 жыл бұрын
Finally this makes sense! I have read and watched so many OOP Lua programming tutorials for LOVE2D specifically and I never really "got" it until now.
@KuraakaiGoro Жыл бұрын
I followed your tutorial, and decided your pet should be fed only once, or you'll overfeed him. I added extra lines of code dog.feed = function(self) if self.status == "Hungry" then print(name .. " is now full") self.status = "Full" self.loyalty = self.loyalty + 5 else print(name .. " has already been fed") end end and added an extra function that lets you train him. dog.train = function(self) print(name .. " has been trained") self.loyalty = self.loyalty + 5 end I feel accomplished
@slycxi4 ай бұрын
bro finlly gonna male blox fruits 💀
@AkamiChannel Жыл бұрын
12:38 Unless I'm sorely mistaken (I'm coming from a bunch of other languages here) that is not inheritance at all. What you are doing there (in an OOP way of thinking) is instantiating a locally scoped object of the Pet class. Not really anything new or special. Your Dog class is not inheriting from your Pet class, ie, you could not use Dog.status directly as it is written. (unless I'm sorely mistaken which would be surprising to me)
@AkamiChannel Жыл бұрын
Hmm, watching later it looks like I'm wrong. It's very strange to me though. Why does it actually inherit the class instead of just instantiating a local pet object? How does it know that you don't want to just instantiate a local pet object?
@liarleyev848711 ай бұрын
you're not too wrong lol, but in absence of real classes, this is a way for "simulate" inheritance. But, for questions of "separation of concerns" i would prefer to pass the "Pet Factory Function" as a parameter instead of call it directly inside of the Dog Factory function. Sorry for my not too correct and weird english, i'm not a native speaker.
@liarleyev848711 ай бұрын
@@AkamiChannel i'm not the guy of the video, but i will reply your question about "why not simply instantiate a pet object?" anyway. This will depends of your interests. Maybe you're developing a game that only will have dogs and cats, both share some common behaviours but not everything. In this case, maybe (only with you want) you can have a class/factory function for create these common behaviours and have factory functions specifically for create Dogs and Cats with its owns behaviours (or sub-functions). In this scenario, you don't want that users or other developers create any kind of pet, even with existance of a generic Pet "class". More one time, sorry for my english
@AlexPiotrowski3 жыл бұрын
Thanks for the tutorial!
@Stevesteacher3 жыл бұрын
Happy to help! :D
@vilser39502 жыл бұрын
Cat "Luis" is always hungry by default and you cant change his status.
@AdrianTRYaValioCheetos3 жыл бұрын
WOW Very nice!! :D
@malakash47169 ай бұрын
So Lua is like Flutter & Dart Object Oriented Program?
@Stevesteacher9 ай бұрын
No, Lua stimulates OOP with metamethods and functions
@malakash47169 ай бұрын
@@Stevesteacher thanks
@dankmemes8619 Жыл бұрын
i understand the subclass of OOP and how you dont need to have say, 50 objects that need the same default thing but just 50 subclasses to save space and the like. i just dont understand HOW to make it. functions and tables and the like confuse the hell out of me.
@AkamiChannel Жыл бұрын
Procedural programming is not functional programming. Aren't procedural and imperative programming the same?