Jump to content

  • Log In with Google      Sign In   
  • Create Account

Lua script manager


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
2 replies to this topic

#1 igna92ts   Members   -  Reputation: 118

Like
0Likes
Like

Posted 16 August 2014 - 10:56 PM

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)



Sponsor:

#2 Endurion   Crossbones+   -  Reputation: 3576

Like
0Likes
Like

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

#3 frob   Moderators   -  Reputation: 21335

Like
0Likes
Like

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 personal indie blog at bryanwagstaff.com.




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS