Would it be possible to suggest some new API functions?
A function which returns specific Attributes of an Object
in cpp:
Code
void LUA_GetObjectInfo( lua_State *L ) {
int id = luaL_checkint( L, 1 );
const char* field = luaL_checkstring(L, 2);
GameObjDbStructEx* obj = g_ObjectData->GetObj( id );
if (obj==NULL || strcmp(field, "")==0) {
lua_pushnil( L );
return;
}
if (strcmp(field, "name")==0) {
lua_pushstring( L, obj->GetName() );
return;
}
if (strcmp(field, "note")==0) {
lua_pushstring( L, obj->Note );
return;
}
lua_pushnil( L );
return;
}
Display More
Working with metatables would probably be better but i currently don't know how to implement something like that.
=> Less accesses to GetObj(id) -> better performance (GetObj is O(log(n)) )
=> strcmp not necessarily needed.
=> cleaner API due to Inheritance.
Pro:
- database Addons (charplan, dailynotes, dungeonloots, itempreview, ...) don't need an own database anymore (except maybe an ID-List) -> less memory usage
- faster than using own databases
- no database updates needed
- combined fields possible (e.g. HP/MP/etc.): Addon devs don't have to know the formula
Contra:
- lots of programming work
- current addons obviously don't use that function