@@ -738,6 +738,27 @@ int ObjectRef::l_get_attach(lua_State *L)
738
738
return 5 ;
739
739
}
740
740
741
+ // get_children(self)
742
+ int ObjectRef::l_get_children (lua_State *L)
743
+ {
744
+ GET_ENV_PTR;
745
+
746
+ ObjectRef *ref = checkobject (L, 1 );
747
+ ServerActiveObject *sao = getobject (ref);
748
+ if (sao == nullptr )
749
+ return 0 ;
750
+
751
+ const std::unordered_set<int > child_ids = sao->getAttachmentChildIds ();
752
+ int i = 0 ;
753
+ lua_createtable (L, child_ids.size (), 0 );
754
+ for (const int id : child_ids) {
755
+ ServerActiveObject *child = env->getActiveObject (id);
756
+ getScriptApiBase (L)->objectrefGetOrCreate (L, child);
757
+ lua_rawseti (L, -2 , ++i);
758
+ }
759
+ return 1 ;
760
+ }
761
+
741
762
// set_detach(self)
742
763
int ObjectRef::l_set_detach (lua_State *L)
743
764
{
@@ -2337,6 +2358,7 @@ luaL_Reg ObjectRef::methods[] = {
2337
2358
luamethod (ObjectRef, get_bone_position),
2338
2359
luamethod (ObjectRef, set_attach),
2339
2360
luamethod (ObjectRef, get_attach),
2361
+ luamethod (ObjectRef, get_children),
2340
2362
luamethod (ObjectRef, set_detach),
2341
2363
luamethod (ObjectRef, set_properties),
2342
2364
luamethod (ObjectRef, get_properties),
0 commit comments