diff --git a/autogen/convert_functions.py b/autogen/convert_functions.py index 36be2fb96..6e3941a99 100644 --- a/autogen/convert_functions.py +++ b/autogen/convert_functions.py @@ -97,7 +97,7 @@ override_allowed_functions = { "src/engine/level_script.h": [ "area_create_warp_node" ], "src/game/ingame_menu.h": [ "set_min_dialog_width", "set_dialog_override_pos", "reset_dialog_override_pos", "set_dialog_override_color", "reset_dialog_override_color", "set_menu_mode", "create_dialog_box", "create_dialog_box_with_var", "create_dialog_inverted_box", "create_dialog_box_with_response", "reset_dialog_render_state", "set_dialog_box_state", ], "src/audio/seqplayer.h": [ "sequence_player_set_tempo", "sequence_player_set_tempo_acc", "sequence_player_set_transposition", "sequence_player_get_tempo", "sequence_player_get_tempo_acc", "sequence_player_get_transposition", "sequence_player_get_volume", "sequence_player_get_fade_volume", "sequence_player_get_mute_volume_scale" ], - "src/pc/network/sync_object.h": [ "sync_object_is_initialized", "sync_object_is_owned_locally" ] + "src/pc/network/sync_object.h": [ "sync_object_is_initialized", "sync_object_is_owned_locally", "sync_object_get_object" ] } override_disallowed_functions = { diff --git a/autogen/lua_definitions/functions.lua b/autogen/lua_definitions/functions.lua index 4497620a2..e5d0c0248 100644 --- a/autogen/lua_definitions/functions.lua +++ b/autogen/lua_definitions/functions.lua @@ -11722,6 +11722,13 @@ function surface_has_force(surfaceType) -- ... end +--- @param syncId integer +--- @return Object +--- Retrieves an object from a sync ID +function sync_object_get_object(syncId) + -- ... +end + --- @param syncId integer --- @return boolean --- Checks if a sync object is initialized using a `syncId` diff --git a/docs/lua/functions-6.md b/docs/lua/functions-6.md index c065ffed0..782c9c004 100644 --- a/docs/lua/functions-6.md +++ b/docs/lua/functions-6.md @@ -7413,6 +7413,29 @@ Checks if a surface has force
+## [sync_object_get_object](#sync_object_get_object) + +### Description +Retrieves an object from a sync ID + +### Lua Example +`local ObjectValue = sync_object_get_object(syncId)` + +### Parameters +| Field | Type | +| ----- | ---- | +| syncId | `integer` | + +### Returns +[Object](structs.md#Object) + +### C Prototype +`struct Object* sync_object_get_object(u32 syncId);` + +[:arrow_up_small:](#) + +
+ ## [sync_object_is_initialized](#sync_object_is_initialized) ### Description diff --git a/docs/lua/functions.md b/docs/lua/functions.md index d08ed79d7..84db1e21c 100644 --- a/docs/lua/functions.md +++ b/docs/lua/functions.md @@ -2115,6 +2115,7 @@
- sync_object.h + - [sync_object_get_object](functions-6.md#sync_object_get_object) - [sync_object_is_initialized](functions-6.md#sync_object_is_initialized) - [sync_object_is_owned_locally](functions-6.md#sync_object_is_owned_locally) diff --git a/src/pc/lua/smlua_functions_autogen.c b/src/pc/lua/smlua_functions_autogen.c index 75dc114e2..96b53d8d5 100644 --- a/src/pc/lua/smlua_functions_autogen.c +++ b/src/pc/lua/smlua_functions_autogen.c @@ -35167,6 +35167,23 @@ int smlua_func_surface_has_force(lua_State* L) { // sync_object.h // /////////////////// +int smlua_func_sync_object_get_object(lua_State* L) { + if (L == NULL) { return 0; } + + int top = lua_gettop(L); + if (top != 1) { + LOG_LUA_LINE("Improper param count for '%s': Expected %u, Received %u", "sync_object_get_object", 1, top); + return 0; + } + + u32 syncId = smlua_to_integer(L, 1); + if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "sync_object_get_object"); return 0; } + + smlua_push_object(L, LOT_OBJECT, sync_object_get_object(syncId), NULL); + + return 1; +} + int smlua_func_sync_object_is_initialized(lua_State* L) { if (L == NULL) { return 0; } @@ -37204,6 +37221,7 @@ void smlua_bind_functions_autogen(void) { smlua_bind_function(L, "surface_has_force", smlua_func_surface_has_force); // sync_object.h + smlua_bind_function(L, "sync_object_get_object", smlua_func_sync_object_get_object); smlua_bind_function(L, "sync_object_is_initialized", smlua_func_sync_object_is_initialized); smlua_bind_function(L, "sync_object_is_owned_locally", smlua_func_sync_object_is_owned_locally); diff --git a/src/pc/network/sync_object.h b/src/pc/network/sync_object.h index ad46afe26..203aa9da6 100644 --- a/src/pc/network/sync_object.h +++ b/src/pc/network/sync_object.h @@ -59,6 +59,7 @@ void sync_object_init_field_with_size(struct Object *o, void* field, u8 size); struct SyncObject* sync_object_get(u32 syncId); struct SyncObject* sync_object_get_first(void); struct SyncObject* sync_object_get_next(void); +/* |description|Retrieves an object from a sync ID|descriptionEnd| */ struct Object* sync_object_get_object(u32 syncId); /* |description|Checks if a sync object is initialized using a `syncId`|descriptionEnd| */ bool sync_object_is_initialized(u32 syncId);