Skip to main content
GameDev.net gamedev.net
🔒 Locked

Lua script manager

Started by igna92ts Aug 17, 2014 at 4:56 AM 1 replies 2.2k views
Original Post
igna92ts
igna92ts

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)

Endurion
Endurion

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 );
Fruny: Ftagn! Ia! Ia! std::time_put_byname! Mglui naflftagn std::codecvt eY'ha-nthlei!,char,mbstate_t>
frob
frob

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.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.