Gamedev: how do i control AI with lua scripting?

My game is in C ++ and I want the AI ​​to be driven by lua scripting, but I have no idea what scripting and integration looks like in C ++.

If the script looks like

   if (whatever_happening) do_something
   if (....) .....
   etc

      

And in every frame in C ++ I have to call every enemy:

   foreach(enemy)
   enemy.handleAi(luascript.file)

      

Or is it wrong and I have to deal with it differently?

+3


source to share


2 answers


To answer another question about what AI scripts look like, this is more appropriate for gamedev.stackexchange . Have a look at this question and answers: https://gamedev.stackexchange.com/questions/2194/new-to-creating-ai-where-to-start



+2


source


Have a look at LuaBind .



Luabind is a library that helps create bindings between C ++ and Lua. It has the ability to expose functions and classes written in C ++ to Lua. It will also provide functionality to define classes in lua and allow them to be inferred from other lua classes or C ++ classes. Lua classes can override virtual functions from C ++ base classes.

0


source







All Articles