3

My game is in C++ and I want to make AI being managed by lua scripts, but I have no idea how should the scripts look like and the integration in C++.

Should the script be like

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

And in every frame in C++ I should call for every enemy:

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

Or it is wrong and I should handle it different?

ziggystar
  • 28,410
  • 9
  • 72
  • 124
user1873947
  • 1,781
  • 3
  • 27
  • 47

2 Answers2

2

To answer your other question about how the AI scripts should look like, that's more appropriate for gamedev.stackexchange. Have a look at this question and the answers: https://gamedev.stackexchange.com/questions/2194/new-to-creating-ai-where-to-start

Community
  • 1
  • 1
congusbongus
  • 13,359
  • 7
  • 71
  • 99
0

Have a look at LuaBind.

Luabind is a library that helps you create bindings between C++ and Lua. It has the ability to expose functions and classes, written in C++, to Lua. It will also supply the functionality to define classes in lua and let them derive from other lua classes or C++ classes. Lua classes can override virtual functions from their C++ baseclasses.

Peter Wood
  • 23,859
  • 5
  • 60
  • 99