Hey, can anyone point me out to a simple, user-friendly, tutorial on how to integrate C++ functions into Lua?
I heard CEGUI uses a custom build of tolua++ so that's why I'm posting here.
Thing is as a newbie in software programming I have no friggin' idea on how to get MY c++ functions into Lua. I mean how did CEGUI do it? logger:logEvent works fine and it's a C++ bind, isn't it?
On this post (http://www.cegui.org.uk/phpBB2/viewtopic.php?f=2&t=5204&p=24883&hilit=tolua) they discuss something like "execute cegui/cegui/src/ScriptingModules/LuaScriptModule/package/make.dat", is tolua++ a command line executable?
Using tolua++ with C++?
Moderators: CEGUI MVP, CEGUI Team
- aaron1a12
- Not too shy to talk
- Posts: 29
- Joined: Wed Sep 29, 2010 21:46
- Location: Miami, Florida, USA
Using tolua++ with C++?
I hate BBCode pls enable <b>HTML</b>
Re: Using tolua++ with C++?
aaron1a12 wrote:I have no friggin' idea on how to get MY c++ functions into Lua.
This is a tolua++ issue, not a CEGUI issue. If you want to learn how to use tolua++ then you should read the tolua++ manual.
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!
Re: Using tolua++ with C++?
I got demo8.lua working with my CEGUI learning framework. But tolua++ is to hard to understand. You know sometimes a creator is a good student, sometimes is a good teacher. This is the first case. Both Tutorials:Creating_a_scriptable_interface_using_CEGUI and tolua++ manual are bad for common understanding. So is there any way to call my C++ function or change C++ variable from demo8.lua without using tolua++ with only current CEGUI and Lua interaction?
helper to newbies
"i help you, dear newbie
but nobody helps me!"
"i help you, dear newbie
but nobody helps me!"
Re: Using tolua++ with C++?
I really wish I could help you but I think Jamarr is right in that you will probably not get any answers here. Have you looked for any dedicated tolua++ communities, or gone to some of the major lua hubs? Indeed a boring answer to get, I know, but perhaps better than silence...
Re: Using tolua++ with C++?
THIS HELPED A LOT!!!
http://www.cegui.org.uk/wiki/index.php/ ... _Interface
But I didn't used namespace, classes, typedefs, variables, constants, just tried to do simple job, I tried to call C function from Lua
Then I created .pkg file, but only one .pkg, not two .pkg files like in tutorial. Tutorial more complex.
Then I compiled .pkg using .bat file. Now I'm thinking to integrate .bat into prebuild step of MSBuild of Visual Studio 2010. But I want this step only if .pkg or .hpp file changed.
Then I attached this "Sample_FirstWindow_reg.hpp" to my code. And used this glue-creator function in initialization step:
Screenshot
Then I click File -> Exit it calls Lua handler function, which calls C function, which calls glfwCloseWindow(), which marks to break main event loop.
Procgen Studio is program name, 0-1D Function is my future software developer company name.
http://www.cegui.org.uk/wiki/index.php/ ... _Interface
But I didn't used namespace, classes, typedefs, variables, constants, just tried to do simple job, I tried to call C function from Lua
Code: Select all
// C function
bool MenuItemExit_OnButtonClick(const CEGUI::EventArgs& pEventArgs)
{
glfwCloseWindow();
return true;
}
Code: Select all
-- Lua code
function MenuItemExitHandler(args)
return MenuItemExit_OnButtonClick(args);
end
...initialization skipped due its not related to subject...
-- subscribe required events, i can place here "MenuItemExit_OnButtonClick" directly, but i will need to handle it in Lua in future, save project before close, etc
winMgr:getWindow("root/MenuitemExit"):subscribeEvent("Clicked", "MenuItemExitHandler")
Then I created .pkg file, but only one .pkg, not two .pkg files like in tutorial. Tutorial more complex.
Then I compiled .pkg using .bat file. Now I'm thinking to integrate .bat into prebuild step of MSBuild of Visual Studio 2010. But I want this step only if .pkg or .hpp file changed.
Code: Select all
REM Create lua interface
tolua++cegui_Static.exe -n Sample_FirstWindow -H Sample_FirstWindow_reg.hpp -o Sample_FirstWindow_reg.cpp Sample_FirstWindow.pkg
pause
Then I attached this "Sample_FirstWindow_reg.hpp" to my code. And used this glue-creator function in initialization step:
Code: Select all
#include "Sample_FirstWindow_reg.hpp"
...
void initialiseSample()
{
using namespace CEGUI;
// create a script module.
LuaScriptModule& scriptmod(LuaScriptModule::create());
// tell CEGUI to use this scripting module
System::getSingleton().setScriptingModule(&scriptmod);
tolua_Sample_FirstWindow_open( scriptmod.getLuaState() );
// execute the procgen.lua script which controls the rest of this demo
System::getSingleton().executeScriptFile("procgen.lua");
}
Screenshot
Then I click File -> Exit it calls Lua handler function, which calls C function, which calls glfwCloseWindow(), which marks to break main event loop.
Procgen Studio is program name, 0-1D Function is my future software developer company name.
helper to newbies
"i help you, dear newbie
but nobody helps me!"
"i help you, dear newbie
but nobody helps me!"
Who is online
Users browsing this forum: No registered users and 9 guests