No this won’t be another of those Lua posts. I did some research to decide which scripting language I will integrate into a project. Of course the number one stop for me was the Lua website. Since everyone is talking about Lua when it comes to scripting it was clear that I had to check this out. Lua was also mentioned by Jonathan S. Harbour in his book Advanced 2D game programming(the DirectX.DevPak was published in this book so check it out) so I read carefully through that chapter and tried the examples. Lua is very good, I thought first. Using just the globals through my C++ application worked very well. After that I thought how it would be extend it to let the Lua scripts calculate NPC movement. This worked also very well. Everything was just fine. It took me some time to get it working with my application but it worked well. There was just one point which was not what I expected. In Lua it’s possible to pass parameters from C++ to the Lua functions and receive the function result back in C++. It’s also possible to access C++ functions through Lua. These have to be registered first but that’s no problem. It works vice versa. But integration is sometimes very time consuming. I accidently stepped over GameMonkeyand this scripting language changed everything. Why? Watch the example below:
#include "gmThread.h" // game monkey script int main(int argc, char* argv[]) { gmMachine machine; machine.ExecuteString("print(`Hello world`);"); return 0; }
This is the simplest script ever. You just need to include the GameMonkey header files and you are done. Simple isn’t it? Further examples showed that it’s more simple to integrate into existing applications compared to Lua, and that’s an important point for me since I don’t want to loose too much time on integration. You will argue now that in most cases you do integration only once but if you take a closer look at GameMonkey and the examples shipped with the SDK you soon will realize that nearly everything is a bit easier than in Lua.
There is a simple explanation for this. If you read carefully the introduction on the GameMonkey website you will notice that the developers of GameMonkey worked intensively with Lua and decided to make some things better so GameMonkey was born. I’m currently way too busy with my game project and my daily job so maybe in near future some GameMonkey tutorials will follow up. Stay tuned.
Here are some useful resources:
Great articles on how to get started with GameMonkey on www.gamedev.net:
http://www.gamedev.net/reference/programming/features/gmscript1/
http://www.gamedev.net/reference/programming/features/gmscript2/
A comparison between JScript and GameMonkey:
http://www.chriscowherd.com/2006/08/microsoft-jscript-vs-gamemonkey.html