Jump to content
  • Advertisement
Sign in to follow this  
thrawn42

Problem binding structure members with LuaBind

This topic is 4234 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'm in the beginnings of utilizing Lua and decided awhile back to go with LuaBind. Several of my in-game classes utilize a struct to store member data (mostly for readability). A hypothetical example:

struct Stats
{
   int m_power;
};

class Character
{
    Stats m_stats;
};


And I bind the class and the members I want to access in Lua like this:

luabind::module(p_lua->GetLuaState())
[
    luabind::class_<Character>("Character")
	.def_readwrite("Power", &Character::m_stats.m_power)
];


My problem is that when I go to bind the members of such a structure as members of the actual Lua class using the above I get the following compilation error:

c:\documents and settings\owner\my documents\game\character.cpp(30) error C2228: left of '.m_power' must have class/struct/union
c:\documents and settings\owner\my documents\game\character.cpp(30) error C2780: 'luabind::class_<T> &luabind::class_<T>::def_readwrite(const char *,D Character::* ,const GetPolicies &,const SetPolicies &)' : expects 4 arguments - 2 provided
        with
        [
            T=Character
        ]
        c:\game projects\luabind\luabind\luabind\class.hpp(1006) : see declaration of 'luabind::class_<T>::def_readwrite'
        with
        [
            T=Character
        ]
c:\documents and settings\owner\my documents\game\character.cpp(30) : error C2780: 'luabind::class_<T> &luabind::class_<T>::def_readwrite(const char *,D Character::* ,const GetPolicies &)' : expects 3 arguments - 2 provided
        with
        [
            T=Character
        ]
        c:\game projects\luabind\luabind\luabind\class.hpp(990) : see declaration of 'luabind::class_<T>::def_readwrite'
        with
        [
            T=Character
        ]


Is this some sort of include/lib ordering error? 2, 3, or 4 parameter overload on def_readwrite()? Just what is going on here that I'm missing? Perhaps I'm not allowed to bind in this fashion? Am I actually forced to have to type object.structure.member in the actual Lua script as opposed to just object.member?

Share this post


Link to post
Share on other sites
Advertisement
It think that I am stuck.

It appears that for def_readwrite(), LuaBind is expecting the second parameter to be of type 'MemberType BoundClass::*'.

Any takers on ways to circumvent this?

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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!