Does anybody have advice on a good tutorial or sample code to look at regarding “modularizing” NPC code into separate lua files? I’m interested in better organizing my code on my current project and would like to craft lua files for some of the major blocks in my main file.
I’m using Jon Bebee’s Modular Classes in Corona Tutorial as a reference:
http://www.coronalabs.com/blog/2011/09/29/tutorial-modular-classes-in-corona/
This is very insightful but there are a a few things I’m trying to figure out beyond this example:
- My NPC need to “act” in the environment. How do I set up event listeners in this modularized context?
- I need to be able to tell one NPC of the same type appart from another (presumably with some sort of unique identifier/name). Is there a way I can set that up from within the file or do I need to manage that from the main file where I’m calling the .new() function?
- how should I handle garbage collection of my NPCs? place them all into one display group and then remove that? I am using the meta table concept from the tutorial. How does the NPC_mt come into play with this? I guess I could create a garbage collection function in my separate NPC file and then call that? If I’ve made multiple instances of NPCs would I then iterate through them calling the function for each one?
Thanks for any help you can offer with this kind of noobish questions!
[import]uid: 105707 topic_id: 28418 reply_id: 328418[/import]