Trying to load classes from files with inheritance

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
mikesglove
Prole
Posts: 3
Joined: Mon Sep 23, 2024 2:11 pm

Trying to load classes from files with inheritance

Post by mikesglove »

Apologies if I'm not doing this right, I registered my account mere minutes prior to writing this post.

I use 30log for classes in my game, which represent objects in the world.
In my case, all objects are loaded from their own files in a folder called "entities" and each file is provided a table called "ENT".
Additionally, they (should) automatically inherit methods from their desired entities, of whose name is defined in "ENT.__base"

Right now, what I'm trying to do is create a class for each file prior to actually loading each file and passing that class as "ENT", but it doesn't seem to work :(

What approach should I use for this problem?
User avatar
dusoft
Party member
Posts: 654
Joined: Fri Nov 08, 2013 12:07 am
Location: Europe usually
Contact:

Re: Trying to load classes from files with inheritance

Post by dusoft »

Not sure without seeing the code. But indeed you can load (require) mutiple files and create and merge objects from them.
mikesglove
Prole
Posts: 3
Joined: Mon Sep 23, 2024 2:11 pm

Re: Trying to load classes from files with inheritance

Post by mikesglove »

That was a good enough reply to get me to change the way I load entities.
The approach I use now is simply requiring a function/an object that can be called, to be returned, that itself returns a table.
With the class system, I require the base and extend it.
Thank you 👍
User avatar
dusoft
Party member
Posts: 654
Joined: Fri Nov 08, 2013 12:07 am
Location: Europe usually
Contact:

Re: Trying to load classes from files with inheritance

Post by dusoft »

Well, good, showing the way is often better than fixing issues for you :-)
mikesglove
Prole
Posts: 3
Joined: Mon Sep 23, 2024 2:11 pm

Re: Trying to load classes from files with inheritance

Post by mikesglove »

After all, I was asking for an approach on solving this.
User avatar
dusoft
Party member
Posts: 654
Joined: Fri Nov 08, 2013 12:07 am
Location: Europe usually
Contact:

Re: Trying to load classes from files with inheritance

Post by dusoft »

Glad you solved it.
Post Reply

Who is online

Users browsing this forum: Amazon [Bot], Google [Bot] and 19 guests