[solved] lua binding new c++ function

For help with anything that CEGUI doesn't offer straight out-of-the-box, e.g.:
- Implementation of new features, such as new Core classes, widgets, WindowRenderers, etc. ...
- Modification of any existing features for specific purposes
- Integration of CEGUI in new engines or frameworks and writing of new plugins (Renderer, Parser, ...) or modules

Moderators: CEGUI MVP, CEGUI Team

User avatar
spracle
Not too shy to talk
Not too shy to talk
Posts: 34
Joined: Tue Aug 24, 2010 07:29

[solved] lua binding new c++ function

Postby spracle » Mon Oct 18, 2010 06:58

hi~
In lua, i can call the function"createListboxTextItem(..)" to new a listboxTextItem;
Now, i created a new class called FormattedListboxItem inherited from ListboxTextItem, and I want to call the function"createFormattedListboxItem()" to new a formattedListboxItem in lua.
Question is how to achive that?

ps:
in <required.h> ,i added this:

Code: Select all

FormattedListboxTextItem* ceguiLua_createFormattedListboxTextItem(const String& text,const HorizontalTextFormatting format,uint item_id, void* item_data, bool disabled, bool auto_delete)

in <required.h>:

Code: Select all

FormattedListboxTextItem* ceguiLua_createFormattedListboxTextItem(const String& text, const HorizontalTextFormatting format,uint item_id, void* item_data, bool disabled, bool auto_delete)
{
   return new FormattedListboxTextItem(text,format,item_id,item_data,disabled,auto_delete);
}

Of course ,that's not enough! lua_CEGUI.cpp is automatically generated,and i don't know how?

So,what exactly do I need to do? Hope, someone help me ,and thanks in andvance, :roll:
Last edited by spracle on Thu Nov 25, 2010 07:36, edited 1 time in total.

User avatar
Kulik
CEGUI Team
Posts: 1382
Joined: Mon Jul 26, 2010 18:47
Location: Czech Republic
Contact:

Re: lua binding new c++ function

Postby Kulik » Mon Oct 18, 2010 10:37

It's generated by tolua++... Please see cegui/cegui/src/ScriptingModules/LuaScriptModule/package/README and cegui/cegui/src/ScriptingModules/LuaScriptModule/package/HelperFunctions.pkg :wink:

User avatar
spracle
Not too shy to talk
Not too shy to talk
Posts: 34
Joined: Tue Aug 24, 2010 07:29

Re: lua binding new c++ function

Postby spracle » Tue Oct 19, 2010 02:57

thank you,kulik :D I did this:
execute cegui/cegui/src/ScriptingModules/LuaScriptModule/package/make.dat
But I got this:

Code: Select all

E:\kk2\code\contrib\cegui\CEGUI-0.7.1\cegui\src\ScriptingModules\LuaScriptModule
\package>tolua++cegui_D.exe -o ..\lua_CEGUI.cpp -L exceptions.lua CEGUI.pkg

** tolua internal error: [string "exceptions.lua"]:1: attempt to index global 'e
xceptionDefs' (a nil value).
stack traceback:
        [string "tolua: embedded Lua code 23"]:6: in main chunk

E:\kk2\code\contrib\cegui\CEGUI-0.7.1\cegui\src\ScriptingModules\LuaScriptModule
\package>pause


Here's make.dat :

Code: Select all

tolua++cegui_D.exe -o ..\lua_CEGUI.cpp -L exceptions.lua CEGUI.pkg
pause


What's the Problem :oops: ??

User avatar
spracle
Not too shy to talk
Not too shy to talk
Posts: 34
Joined: Tue Aug 24, 2010 07:29

Re: lua binding new c++ function

Postby spracle » Wed Oct 20, 2010 09:35

I deleted "-L exceptions.lua", it worked ,and Lua_CEGUI.cpp was Generated automatically.

But there are still two questions:
1. In lua_CEGUI.cpp, no interface at all like "createFormattedListboxTextItem()" ;
2. toluabind.c and toluabind.h also should be generated automatically , but how ?

Anyone help me?

User avatar
spracle
Not too shy to talk
Not too shy to talk
Posts: 34
Joined: Tue Aug 24, 2010 07:29

Re: lua binding new c++ function

Postby spracle » Thu Nov 25, 2010 07:35

It appears that 0.7.2 lacked some pkg files,and now problems were solved :D


Return to “Modifications / Integrations / Customisations”

Who is online

Users browsing this forum: No registered users and 3 guests