- Part 1. Intro to ECS and basic principles
- Part 2. Implementing the basics
- Part 3. Controlling entities in Lua by calling C++ functions.
There are many reasons to use Lua with C++. One of them is that you can put some of the logic from C++ code into scripts, so you can easily change them without the need or recompilation. You can also write some good interfaces, so the scripts are easy enough for even non-coders to write them. Lua is free, Lua is fast, Lua is used in game development quite often.
While there are plenty of good articles about using Lua with C++, I think there are not enough articles about how to use Lua in real projects.
This article is one of the many articles I plan to write. Here are some topics which my articles will cover:
- Entity creation and other basic stuff (you’re reading this now)
- How to implement entity creation
- Managing Lua state and cleaning up
- Scriptable state machines
- Events and callbacks
The stuff described in the articles was mostly discovered during the development of my game called Re:creation.
I don’t think the methods here are perfect, but they’re good enough, fast and work well for me. So, your feedback is welcome. Feel free to leave comments and write e-mails to me about the stuff I can do better. I’m interested in hearing about your Lua/C++ usage!
While this is a C++ article, I think you can implement most of the things mentioned here in your favourite language. I’ll use Lua C API and LuaBridge for examples, so I recommend to read the following articles if you’re not familiar with them: