[Solved] Integrating CEGUI Lua with existing Lua

For help with general CEGUI usage:
- Questions about the usage of CEGUI and its features, if not explained in the documentation.
- Problems with the CMAKE configuration or problems occuring during the build process/compilation.
- Errors or unexpected behaviour.

Moderators: CEGUI MVP, CEGUI Team

bull
Just popping in
Just popping in
Posts: 6
Joined: Sat Jun 30, 2007 17:02

[Solved] Integrating CEGUI Lua with existing Lua

Postby bull » Wed Jul 04, 2007 16:19

Hi,

My C++ project already uses both Lua and CEGUI (+ Ogre, ODE, SDL, etc) and I'd like to combine CEGUI's scripting ability with the one I've already set up. I don't want to end up with two Lua "dialects" (and namespaces) in the same project. The project runs on Win32, 32 bit Linux and 64 bit linux, hopefully with OS X support to follow.

Currently we use Lua 5.1.2 whereas CEGUI seems to be built against 5.0.? (the svn copy of CEGUI's ./configure certainly refuses to compile the Lua module on my machine.)

I know that the CEGUI Lua scripting module provides a way to access it's Lua "state" (struct lua_State *) so hopefully I can just alter my code to use CEGUI's state instead of my own.

My question is really about organising the project in the least painful way. I need to distribute a source package to various developers and artists working on the project. I can see two options:

1) Ask all the developers to downgrade to the older Lua version, checkout CEGUI from svn and do ./configure --enable-toluacegui. This seems like a lot to ask of the other users. Or is it possible to compile CEGUI with the newer version of Lua? And how would I go about it?

2) The other possibility (as I see it) is to import both CEGUI and Lua 5.0.x into my source tree and compile them as part of my project (i.e. make vendor branches). My project doesn't even use autotools yet (and I'm basically unfamiliar) so I envisage this being tricky (for me, easier for everyone else). Does anyone have any tips for getting CEGUI to compile in these conditions?

Obviously I may be missing something so if there's another way to do it I'd be glad to hear about it!

Any help/pointers gratefully received.

--
Bull
http://sourceforge.net/projects/bugrdspace
Last edited by bull on Tue Jul 10, 2007 19:05, edited 1 time in total.

User avatar
Taharez
Not too shy to talk
Not too shy to talk
Posts: 30
Joined: Mon Mar 07, 2005 19:06
Location: Sweden
Contact:

Postby Taharez » Thu Jul 05, 2007 19:37

The easiest way to use the same lua state is probably just to give your scripting systems' instance to the cegui script module like so:

Code: Select all

CEGUI::LuaScriptModule* scriptModule = new CEGUI::LuaScriptModule( mScriptSystem->getState() );

As for using Lua 5.1, there is a post on the forum about upgrading, it doesn't require that much work to get it working.

bull
Just popping in
Just popping in
Posts: 6
Joined: Sat Jun 30, 2007 17:02

Postby bull » Fri Jul 06, 2007 16:56

Taharez: thanks for the tip, I'll definitely do it that way.

Appologies but I can't find the post you mention.

I think I've managed to get it to compile myself though. I had to fixup the Lua installation as it's a bit munged currently. Installing Lua 5.1.2 from source sets the permissions incorrectly. You need to edit the Makefile and comment out the INSTALL_EXEC and INSTALL_DATA lines involving $(CP) and comment the ones using $(INSTALL) back in. (I've sent a bug report about that, and they're fixing it.) You also need to copy <build-dir>/etc/lua.pc into it's usual install directory of /usr/local/lib/pkgconfig and set the permissions correctly (again they're fixing that).

After that I just changed the test in <cegui-build-dir>/acinclude.m4 near [CEGUI_CHECK_LUA] to be 'lua >= 5.0 lua < 6.0' instead of 'lua >= 5.0 lua < 5.1' and then ./configure seemed to build the cegui Lua module ok (but with, possibly unrelated, errors compiling Demo8). I'll report back when I know more. I also had to use the patch provided by ldb (see http://www.cegui.org.uk/phpBB2/viewtopic.php?t=2678 ).

User avatar
Taharez
Not too shy to talk
Not too shy to talk
Posts: 30
Joined: Mon Mar 07, 2005 19:06
Location: Sweden
Contact:

Postby Taharez » Fri Jul 06, 2007 18:10

bull wrote:Appologies but I can't find the post you mention.

This was the thread I referred to, good luck.

bull
Just popping in
Just popping in
Posts: 6
Joined: Sat Jun 30, 2007 17:02

Postby bull » Fri Jul 06, 2007 19:44

Thanks! Yep that worked. The only other thing I needed was one extra line in src/Makefile.am:

Code: Select all

@@ -42,6 +42,7 @@
                       CEGUISchemeManager.cpp \
                       CEGUIScheme_xmlHandler.cpp \
                       CEGUIScriptModule.cpp \
+                      CEGUIScriptWindowHelper.cpp \
                       CEGUISize.cpp \
                       CEGUIString.cpp \
                       CEGUISubscriberSlot.cpp \


Return to “Help”

Who is online

Users browsing this forum: No registered users and 10 guests