Home - Forums - Documentation - Gallery - Bugs
(work in progress 2)
m (work in progress 3)
Line 12: Line 12:
-
== Let us begin ==
+
== Setup your enviroment==
The very first step is download, complie and install LUA. You can get it from the official site:
The very first step is download, complie and install LUA. You can get it from the official site:
[http://www.lua.org/ LUA homepage]
[http://www.lua.org/ LUA homepage]
-
This tutorial use the LUA 5.1 version.
+
You can find here also some precompiled version, you can use them, when you want.
 +
This tutorial uses the LUA 5.1 version.
-
The next step is setting up an axternal CS project within your enviroment. Don't follow to set up your project as a dynamic link library, and the neccessary CS and LUA libs. The concrete steps depending from your IDE and operating system. ( This is a so called "professional" tutorial. Professional tutorials are not just C++ masters , but I assume, you can set up this project without any external help.)
+
The next step is setting up an external CS project within your enviroment. Don't forget to set up your project as a dynamic link library, and the neccessary CS and LUA libs and include director, . The concrete steps depending from your IDE and operating system. ( This is a so called "professional" tutorial. Professional tutorials are not just for C++ masters , but I assume, you can set up this project without any external help.)
 +
 
 +
 
 +
== Start coding ==
 +
 
 +
Crystal Space uses the ''iScript'' interface to communicate with scripting languages, so we have to implement this interface to integrate LUA. So we include some CS headers:
 +
 
 +
<pre>
 +
#include <ivaria/script.h>
 +
#include <iutil/eventh.h>
 +
#include <iutil/comp.h>
 +
#include <csutil/csinput.h>
 +
#include <iutil/string.h>
 +
</pre>
 +
 
 +
Then we introduce a new namespace to avoid name conflicts, in Crystal Space way:
 +
<pre>
 +
CS_PLUGIN_NAMESPACE_BEGIN(cslua) {
 +
</pre>
 +
 
 +
This macro creates for us a new cslua namespace.
 +
 
 +
Now we can to start

Revision as of 19:34, 25 January 2007


Contents

Creating a LUA plugin

Short indtroduction

In this tutorial we will create a plugin for integrating Lua. That means, you can reach the the whole CS API with LUA scripting. Note, you can any SWIG supported language integrate easily into Crystal Space. In that case, when SWIG is new for you, please have a look at the project here:

SWIG homepage

A note about the history of this plugin. The source itself is just partially my work. The original code written by Brandon Ehle in 1999. I started to update the code, but the greater part of the code written by Mildred. Many thanks, Mildred!


Setup your enviroment

The very first step is download, complie and install LUA. You can get it from the official site:

LUA homepage

You can find here also some precompiled version, you can use them, when you want. This tutorial uses the LUA 5.1 version.

The next step is setting up an external CS project within your enviroment. Don't forget to set up your project as a dynamic link library, and the neccessary CS and LUA libs and include director, . The concrete steps depending from your IDE and operating system. ( This is a so called "professional" tutorial. Professional tutorials are not just for C++ masters , but I assume, you can set up this project without any external help.)


Start coding

Crystal Space uses the iScript interface to communicate with scripting languages, so we have to implement this interface to integrate LUA. So we include some CS headers:

#include <ivaria/script.h>
#include <iutil/eventh.h>
#include <iutil/comp.h>
#include <csutil/csinput.h>
#include <iutil/string.h>

Then we introduce a new namespace to avoid name conflicts, in Crystal Space way:

CS_PLUGIN_NAMESPACE_BEGIN(cslua) {

This macro creates for us a new cslua namespace.

Now we can to start

| Article | Discussion | View source | History |