mirror of
https://github.com/edubart/otclient.git
synced 2025-10-17 04:53:27 +02:00
rename item data to count, add function to get current class name in lua
This commit is contained in:
@@ -48,7 +48,8 @@ void LuaInterface::init()
|
||||
|
||||
// register LuaObject, the base of all other objects
|
||||
registerClass<LuaObject>();
|
||||
bindClassMemberGetField<LuaObject>("use_count", &LuaObject::getUseCount);
|
||||
bindClassMemberFunction<LuaObject>("getUseCount", &LuaObject::getUseCount);
|
||||
bindClassMemberFunction<LuaObject>("getClassName", &LuaObject::getClassName);
|
||||
}
|
||||
|
||||
void LuaInterface::terminate()
|
||||
@@ -958,7 +959,7 @@ void LuaInterface::pushObject(const LuaObjectPtr& obj)
|
||||
new(newUserdata(sizeof(LuaObjectPtr))) LuaObjectPtr(obj);
|
||||
|
||||
// set the userdata metatable
|
||||
getGlobal(Fw::mkstr(obj->getLuaObjectName(), "_mt"));
|
||||
getGlobal(Fw::mkstr(obj->getClassName(), "_mt"));
|
||||
assert(!isNil());
|
||||
setMetatable();
|
||||
}
|
||||
|
@@ -61,8 +61,8 @@ public:
|
||||
/// @note each userdata of this object on lua counts as a reference
|
||||
int getUseCount();
|
||||
|
||||
/// Returns the class name used in Lua
|
||||
virtual std::string getLuaObjectName() const {
|
||||
/// Returns the derived class name, its the same name used in Lua
|
||||
virtual std::string getClassName() const {
|
||||
// TODO: this could be cached for more performance
|
||||
return Fw::demangleName(typeid(*this).name());
|
||||
}
|
||||
|
Reference in New Issue
Block a user