   Control of Luabind objects
  Is it possible to ensure luabind always uses the same Luabind::object for any given C++ object?  I am having problems because luabind is creating new luabind::objects and returning those, without the information I attached to the “real” object.Example:--“entity” is the luabind::object created for the C++ objectentity.health= entity.health -1for child in entity.kids do —“kids” is an std::list exposed to LuaBindchild.health = child.health-1 –Can’t access this because luabind creates a new luabind::object and returns it, instead of returning the one I created and pushed the “health” value ontoendI would like to have a callback function LuaBind uses to get the actual luabind::object I created and pushed onto the stack when I added values.  Right now, any values I add to a luabind::object will get lost if a function returns an object, because a new empty luabind::object will be created.   
  Posting the C++ binding code, along with output and what you expect might be helpful as well.My inital thoughts however are that the objects you are adjusting aren't references to the real objects, so the object values are being copied to lua but never copied back again. I suspect there is a way around this but I can't be sure atm.   ;  Sorry, I should have explained that "health" is not a member of the Entity class.  Luabind allows you to add values to the object that don't exist in the C++ class.  So you can add "health", "mood", "ammo", and other gamic stuff that doesn't belong in the core engine.The problem is if I set these script values, and then call a function somewhere else that returns this entity, the returned luabind::object does not have all the script values I added to it, even though it corresponds to the same C++ object.I always use pointers for Entity objects.   ;  Here's another example.  The printed output, with one child in the entity kids, is:No NameJoeNo Name"name" is not a C++ class member.It seems a new luabind::object is created each time a C++ object is returned from a function?for child in self.kids doif child.name==nil thenPrint("No Name")child.name="Joe"Print(child.name)elsePrint(child.name)endendfor child in self.kids doif child.name==nil thenprint("No Name")elsePrint(child.name)endend;Here's another example.  The printed output, with one child in the entity kids, is:No NameJoeNo Name"name" is not a C++ class member.It seems a new luabind::object is created each time a C++ object is returned from a function?for child in self.kids doif child.name==nil thenPrint("No Name")child.name="Joe"Print(child.name)elsePrint(child.name)endendfor child in self.kids doif child.name==nil thenprint("No Name")elsePrint(child.name)endendWhat kind of std::list are you using for kids ? std::list<luabind::object> should work if its expose correctly to lua. If you are using something like std::list<Child> and then have the child class exposed to lua aswell you should get the problem you're having.   ;  The list is like this:class Entity{std::list<Entity*> kids;...(+some other shit)};;  I read the luabind documentation on object slicing.  I have my classes and binding set up as follows:class Objectclass Object_wrap : public Object, public luabind::wrap_base {};class Entity : public Objectclass Entity_wrap : public Entity, public luabind::wrap_base {};class Model : public Entityclass Model_wrap : public Entity, public luabind::wrap_base {};class_<Object,Object_wrap>("Object")class_<Entity,Entity_wrap,Object>("Entity")class_<Model,Model_wrap,Entity,Object>("Model")Is that all I have to do to make luabind consistently use the same luabind::object?  It doesn’t appear to have any effect.   ;  I don't know if this helps (I didn't read all the posts) but when doing classes in lua I have to put "self." infront of my class variables and then they are unique to each object. Its working a bit like the "this" pointer in c++. This may be something added by luabind.function AttackState:__init(fsm, memory)    AI.PathMoveState.__init(self, fsm, self)    self.memory = memory;    self.health = 100;   ...endThen in my other methods I can do self.health = self.health - 10; or whatever I need to do.;  The issue is talked about here:http://www.rasterbar.com/products/luabind/docs.html#slicingIt's documented, to the minimum extent that you could classify their vague description as "documentation".I'm pretty shocked that such a basic issue is apparently obscure knowledge.  This makes me question whether I should be using LuaBind at all.  This just tells me people never really get into any depth with it.   ;  This illustrates the problem nicely, except I am not even trying to add a Lua class onto the C++ class, I just want to preserve the Lua data:http://old.nabble.com/Slicing---Object-identity-problem-td30319053.html   