Hello,
Im working on running Lua scripts from within my program written in C++. The way I am currently handling resources, I register the scripts to a memory buffer, and then use luaL_loadbuffer to load the scripts. However i'm a bit stuck in trying to figure out a way to replicate luas "require()" behavior for including other files when I am not actually using files.
Im thinking that I may have to register a c++ function with the lua state prior to loading scripts, that will pass a filename that I can then call luaL_loadbuffer on the representative buffer. However, then I believe that I will have to load all the scripts in the same Lua state which I would imagine is a pretty horrible idea, and calling this method multiple times on the same file will probably make things explode.
Note that I have an extremely primitive knowledge of Lua, so I little comprehension of how the Stack/States work so im not sure if what im thinking is even possible (and probably makes no sense/is a bunch of crap).
So basically i'm wondering if anybody has any experience with this type of problem (doesn't necessarily have to be Lua) or any insight on what direction to go in.
Thank You!