Closed JMLX42 closed 10 years ago
Assuming you're using LuaGlue as it was intended, lookAt should just be a C++ class member (or getter/setter). then you can set that in C++ when ever you want, and lua will see the value you set.
The thing is as you can see in the sample code the self.lookAt is created/set from Lua and is dynamic. My LuaScript C++ class is a generic class, it just provides methods a "script" will require but has no script-specific bindings. The goal is to be able to create Lua scripts without any specific C++ code.
To explain a bit more the process:
So declaring explicit bindings in my C++ is not an option. I think I'll create a LuaScript::getInstance() method that returns the C++-side stub object used for binding. In other words the actual Lua "self" of my script object. This way my Lua code can get a script instance and set some values on it.
Still, it would be useful to have C++ LuaGlueClass::set()/get() methods just like the LuaGlueClass::invoke ones... What do you think?
I suppose. But really, this funky wrapper class you have is just weird :P
Ok, this should be implemented now (in ad75202)
Some api additions:
You can fetch globals now via: glue.getGlobal<TYPE>("name")
Get LuaGlueClass<CLASS>*
via: glue.getClass<CLASS>("name")
get properties via: glue_class->getProperty<TYPE>("name", obj)
set properties via: glue_class->setProperty("name", obj, value)
other changes in ad75202 include some std::string handling improvements, and const fixes.
Hello,
I need to be able to set values from my C++ code. Considering 'rotate' is my "script" class:
I would like to be able to do the same thing as
self.lookAt = ...
but from my C++ code. My goal is to be able to init. my object with values set by other scripts/my C++ code:How can we do this?