Jump to content
  • Advertisement
Sign in to follow this  

Luabind - .property getter not working

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

If you intended to correct an error in the post then please contact us.

Recommended Posts


I just began learning luabind and I'm trying to get the .property getter to work but with no luck.

When I set the getter to a lua variable and try to print it... it prints the function address instead of the value.

I made a simple program to test it here:

using namespace std;
class Test
int stack;
Test(){stack = 0;}
void addStack(){stack++;}
void sayStack(){cout << stack << endl;}
int getStack(){return stack;}
void setStack(int stk){stack = stk;}
int main()
lua_State* l = luaL_newstate();
//Bind the class to lua
luabind::module(l) [
.def("sayStack", &Test::sayStack)
.def("addStack", &Test::addStack)
.property("stack", &Test::getStack, &Test::setStack)
//Create a Test class
Test ts;
//Make lua global test equal to local ts
luabind::globals(l)["test"] = &ts;
//Should make rs = stack,
//Say stack and then print the rs(print same as sayStack)
"rs = test.stack\n"
//Close lua
return 0;

The output here:

function: 005FC568

I tried the setter and it works just fine.... its just the getter that doesnt work.

Does anybody have an idea why and how to get the getter to work?

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!