Getting Lua work

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

User avatar
Chjoodge_
Just popping in
Just popping in
Posts: 10
Joined: Mon Jan 29, 2007 15:30

Getting Lua work

Postby Chjoodge_ » Mon Jan 29, 2007 17:03

Hi, I got through the CEGUI basic tutorials, now I have a window with some buttons and I would like to implement scripting the interface with Lua.

Of course I referred to the tutorial on the wiki and altough it covers how to work with Lua, it is quite vague about the get-it-work part (at least for me to understand). Does including some headers do the job? Or have I to link some libraries and if so, which ones? I tried it for quite a while, but wasn't able to compile the project with LuaScriptingModule successfully.

I would be really grateful if someone could help me, or possibly cover the topic closer in the wiki. Thanks!

User avatar
Chjoodge_
Just popping in
Just popping in
Posts: 10
Joined: Mon Jan 29, 2007 15:30

Postby Chjoodge_ » Tue Jan 30, 2007 11:54

To be more specific, for starters: if I have downloaded the CEGUI 0.5.0 binaries for VC 7.0, do I already have everything I need, or do I have to download something else?

Pompei2
Home away from home
Home away from home
Posts: 489
Joined: Tue May 23, 2006 16:31

Postby Pompei2 » Tue Jan 30, 2007 23:09

afaik, you have everything included, just take a look if there are two dlls (tolua++ and lua or something like that)

User avatar
scriptkid
Home away from home
Home away from home
Posts: 1178
Joined: Wed Jan 12, 2005 12:06
Location: The Hague, The Netherlands
Contact:

Postby scriptkid » Wed Jan 31, 2007 13:03

Are you that you compiled all of the required cegui files? Can you double-check your premake file to have LUA_SCRIPT_MODULE set to 'true'?

If so, have a look which library names are created exactly and try to link to those.

If the wiki code does not compile, a change has run into it which should be reflected into this page. Please let us know.

Good luck!

User avatar
Chjoodge_
Just popping in
Just popping in
Posts: 10
Joined: Mon Jan 29, 2007 15:30

Postby Chjoodge_ » Thu Feb 01, 2007 15:40

Aha! I can compile and run a project using CEGUI+its LuaScriptingModule and I can compile and run a project using CEGUI+Ogre. The problem I was getting in compilation occured only in projects where I was trying to use all these three.

I am using CEGUI v0.5.0 and Ogre v.1.2.5.

I tried recompiling OgreGUIRenderer with the CEGUI 0.5.0. Here's what I did:

- Downloaded Ogre Source for MS VS 7.
- In the Ogre source, I replaced all the header files in Dependencies/include/CEGUI with header files from CEGUI.
- In the Ogre source, I replaced all the .lib files in Dependencies/lib/CEGUI with .lib files from CEGUI.
- Recompiled OgreGUIRenderer project in Ogre Source, which gave me new OgreGUIRenderer_d.lib and .dll.
- Compiled a CEGUI+Ogre+Lua project with this new OgreGUIRenderer_d.lib, which succeeded. I wasn't able to compile such a project with the OgreGUIRenderer_d.lib from the Ogre SDK I downloaded.

So the program at least compiles now. However, it dies on this line:

Code: Select all

CEGUI::SchemeManager::getSingleton().loadScheme((CEGUI::utf8*)"TaharezLookSkin.scheme");

with this run-time error:

Code: Select all

Entry point of subscribeScriptedEvent@EventSet@CEGUI@@UAE?AV?$RefPtr@VConnectionInterface@Event@CEGUI@@@2@ABVString@2@0@Z
in CEGUIBased_d.dll wasn't found.


...although I use OgreGUIRenderer_d.dll which fell out of the OgreGUIRenderer recompilation, e.g. it is the one coupled with the new OgreGURenderer_d.lib I use.

These are few last lines of the log:

Code: Select all

...
01/02/2007 16:23:58 (InfL2)   ---> Start of definition for widget look 'TaharezLook/LargeVerticalScrollbar'.
01/02/2007 16:23:58 (InfL2)   ---< End of definition for widget look 'TaharezLook/LargeVerticalScrollbar'.
01/02/2007 16:23:58 (InfL1)   ===== Look and feel parsing completed =====
01/02/2007 16:23:59 (Error)   Exception: DynamicModule::DynamicModule - Failed to load module 'CEGUIFalagardBase_d': Uvedená procedura nebyla nalezena.

...where the last line is saying (in Czech) that given function was not found.

Anybody any hints?

Pompei2
Home away from home
Home away from home
Posts: 489
Joined: Tue May 23, 2006 16:31

Postby Pompei2 » Thu Feb 01, 2007 22:47

Make sure you use the same CRT veresion (regarding debug/release and multithreading) on every compilation you did. Make sure that if you use one debug dll, all other dlls and your project is in debug mode too. These are my hints, hope they help.

User avatar
Chjoodge_
Just popping in
Just popping in
Posts: 10
Joined: Mon Jan 29, 2007 15:30

Postby Chjoodge_ » Fri Feb 02, 2007 12:10

Thanks, I didn't notice I compiled Ogre with multithreaded CRT and my project with singlethreaded one. However, although I recompiled Ogre for singlethreaded CRT, it was still no help.

