Jump to content
  • Advertisement
Sign in to follow this  
hick18

Lua Questions

This topic is 2778 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
Advertisement
Sign in to follow this  

  • Advertisement
×

Important Information

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

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!