Is there an ACTUAL luabind tutorial

This topic is 2753 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

Recommended Posts

Ive spent... countless.. COUNTLESS, hours attempting to learn luabind.. but there is Nothing out there... and if there is it is a minute amount of information...

What I would really kill for is a working example I could pick apart and make work for my needs.

What I am trying to do is expose a class so that I can call a function inside of it, passing an int and a string... My issue is that I have to pass in two maps to the creation of the class.. So I pretty much need to be able to pass in objects... but when ever I use luabind::gobals() I get exception problems

So what I wanted to know.. Is there any resource out there which will help me learn how to expose a class and pass objects to it.
(hmm, I mean pass object references, as I need to be able to access the data in them after the exposed class has modified them)

Share on other sites
I'm assuming the documentation isn't sufficient?

Share on other sites

I'm assuming the documentation isn't sufficient?

Not really... I am slowly getting a hold of it, but without other teams at my uni I wouldn't be able to do it.. the biggest thing I needed, luabind::globals has almost no info on it in the documentation, If I get to fully understand it I might make a guide (after this semester)

Share on other sites
The docs says luabind::globals() returns the global environment table, which is a luabind::object. Section 11 of the docs gives you a synopsis of luabind::object's interface. Is there anything else you need?

Share on other sites
for instance... I cannot find a way in hell to fix this error:

CompCompiler.cpp 1>g:\crsm-svn\luatesting\externallibraries\include\luabind\detail\call.hpp(293): error C2027: use of undefined type 'lua_State' 1> g:\crsm-svn\luatesting\externallibraries\include\lua.h(50) : see declaration of 'lua_State' 1> g:\crsm-svn\luatesting\externallibraries\include\luabind\detail\call.hpp(89) : see reference to function template instantiation 'int luabind::detail::invoke_normal<F,boost::mpl::vector3<T0,T1,T2>,Policies>(lua_State *,const luabind::detail::function_object &,luabind::detail::invoke_context &,const F &,Signature,const Policies &,boost::mpl::long_<N>,boost::mpl::true_)' being compiled 1> with 1> [ 1> F=luabind::detail::construct<construct_type,pointer,signature>, 1> T0=void, 1> T1=const luabind::adl::argument &, 1> T2=lua_State, 1> Policies=luabind::detail::null_type, 1> Signature=boost::mpl::vector3<void,const luabind::adl::argument &,lua_State>, 1> N=2 1> ] ......... ........

which is being caused by this class:
#pragma once #include <lua.hpp> #include <luabind/luabind.hpp> class CompCompiler { public: CompCompiler(); ~CompCompiler(); void setSomeData(int dataz); void setMoreData(bool statezzz); int getSomeData(){return(someData);}; bool getMoreData(){return(moreData);}; void setupLuaBinds(lua_State *L); private: int someData; bool moreData; }; 
implementation:
#include "CompCompiler.h" CompCompiler::CompCompiler() { someData = 2; moreData = true; } void CompCompiler::setupLuaBinds(lua_State *L) { luaL_openlibs(L); luabind::open(L); luabind::module(L) [ luabind::class_<CompCompiler>("CompCompiler") .def(luabind::constructor<lua_State>()) .def("setSomeData",&CompCompiler::setSomeData) .def("setMoreData", &CompCompiler::setMoreData) .def("getSomeData", &CompCompiler::getSomeData) .def("getMoreData", &CompCompiler::getMoreData) ]; lua_close(L); } CompCompiler::~CompCompiler() { } 

Now, the reason why I am getting this error is probably something trivial.. but as I have no knowledge in luabind I am hitting a brick wall.

I thought, hey maybe it's because inside of a constructor lua_state is unacceptable for some stupid reason, bummer, now my neat idea ain't gonna be as need as I wanted it to be, but when I changed my code (to what you see there) so that lua_state wasn't in the compiler, it was in a fully compiled class, it still gets the error -.-
so apparently atm luabind is angry at me for passing a lua_state... can you even pass a lua_state?

So I am stuck at a brick wall... I am trying to keep my LuaInstances class as abstract as possible (i.e. all it does is hold and distribute the states, the classes using them initiate their part in a given instance (yes I know, if I wanted to be fully abstract I would make a separate class for initiating the class being binded to luabind, but I can't be bothered) can you not do this?

I am trying to make it so that there are multiple instances of lua_state so that I can keep my lua states COMPLETLY seperate so that when who ever is writing the scripts, is writing the scripts, they only have access to a portion of the functions in my code for a given task.. I don't want somone who is changing key bindings having access to entity management -.-.. I considered namespaces, but people would (to the best of my knowledge) be able to access the functions/globals I don't want them having access to.

Share on other sites
btw, if anyone wants to try to help me, I get these more easy to read errors:

Error 1 error C2027: use of undefined type 'lua_State' g:\crsm-svn\luatesting\externallibraries\include\luabind\detail\call.hpp 293

Error 2 error C2664: 'void luabind::detail::construct_aux<Arity,T,Pointer,Signature>::operator ()(const luabind::adl::argument &,lua_State) const' : cannot convert parameter 2 from 'a1' to 'lua_State' g:\crsm-svn\luatesting\externallibraries\include\luabind\detail\call.hpp 294

Share on other sites
Your lua/luabind includes look a bit iffy. Read sections 4 and 5 of this.

Share on other sites
ive build a working program using these libraries before, I will though look at my other version which isn't statically linked

edit:

nope, that wasn't the problem, and both of these builds have worked in different situations

edit:
I think I know the problem, it is a static class, therefore accessing it's includes might cause derp

Share on other sites
turns out error is hear:
luabind::module(L) [ luabind::class_<CompCompiler>("CompCompiler") .def(luabind::constructor<lua_State>()) .def("setSomeData",&CompCompiler::setSomeData) .def("setMoreData", &CompCompiler::setMoreData) .def("getSomeData", &CompCompiler::getSomeData) .def("getMoreData", &CompCompiler::getMoreData) ];

 .def(luabind::constructor<lua_State>()) 

originally the constructor TRIED to accept a lua_state in the constructor, I changed. sigh... the error message didn't help me at all

edit:
lol one problem fixed, another pop's its head up

Share on other sites
seriously.. anybody out there with ANY knowledge of luabind PLEASE PLEASE help... I have no idea how it works and now I'm getting errors which are either me getting pissed off or luabind being a peice of *(@T... I have 2 lua states being held in a map... I used .find(instEnum)->second to access them.. but when ever I pass this back through a function it causes access violations

 First-chance exception at 0x0009facd in LuaInstances.exe: 0xC0000005: Access violation reading location 0xfeeeff32. Unhandled exception at 0x77df15ee in LuaInstances.exe: 0xC0000005: Access violation reading location 0xfeeeff32. 

I know its probably somthing so soo simple.. but I am dead.. luabind is making me want to murder ducklings

• Game Developer Survey

We are looking for qualified game developers to participate in a 10-minute online survey. Qualified participants will be offered a \$15 incentive for your time and insights. Click here to start!

• 15
• 21
• 22
• 11
• 25