Scripted Lua Exposure With toLua++

Last week I talked about adding Lua exposure to the engine. I am currently thinking of going a step further and having my game update be written primarily in Lua and having all supporting functionality in C. That is the current theory, but since I have never done that before I reserve the right to change my mind. In order to make that happen I need to do a few things

  1. Find a way of automating C/C++ exposure to Lua
  2. Add in a flow that allows me to initialize and update the “lua world” of the game
  3. Add a place to clean this up

1. Automating C/C++ Lua exposure
What options? Which should I use?
Well based on my new attitude of just get things done, I did a quick search for Lua and Box2D and it looks like someone already used tolua++ to expose Box2D to lua. In my new non-scientific evaluation mentality that is “good enough for me” and I will attempt to do the same. One small catch though…I actually have to download and install SCons to make tolua++. I appreciate sites with compiled binaries but I will have to chalk this one up to learning. So what should be a simple download and use turns into a half hour of downloading applications:

  • Download tolua++ source (needs SCons to build)
  • Download and install python (needed for SCons)
  • Download and install SCons

For me I thought this would really work after this but it turns out that for me the scons version 1.1.0 windows installer doesn’t actually create a scons executable but instead just installs the scripts for python. I love the internet because someone else ran into this and pointed out I just need python and the scripts in my path. Great! What a short list:

  1. Setup vsvars32
  2. Add Python and Python scripts to path
  3. Add lua to INCLUDE
  4. Add lua to LIBPATH
  5. No lua.lib file or lualib.lib file. I was about to dig into this when I found the proj file! I gave up on getting it to compile from the commandline. This was just adding the lua path and renaming the lib in the project settings and I was good to go. Had I noticed this it would have saved me a 1/2 hour.

Now I am just ready to try and use it and I am out of time. So at the end of the day, again rather than writing code I end up just downloading and installing applications in preparation of writing code! Knowing that this will save hundreds to thousands of functions being generated makes it all worthwhile.

I’m also finding that link times on my laptop are in the order of minutes. I also hope that this can help my turn around time or I may have to look at buying a new laptop (or looking at my compiler settings). With the rate thigns are going it is going to be challenging to hit my goal of getting lua integrated, but there is no harm in trying.

On the bright side, tonights endeavor did move my engine one small step forward. When I get Lua up and running I’ll post a screenshot.

Advertisement
This entry was posted in Technical and tagged , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s