Page 1 of 1

[solved] lua binding new c++ function

Posted: Mon Oct 18, 2010 06:58
by spracle
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:

Re: lua binding new c++ function

Posted: Mon Oct 18, 2010 10:37
by Kulik
It's generated by tolua++... Please see cegui/cegui/src/ScriptingModules/LuaScriptModule/package/README and cegui/cegui/src/ScriptingModules/LuaScriptModule/package/HelperFunctions.pkg :wink:

Re: lua binding new c++ function

Posted: Tue Oct 19, 2010 02:57
by spracle
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: ??

Re: lua binding new c++ function

Posted: Wed Oct 20, 2010 09:35
by spracle
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?

Re: lua binding new c++ function

Posted: Thu Nov 25, 2010 07:35
by spracle
It appears that 0.7.2 lacked some pkg files,and now problems were solved :D