Sign in to follow this  
  • entries
    201
  • comments
    88
  • views
    100357

Lua Scripting almost done...

Sign in to follow this  
Metron

57 views

One of my targets is to make almost everything in my engine accessible from lua scripts. Another one is to make calls into the lua scripts from within my engine/game.

After searching for the right way to do it (because I want to keep the usage as simple as possible), I stumbled upon this page: Cpp convinient Lua Wrapper Class. This very nice piece of code is just what I needed.

So I say a big thanks to the guys of the yag2002 group who made their source available. I had to change some stuff because I use my own memory manager within lua (yes, my own lua_alloc function) and I don't use the STL. So, I had to get rid of those iterators.

Finally, I was able to test it within one of my games.

But there are still some things to do:

1. I don't want to use only one huge lua script but want to be able to use several small scripts. So I have to write a wrapper class, that can handle this and to which I pass the functions available.

2. The class functions are directly passed to the lua_state which is bad because I want to "manage" those functions without having to load any script beforehand. So I have to write a function manager class to which I may register any function with in and out parameters.

3. Whenever I load a script that I want to execute, I have to "attach" all functions that I have registered within the function manager class to the script (unless I find an easy way to "extract" the needed functions and pass only those).

4. I have to be able to get an "identifier" into lua which helps me to access the "right" C++ class instance of an object in my game.

So, to give you an example of what I would like to do:

Imagine I have a Button Class. I want to attach a lua script to that button which is executed whenever the button is pressed (or have a _down and a _up lua function in the script). This means that the Lua script has to know *which* button function of which object has to be called (there might be 10 buttons with a different lua script for each of them).

Well... I have to think about this :)

Have fun
Sign in to follow this  


0 Comments


Recommended Comments

There are no comments to display.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now