Singleton Oop Question

wow, i’d say a senior designer such as yourself with good programming skills is a deadly combination. :slight_smile: you can truly create anything. props to you !

my only design skills come from my copy of OmniGraffle. that app is indispensable because it makes it seem like i have more design talent than i really do. LOL

i will definitely keep you in mind. :slight_smile:

sorry about that. this is what i was considering:

[lua]
– if you need to initialize:

local singleton = MyClass:new()
singleton:init()
singleton:load()
return singleton

– if no initialization is required:

return MyClass:new()
[/lua]

Ahh, that makes more sense. :slight_smile: This is why I was asking, I was going to have in my main.lua a class that held the main game engine. The main class would be singleton but the game engine class wouldn’t be. But from the looks of this I could just make the GameEngine class singleton and be done with it… lol

Wait, does garbage collection ever clear the modules Lua holds in require?

i don’t believe so - i’ve never heard of nor run into that situation. i think you have to explicitly unload the module for it to be released to the GC, otherwise modules are unloaded when the Lua interpreter is shut down.

i found a discussion regarding the topic:

http://lua.2524044.n2.nabble.com/Unloading-shared-libraries-loaded-by-require-td5991252.html

dmccuskey, yep, it’s a pretty good situation to be in - especially since I used to be quite active in semi-pro music production and have a nice home studio set up. Typically, I code my game on my laptop, and then when I decide I need an ancient Japanese temple graphic or 8-bit soundtrack, I just model or produce that stuff in the studio or on my 3D-workstation, dropbox it to the laptop and continue coding, in the course of one evening. Tres cool, but what I’m lacking most of all is time!

I’m currently working on a 2D-platformer with a complete leveldesigner built-in, and having lots of fun, but it is a big project to tackle as a solo hobbyist, so taking longer than I wish it would, but I’ll shoot you a preview in the next coming weeks!

ah, okay. I should be good then. Thanks for all the help everyone!! :smiley: