diff --git a/src/game/behaviors/exclamation_box.inc.c b/src/game/behaviors/exclamation_box.inc.c index bfc38408..c9a7b8ba 100644 --- a/src/game/behaviors/exclamation_box.inc.c +++ b/src/game/behaviors/exclamation_box.inc.c @@ -133,6 +133,7 @@ void exclamation_box_spawn_contents(struct Struct802C0DF0 *a0, u8 a1) { struct Object* luaSpawnedObject = NULL; if ((luaSpawnedObject = smlua_call_exclamation_box_hook(o, true)) != NULL) { + luaSpawnedObject->parentObj = o; // Allows spawned stars to work like it was a normal exclamation box (void *)smlua_call_exclamation_box_hook(luaSpawnedObject, false); return; } diff --git a/src/pc/lua/smlua_hooks.c b/src/pc/lua/smlua_hooks.c index 11b34cd3..b145277e 100644 --- a/src/pc/lua/smlua_hooks.c +++ b/src/pc/lua/smlua_hooks.c @@ -1842,11 +1842,13 @@ struct Object* smlua_call_exclamation_box_hook(struct Object* obj, bool write) { struct Object* returnObject = NULL; if (write) { returnObject = (struct Object*)smlua_to_cobject(L, 1, LOT_OBJECT); + if (!gSmLuaConvertSuccess || returnObject == NULL) { + LOG_LUA("Return value type is invalid for writeFunction: %d", lua_type(L, 1)); + continue; + } } lua_pop(L, 1); - if (!gSmLuaConvertSuccess) { return NULL; } - return returnObject; }