I somehow missed this topic, so sorry I didn't post earlier.
I know Lua quite well and I think it would be great for it to be Transport Empires's scripting language. I'm not for creating some home-brewn solution, because it can hardly be better than lua and it would mean a lot of additional effort.
Lua is small and fast scripting languale written in C. It was built for embedding into C applications and it does it's job great.
Here are the Lua's features:
- It's implements a state machine (object) which keeps the context until deleted. So, you can perform many separate operations with it in all possible means. This includes parsing files or C string as code or any operations described below.
- You can read and write values to the lua's enviroment
- You can register C functions with lua and then call them from within the script. The functions must use lua api to get arguments and return values, but othervise they are ordinary C functions.
- You can call lua functions from outside, using the api. This includes passing arguments and reading results. Could be good for callbacks. The functions to use this way are fully regular lua functions, no tricks.
- You can export C pointers into lua as 'light userdata' variables. Such pointers become regular lua variables. Then, you can pass it into C functions of your choice to manipulate it. Lua can't go directly into a C object's attributes, but you can create access functions. Also, lua objects are hash tables and anything can serve as index, so you can easily bind lua data to c objects.
- You can also allocate an object with lua api. Such object becomes 'full userdata' variable inside lua. The benefit is that such object can have lua functions attached as methods. Also, such object is garbage-collected by lua, unlike light userdata, where the pointer is programmer's responsibility.
- You can load dynamic libs (.dll and .so) as lua modules. I don't know this in detail, only that it works. The api of such module must be made with lua-ready functions.
I hope I didn't miss anything. I'd really like to see lua with TE.
Now, it's quite easy to learn the language itself, there are lots of good resources:http://www.lua.org/pil/
Programming in Lua online bookhttp://lua-users.org/wiki/TutorialDirectory
Detailed tutorials about every aspect of the language. The whole site is very useful.http://www.lua.org/manual/5.1/
Manual. Not good for learning, but good reference.
Unfortunately, using lua with C is documented quite poorly. I learned mostly from the reference manual. I also found some article on gamedev, but it's not there anymore. I can't provide any materials right now, you'll have to search. But, knowing this, I created a demo showing all the features I wrote about. There are both source and binary, the lua lib is bundled.
Edit: I forgot, there is a simple game engine which is built to run lua scripts, http://www.love2d.org/
. It's a great demo how lua can work in action and also how fast it is. There are some games on the forums http://love2d.org/forum/
, so grab one and check it out!
Edit2: Just found out that ogre's built-in gui system, CEGui, has a Lua binding! Check out this tutorial http://www.cegui.org.uk/wiki/index.php/Getting_Started_with_Lua_and_CEGUI
. It's dated 2005, so I'm sure the thing is in working state today. With the TE game facilities being exported or implemented in Lua, you could actually create the whole Gui, including the tools, with just lua.
I hope to hear TE will use Lua