Page 1 of 1

Problem with LUA not having acces to CEGUI objects.

Posted: Wed Jan 03, 2007 23:12
by jtracy
I am just trying to get a simple demo working where I have a button that I create in a layout and have it call a LUA function when clicked. The problem is that I cannot access anything in CEGUI through LUA. I get the following error when trying to execute a script that tries to log something.

script:
function luabtn_clicked(e)
local we = CEGUI.toWindowEventArgs(e)
we.window:setText("handled from Lua");
end
local logger = CEGUI.Logger:getSingleton()
logger:logEvent( ">>> Init script says hello" )

error:
03/01/2007 18:04:57 (Error) Exception: Unable to execute Lua script file: 'scripts/script.lua'

[string "scripts/Login.lua"]:6: attempt to index global `CEGUI' (a nil value)

03/01/2007 18:04:57 (Error) Exception: System::executeScriptFile - An exception was thrown during the execution of the script file.

I think it is something simple that I am missing, but I cannot figure out what is causing the problem.

Posted: Thu Jan 04, 2007 03:30
by Trentin
The only thing I can think of is are you creating the LuaScriptModule? I create it just before I create the CEGUI::System object.

Code: Select all

pGUIScriptModule = new CEGUI::LuaScriptModule(...);
pGUISystem = new CEGUI::System(...);


Maybe that'll help...

Posted: Thu Jan 04, 2007 15:07
by jtracy
I was creating the LuaScriptModule, but because I was using delta3D I had to get creative and find a way to pass that in on the creating of the System which ofcourse did not work. It does work however if I use the setScriptingModule method. Thanks for the help.