Jump to content
  • Advertisement
Sign in to follow this  

Lua Questions

This topic is 2693 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Where should game data be stored, for example example enemy objects? in C++ and then pass to each script for processing, or in the script itself? Say I have 20 enemy types and I wanted to have 100 enemies at any one time. In C++ i would do this using polymorphism, using a number of inherited enemy types all derived from Enemy, and then create these storing them in a list of abstract enemies, and then call their virtual functions. How would this be done in Lua? In lots of tutorials, you seem them creating and storing th enemies in Lua itself using a table as a global variable. I like the idea of having the scripts just perform some functionality, or processing. So maybe having only one enemy class in C++, but a different script assigned to each enemy to give it different characteristics. But this then raises the question of where to store EnemyType specific data?

How should Lua States be used? If I use one for each enemy, then that would allow me to have enemy specific data stored in the script, that i know wouldnt change unless being called for that exact enemy. Are there performance issues using this technique?

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!