Is there someone who combines CEGUI 0.5.0 with Ogre 1.2.x and who has got CEGUI Lua scripting working? If so, were there any steps (like recompiling something, I wouldn't be afraid of some hacks neither ;)) neccessary to get this working?

User avatar
Chjoodge_
Just popping in
Just popping in
Posts: 10
Joined: Mon Jan 29, 2007 15:30

Postby Chjoodge_ » Fri Feb 16, 2007 18:04

Just wanted you to know that with Ogre 1.4 and Cegui 0.5 my program now runs just fine.

tenpebbles
Just popping in
Just popping in
Posts: 2
Joined: Mon May 26, 2008 03:51

Postby tenpebbles » Mon May 26, 2008 04:26

I'm relatively new to using Lua for CEGUI. Actually, I haven't actually used Lua for CEGUI at all, at least not yet.

To make things short, the wiki states the following:

Code: Select all

#include "CEGUILua.h"

CEGUI::YourRendererOfChoice* renderer = new YourRendererOfChoice;
CEGUI::LuaScriptModule* script_module = new CEGUI::LuaScriptModule();
new CEGUI::System( renderer, script_module );


In this code snippet, CEGUI::System is initialized with the parameter types CEGUI::Renderer* and CEGUI::LuaScriptModule*. However, the only candidate for the second parameter type would be CEGUI::ResourceProvider*.

How could 'script_module' serve as a working second argument to the class CEGUI::System? Since it is a CEGUI::LuaScriptModule*, it can be upcasted to a CEGUIScriptModule... but that's as far as it goes.

Regardless, I've tried compiling, but I get the following error, as expected:

Code: Select all

error: no matching function for call to CEGUI::System::System(CEGUI::OgreCEGUIRenderer*&, CEGUI::LuaScriptModule*&)

candidates are:
...
CEGUI::System::System(CEGUI::Renderer*, CEGUI::ResourceProvider*, CEGUI::XMLParser*, CEGUI::ScriptModule*, const CEGUI::String&, const CEGUI::String&)

User avatar
scriptkid
Home away from home
Home away from home
Posts: 1178
Joined: Wed Jan 12, 2005 12:06
Location: The Hague, The Netherlands
Contact:

Postby scriptkid » Mon May 26, 2008 07:15

Hi and welcome :),

i guess that the wiki page is outdated. The scripting module should now be set (after creating System!). This is a code snippet from Demo8:

Code: Select all

// create a script module.
LuaScriptModule* scriptmod = new LuaScriptModule();

// tell CEGUI to use this scripting module
System::getSingleton().setScriptingModule(scriptmod);

// execute the demo8 script which controls the rest of this demo
System::getSingleton().executeScriptFile("demo8.lua");


[EDIT] I checked the most recent System code, and the constructor accepts the scripting module at a different argument:

Code: Select all

System(Renderer* renderer, ResourceProvider* resourceProvider = 0, XMLParser* xmlParser = 0, ScriptModule* scriptModule = 0, const String& configFile = "", const String& logFile = "CEGUI.log");

So you should call:

Code: Select all

new CEGUI::System( renderer, 0, script_module );

For details, see the code:
http://crayzedsgui.svn.sourceforge.net/ ... iew=markup
[/EDIT]

HTH.
Check out my released snake game using Cegui!

tenpebbles
Just popping in
Just popping in
Posts: 2
Joined: Mon May 26, 2008 03:51

Postby tenpebbles » Mon May 26, 2008 08:47

Thanks! I was confused whether I was missing something.

Using Code::Blocks with GCC:
The code compiles, but when I include this line

Code: Select all

'CEGUI::LuaScriptModule *mpLuaScriptModule = new CEGUI::LuaScriptModule();'


... I get the following linking errors.

Code: Select all

resolving vtable for Ogre::Exception by linking to __imp___ZTVN4Ogre9ExceptionE
undefined reference to `_imp___ZN5CEGUI15LuaScriptModuleC1Ev
|undefined reference to `_imp___ZN5CEGUI15LuaScriptModuleC1Ev


Without that line, everything compiles fine(kinda self explanatory though).

I've set global variables CEGUI_HOME and CEGUI_SOURCE to 'cegui' and 'cegui/include'. The linker points to the subdirectory 'cegui/bin' and 'cegui/lib'.

The sources I'm using are of CEGUI 5.0 and 6.0. I've tested both but I get the exact linking error, which leads me to believe I really did leave out something.

However, I don't really know what that something is. It's not a library or a dynamic linking library provided explicitly in the provided CEGUI packs.

I've looked into the file CEGUILua.h(I've included this as well for the compiler) and I see the line 'class CEGUILUA_API LuaScriptModule'. According to the preprocessing directive '#define CEGUILUA_API __declspec(dllimport)', the compiler reads it as 'class __declspec(dllimport) LuaScriptModule'. I'm still guessing at this point, but it seems like that macro is supposed to import the dll; the compiler might not have located the dll, which could be the source of my problem.

The phrase 'CEGUILUA_API' to me suggests that I should import CEGUILua, but since I have already done so... I ruled that out.

I'm talking mostly to myself at this point, but hopefully it might end up helping. I can't really use Lua without getting past this step.


Return to “Help”

Who is online

Users browsing this forum: No registered users and 20 guests