Questions tagged [luabind]

Library to make bindings between C++ and Lua

Luabind is a library that helps you create bindings between C++ and Lua. It has the ability to expose functions and classes, written in C++, to Lua. It will also supply the functionality to define classes in lua and let them derive from other lua classes or C++ classes. Lua classes can override virtual functions from their C++ baseclasses. It is written towards Lua 5.x, and does not work with Lua 4.

177 questions
3
votes
1 answer

How to bind a std::map to Lua with LuaBind

I'm trying to expose my std::map as a class property to Lua. I've set this method for my getter and setter: luabind::object FakeScript::GetSetProperties() { luabind::object table = luabind::newtable(L); …
MahanGM
  • 2,352
  • 5
  • 32
  • 45
3
votes
1 answer

using a pointer from a C++ object, to another C++ object, to modify member variables, from Lua

How do you get a reference to a C++ object, from another C++ object, inside a Lua script? I don't really know how to summarize that in words properly, so let me elaborate with a Lua example first: function doSomething() compo = a:getComponent() …
Shel Soloa
  • 104
  • 7
3
votes
1 answer

Luabind - Unable to find Lua library

I am trying to compile Luabind for my project with little success. I have the lua directory (containing src, the makefile etc) as a sibling of luabind. I have LUA_PATH set to the /my/dirs/lua folder. I am running OSX Server 10.4. When I go into…
ipburbank
  • 151
  • 1
  • 8
3
votes
1 answer

passing a lua table from C++ to .Lua script

I have spent the past 6 hours trying to solve this ! and i coulnt get anywhere :s I want to be able to create a lua table in a c++ file and then pass that to a lua script file, which has the following lua function: function MTable (t) local n=#t …
PeacefulSoul
  • 55
  • 1
  • 7
2
votes
2 answers

Custom constructor in Luabind

I'm using Luabind to bind a C++ API to Lua. I have some objects that cannot be created directly, but rather must be created on another thread. I'm currently handling this by defining a "static" member called create that yields until the object is…
Xtapolapocetl
  • 613
  • 5
  • 21
2
votes
2 answers

Luabind: return_stl_iterator for std::map

Is there any way to return an STL iterator to a std::map (e.g. std::map)? Luabind definition for an example class: class_( "SomeClass" ) .property( "items", &SomeClass::GetItems, return_stl_iterator ) GetItems()…
stschindler
  • 937
  • 7
  • 28
2
votes
1 answer

LuaBind c++ error handler when calling a Lua function

I am little newbie in C++ scripting but I know some things. I'm compiling a plugin that use a function to call an Lua callback using the LuaBind, but the client crashes when function doesn't exists on main.lua, also I'm trying to add an error…
mazda7
  • 31
  • 4
2
votes
2 answers

How do I make sure that the (luabind) lua state is good after an error has occurred?

When lua code causes an exception, luabind will leave an error message on the stack for me to collect. I am wondering how to guarantee that the lua stack will be in a sensible state after I have handled the exception: The examples I've found tells…
Magnus Hoff
  • 21,529
  • 9
  • 63
  • 82
2
votes
3 answers

How should I bind lua functions to C++ functions?

I have a class called Entity, which has many functions like onPickup, onDrop, onUse etc. What I want to do is, write a script that defines all of these functions and make them callable from the C++ functions. So the functions defined in C++ would…
toujamaru
  • 111
  • 1
  • 5
2
votes
2 answers

How to bind overloaded functions with Luabind?

I am writing a game engine in c++ which will provide Lua scripting ( for which wrapping I am using Luabind ) and I am having some problems to bind overloaded functions. Namely: I have am overloaded function : void setGlobalPosition(const Vec3&…
Patryk
  • 22,602
  • 44
  • 128
  • 244
2
votes
1 answer

Returning tables of objects from C++, adopt policy

Using luabind, I create a table of objects from C++ luabind::object create_table(lua_State *L) { luabind::object result = luabind::newtable(L); int index = 1; for ( ... ) { lua_Object *o = new lua_Object( ... ); result[ index ++ ] =…
sylefeb
  • 21
  • 2
2
votes
2 answers

Need help to get started integrating lua in c++ game

I need help integrating lua in my game. I know only a little about lua, since I just started learning scripting (in general). I've read tutorials about lua, but most of them are only tell me how to bind lua in c++ code (which I've managed to do that…
Radi
  • 103
  • 1
  • 4
2
votes
2 answers

Using C++ functions in Lua/Binding

so basically I'm trying to find a way to use C++ functions in Lua that are not lua_CFunctions (don't return and int and take a lua_State as a parameter). Basically your regular old C++ function. The catch, though, is I'm trying to find a way to do…
kageB
  • 21
  • 3
2
votes
2 answers

MSVC 10 + Luabind + std::vector == refuse to compile

So, I have a code, that compiled on MSVC 9 and some previous (dunno how far back it goes...), GCC, MingW, GCC on Mac... But one line, does not compile on MSVC: class_< vector >("LayerList") .def(constructor<>()) .def("GetCount",…
speeder
  • 6,197
  • 5
  • 34
  • 51
2
votes
0 answers

Getting list of attributes of a luabind class created in Lua

Lua classes can be created using the OO system that Luabind exposes to Lua: http://www.rasterbar.com/products/luabind/docs.html#defining-classes-in-lua class 'MyClass' function MyClass:__init() self.a1 = true self.a2 =…
safe_malloc
  • 824
  • 2
  • 12
  • 29
1 2
3
11 12