diff --git a/docs/lua/functions.md b/docs/lua/functions.md
index cf6d20e55..34edb92a2 100644
--- a/docs/lua/functions.md
+++ b/docs/lua/functions.md
@@ -454,7 +454,7 @@
- smlua_obj_utils.h
- - [spawn_object_sync](#spawn_object_sync)
+ - [spawn_sync_object](#spawn_sync_object)
@@ -8030,10 +8030,10 @@
-## [spawn_object_sync](#spawn_object_sync)
+## [spawn_sync_object](#spawn_sync_object)
### Lua Example
-`local ObjectValue = spawn_object_sync(behaviorId, modelId, x, y, z, objSetupFunction)`
+`local ObjectValue = spawn_sync_object(behaviorId, modelId, x, y, z, objSetupFunction)`
### Parameters
| Field | Type |
@@ -8043,13 +8043,13 @@
| x | number |
| y | number |
| z | number |
-| objSetupFunction | LuaFunction([Object](structs.md#Object)) |
+| objSetupFunction | LuaFunction() |
### Returns
[Object](structs.md#Object)
### C Prototype
-`struct Object* spawn_object_sync(enum BehaviorId behaviorId, enum ModelExtendedId modelId, f32 x, f32 y, f32 z, LuaFunction objSetupFunction);`
+`struct Object* spawn_sync_object(enum BehaviorId behaviorId, enum ModelExtendedId modelId, f32 x, f32 y, f32 z, LuaFunction objSetupFunction);`
[:arrow_up_small:](#)
diff --git a/src/pc/lua/smlua_functions_autogen.c b/src/pc/lua/smlua_functions_autogen.c
index f4fff1d2e..c85ee080d 100644
--- a/src/pc/lua/smlua_functions_autogen.c
+++ b/src/pc/lua/smlua_functions_autogen.c
@@ -5286,7 +5286,7 @@ int smlua_func_save_file_get_total_star_count(lua_State* L) {
// smlua_obj_utils.h //
///////////////////////
-int smlua_func_spawn_object_sync(lua_State* L) {
+int smlua_func_spawn_sync_object(lua_State* L) {
if(!smlua_functions_valid_param_count(L, 6)) { return 0; }
int behaviorId = smlua_to_integer(L, 1);
@@ -5302,7 +5302,7 @@ int smlua_func_spawn_object_sync(lua_State* L) {
LuaFunction objSetupFunction = smlua_to_lua_function(L, 6);
if (!gSmLuaConvertSuccess) { return 0; }
- smlua_push_object(L, LOT_OBJECT, spawn_object_sync(behaviorId, modelId, x, y, z, objSetupFunction));
+ smlua_push_object(L, LOT_OBJECT, spawn_sync_object(behaviorId, modelId, x, y, z, objSetupFunction));
return 1;
}
@@ -6121,7 +6121,7 @@ void smlua_bind_functions_autogen(void) {
smlua_bind_function(L, "save_file_get_total_star_count", smlua_func_save_file_get_total_star_count);
// smlua_obj_utils.h
- smlua_bind_function(L, "spawn_object_sync", smlua_func_spawn_object_sync);
+ smlua_bind_function(L, "spawn_sync_object", smlua_func_spawn_sync_object);
// sound_init.h
smlua_bind_function(L, "disable_background_sound", smlua_func_disable_background_sound);
diff --git a/src/pc/lua/smlua_obj_utils.c b/src/pc/lua/smlua_obj_utils.c
index 662a39e19..09dd0238a 100644
--- a/src/pc/lua/smlua_obj_utils.c
+++ b/src/pc/lua/smlua_obj_utils.c
@@ -8,8 +8,7 @@
#include "smlua_model_utils.h"
#include "pc/debuglog.h"
-
-struct Object* spawn_object_sync(enum BehaviorId behaviorId, enum ModelExtendedId modelId, f32 x, f32 y, f32 z, LuaFunction objSetupFunction) {
+static struct Object* spawn_object_internal(enum BehaviorId behaviorId, enum ModelExtendedId modelId, f32 x, f32 y, f32 z, LuaFunction objSetupFunction, bool doSync) {
const BehaviorScript* behavior = get_behavior_from_id(behaviorId);
if (behavior == NULL) {
LOG_ERROR("failed to find behavior %u", behaviorId);
@@ -28,7 +27,7 @@ struct Object* spawn_object_sync(enum BehaviorId behaviorId, enum ModelExtendedI
return NULL;
}
- if (!network_set_sync_id(obj)) {
+ if (doSync && !network_set_sync_id(obj)) {
obj->activeFlags = ACTIVE_FLAG_DEACTIVATED;
LOG_ERROR("failed to set sync id");
return NULL;
@@ -54,13 +53,24 @@ struct Object* spawn_object_sync(enum BehaviorId behaviorId, enum ModelExtendedI
}
}
- struct SyncObject* so = &gSyncObjects[obj->oSyncID];
- so->extendedModelId = modelId;
- so->o = obj;
+ if (doSync) {
+ struct SyncObject* so = &gSyncObjects[obj->oSyncID];
+ so->extendedModelId = modelId;
+ so->o = obj;
- struct Object* spawn_objects[] = { obj };
- u32 models[] = { loadedModelId };
- network_send_spawn_objects(spawn_objects, models, 1);
+ struct Object* spawn_objects[] = { obj };
+ u32 models[] = { loadedModelId };
+ network_send_spawn_objects(spawn_objects, models, 1);
+ }
return obj;
}
+
+struct Object* spawn_sync_object(enum BehaviorId behaviorId, enum ModelExtendedId modelId, f32 x, f32 y, f32 z, LuaFunction objSetupFunction) {
+ spawn_object_internal(behaviorId, modelId, x, y, z, objSetupFunction, true);
+}
+
+// this is too dangerous for now
+struct Object* spawn_non_sync_object(enum BehaviorId behaviorId, enum ModelExtendedId modelId, f32 x, f32 y, f32 z) {
+ spawn_object_internal(behaviorId, modelId, x, y, z, 0, false);
+}
\ No newline at end of file
diff --git a/src/pc/lua/smlua_obj_utils.h b/src/pc/lua/smlua_obj_utils.h
index a5068067d..e7db21124 100644
--- a/src/pc/lua/smlua_obj_utils.h
+++ b/src/pc/lua/smlua_obj_utils.h
@@ -4,6 +4,9 @@
#include "behavior_table.h"
#include "smlua_model_utils.h"
-struct Object* spawn_object_sync(enum BehaviorId behaviorId, enum ModelExtendedId modelId, f32 x, f32 y, f32 z, LuaFunction objSetupFunction);
+struct Object* spawn_sync_object(enum BehaviorId behaviorId, enum ModelExtendedId modelId, f32 x, f32 y, f32 z, LuaFunction objSetupFunction);
+
+// this is too dangerous for now
+//struct Object* spawn_non_sync_object(enum BehaviorId behaviorId, enum ModelExtendedId modelId, f32 x, f32 y, f32 z);
#endif