Using an existing Lua state

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

laurens
Just popping in
Just popping in
Posts: 5
Joined: Wed Jun 02, 2010 07:08

Using an existing Lua state

Postby laurens » Tue Aug 30, 2011 17:28

Hello,

I am trying to use the Lua scripting module provided with CEGUI. The engine I am using, Leadwerks, also uses Lua (5.1) as the scripting language and thus I have access to an already open lua_State although I can only access it in the form of a byte pointer. My goal is to get that lua_State working with CEGUI. The initialization is as follows:

Code: Select all

_ceguiScriptModule = &CEGUI::LuaScriptModule::create(reinterpret_cast<lua_State*> (lua));


While this does compile, the run immediatly fails:

The application failed with exit code -1073741515 (0xc0000135).
This could indicate that no required .dll was found in the PATH.


Yet I do have CEGUILuaScriptModule_d.dll on the path (and linked to libCEGUILuaScriptModule_d as well). Are there any additional DLL's I need to have on the path or is not possible to cast the byte pointer to the lua_State like I am doing? If this is not possible, are there any objections against having multiple states open at the same time?

Thanks!

Jamarr
CEGUI MVP
CEGUI MVP
Posts: 812
Joined: Tue Jun 03, 2008 23:59
Location: USA

Re: Using an existing Lua state

Postby Jamarr » Tue Aug 30, 2011 18:39

Please make sure you follow the Forum Usage Guidelines when posting; in particular, please make sure to include the contents of your CEGUI.log file or if it was not generated make note of that. This log provides us with information regarding your environment, ex: CEGUI version, os, compiler, modules, so that we can better assist you.

laurens wrote:While this does compile, the run immediatly fails:

The application failed with exit code -1073741515 (0xc0000135).
This could indicate that no required .dll was found in the PATH.


Yet I do have CEGUILuaScriptModule_d.dll on the path (and linked to libCEGUILuaScriptModule_d as well). Are there any additional DLL's I need to have on the path


I have never seen this error before on these forums, so I am inclined to believe that this is unrelated to CEGUI. Have you tried excluding CEGUI from the build to see if the same error occurs? Usually when a missing CEGUI DLL is the issue CEGUI will throw a CEGUI-specific exception and log the exception information (name of missing module) in the CEGUI.log file. This looks more like a missing system or system-ish (.net, etc.) DLL. You might want to try dependencywalker to figure out which DLLs are missing.

I am trying to use the Lua scripting module provided with CEGUI. The engine I am using, Leadwerks, also uses Lua (5.1) as the scripting language and thus I have access to an already open lua_State although I can only access it in the form of a byte pointer. My goal is to get that lua_State working with CEGUI. The initialization is as follows:

Code: Select all

_ceguiScriptModule = &CEGUI::LuaScriptModule::create(reinterpret_cast<lua_State*> (lua));


is not possible to cast the byte pointer to the lua_State like I am doing?


The easiest way to determine this would be to simply comment out this line of code and re-build and re-run the application to see if this is the cause of the crash; I highly doubt it is. As far as attaching CEGUI to an existing lua_State it should be possible using this method, however I am not sure what you mean by byte pointer; if you are talking an opaque pointer or a void*, so long as it is pointing to the actual lua_State object, this should be fine.

are there any objections against having multiple states open at the same time?


Afaik having two open lua states is perfect fine as lua encapsulates the entire state within the lua_State object; eg there are no singleton/global state conflicts between contexts. The only caveat of course is that they cannot directly communicate with each other; you would need to mediate any necessary communication.
If somebody helps you by replying to your thread, upvote him/her as a thanks! Make sure to include your CEGUI.log and everything you tried when posting! And remember that we are not magicians!

laurens
Just popping in
Just popping in
Posts: 5
Joined: Wed Jun 02, 2010 07:08

Re: Using an existing Lua state

Postby laurens » Tue Aug 30, 2011 19:13

Hi Jamarr,

Thanks for the swift reply! There is no log because the application crashes before it even gets a chance to initialize. If I exclude CEGUI from the build then everything is well, in fact:

Code: Select all

byte* lua = GetLuaState(); // This engine command returns a byte* (not a void or opaque pointer)


Code: Select all

    _ceguiRenderer = &CEGUI::OpenGLRenderer::create();
    _ceguiRenderer->enableExtraStateSettings(true);
    CEGUI::System::create(*_ceguiRenderer, 0, 0, 0, _ceguiScriptModule, "GUI/CEGUI.config");


This runs perfectly fine, but

Code: Select all

    _ceguiRenderer = &CEGUI::OpenGLRenderer::create();
    _ceguiRenderer->enableExtraStateSettings(true);
    _ceguiScriptModule = &CEGUI::LuaScriptModule::create(reinterpret_cast<lua_State*> (lua));
    CEGUI::System::create(*_ceguiRenderer, 0, 0, 0, _ceguiScriptModule, "GUI/CEGUI.config");


this crashes with the aforementioned error.

Here is the relevant excerpt from the log when I run the code with the script module creation commented out:

30/08/2011 21:01:13 (Std) ---- Version 0.7.5 (Build: Nov 19 2010 Debug Microsoft Windows g++ 4.4.0 32 bit) ----
30/08/2011 21:01:13 (Std) ---- Renderer module is: CEGUI::OpenGLRenderer - Official OpenGL based 2nd generation renderer module. TextureTarget support enabled via FBO extension. ----
30/08/2011 21:01:13 (Std) ---- XML Parser module is: CEGUI::ExpatParser - Official expat based parser module for CEGUI ----
30/08/2011 21:01:13 (Std) ---- Image Codec module is: SILLYImageCodec - Official SILLY based image codec ----
30/08/2011 21:01:13 (Std) ---- Scripting module is: None ----


Thanks again!

laurens
Just popping in
Just popping in
Posts: 5
Joined: Wed Jun 02, 2010 07:08

Re: Using an existing Lua state

Postby laurens » Tue Aug 30, 2011 19:23

DependencyWalker figured it out for me, I was missing both lua_d.dll and tolua++_.dll from my path. It is running now!

Thanks!


Return to “Help”

Who is online

Users browsing this forum: Bing [Bot] and 16 guests