I made a very simple 2d engine with directx and I was thinking on including a scripting system since tweaking values on the engine code everytime I want to try somthing its becoming a little annoying. I understand how to somewhat use lua scripts for c++ code but since I have to register the lua functions I dont know how to create new functions on a script and register them without touching the engine code myself. If there is another way to get variables from lua functions in c++ code without registering them I dont know how. (Lua beginner)
Lua script manager
Crossbones+ - Reputation: 3847
Posted 16 August 2014 - 11:05 PM
With the Lua API you can access everything that a Lua script can do as well.
To get a global variable for example:
lua_getglobal( LuaInstance, VarName.c_str() ); std::string result = ToString( -1 ); lua_pop( LuaInstance, 1 );
Moderators - Reputation: 26589
Posted 16 August 2014 - 11:07 PM
Unfortunately the hardest part is getting the initial system in place.
Have you looked into LuaBind?
Sadly it usually just takes a lot of effort to get enough complete. Much of it is repetitive, boring, but at least is well-described on the Lua website tutorials. It takes more than a little effort to build up enough functionality that the system becomes script driven instead of code driven.
Once you have a large number of scripts and the engine is mostly working okay it becomes quite easy.
Check out my book, Game Development with Unity, aimed at beginners who want to build fun games fast.
Also check out my personal website at bryanwagstaff.com, where I write about assorted stuff.