I am developing using MacOS with PlayDate C SDK 2.5.0 and I was trying to figure out how to use this functions. My idea was to put there a Lua table with some callbacks and then do something like this:
my_object *foo = init();
my_object->lua_userval = pd->lua->pushObject(my_object, CLASSNAME_MY_OBJECT, 1);
// ...
int mo_set_luadata(lua_State *L) {
LuaUDObject *lua_userval;
my_object *mo = (my_object*)pd->lua->getArgObject(1, CLASSNAME_MY_OBJECT, &lua_userval);
// second argument is table and also top of stack if I understand correctly
pd->lua->setUserValue(lua_userval, 1);
}
static void some_callback(my_object *mo) {
pd->lua->pushObject(my_object, CLASSNAME_MY_OBJECT, 1);
pd->lua->getUserValue(mo-> lua_userval, 1);
pd->lua->callFunction("my_object.callback");
}
But it seems work incorrectly or I am doing something terribly wrong