• Advertisement
Sign in to follow this  

Lua script manager

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

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)

Share this post


Link to post
Share on other sites
Advertisement

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 );
 

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement