Jump to content
  • Advertisement
Sign in to follow this  

How to use Lua tables to manage resources efficiently?

This topic is 3169 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

Having resource path or a stage of a game in your source code is impractical and inflexible, so I wanted to tackle some scripting language. I just got my hand on Lua not so long ago, and I am thinking of mixing C++ +SDL+OpenGL with Lua. I have read about Lua and I am very interesting in using the table. However, I do not see the whole picture of how Lua and C++ can accomplish objectives together yet. For instances, which language should be responsible for what?, should C++ or Lua hold the pointers to the resources?, are there some design patterns to look for?, etc. Could you please provide me some guides or factors to consider? Thank you.

Share this post

Link to post
Share on other sites
The demarcation of responsibility between scripts and core code is arbitrary. You have to weight several factors to determine where the draw the line in how much responsibility/power you have to give the scripts vs how much you want to keep behind the engine.

Factors which affect this are:

3)easy of use (convenience)

Every time you call into the core engine for something it has a time cost but keeping everything in scripts also has its own penalty as scripts are usually 5-50x slower than native code.

Scripts are usually exposed and allows designers to code the game from scratch. However you don't want anyone to wipe your hard drive or download malicious virus or execute buffer overrun attacks. So you'll have to be careful what functions you expose from the native interfaces and also to sandbox the scripts appropriately.

Easy of use, basically working within the paradigm of the scripting language. After writing for several scripting languages you'll see that they have some fundamental paradigms built into them about how to approach things. It's best to use the language as it was designed, this will have the least resistance.

Scalability is only really important if you plan on making large games/applications. Scripting is software engineering, so good planning and design in the early phase will pay off 100x over in the later stages. If your working as part of a team, it might be a good idea to build a script framework for them.

Good Luck!


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!