Embedding Lua in C++ #26 - Creating Native Objects Using Run Time Type Information

preview_player
Показать описание

The stub project for these videos is available here.

How to embed Lua into a C++ application and interface with the Lua C API.
To follow along you should be familiar with how to code in C++, some knowledge of the Lua scripting langage itself is preferable as this is not a scripting language tutorial.
The tutorial is on Windows and using CMake and Visual Studio, but you could build this code on pretty much any platform.

Рекомендации по теме
Комментарии
Автор

I've found that I can take what you've taught and VERY easily integrate it with Qt's QMetaObject implementation. Great stuff! Very helpful :)

MattPryze
Автор

Another topic of discussion would be passing arguments to the constructor.

MattPryze
Автор

You have an extra *lua_pushvalue* in your binding loop. Right before you create "new". *lua_setfield* doesn't pop the table off the stack. I needed to delete that otherwise I get some memory bugs. Idk 100% if that is the cause of my bugs, but removing that fixed the duplicate tables on the stack and my bug is gone (for now).

I only noticed an issue after I bound about 11 classes to it then started an empty script.

MattPryze
welcome to shbcf.ru