From 0c42836b81c6b10a6d5d9db813ec6036293c7dde Mon Sep 17 00:00:00 2001
From: PeachyPeach <72323920+PeachyPeachSM64@users.noreply.github.com>
Date: Sun, 27 Feb 2022 23:31:59 +0100
Subject: [PATCH 1/6] Added support for X and Y buttons; Re-mapped B button to
the actual B button for controllers; Moved particleFlags code so lua scripts
can spawn Mario particles with 'before Mario update' and 'after Mario update'
hooks (#5)
---
docs/lua/constants.md | 4 ++++
include/PR/os_cont.h | 4 ++++
include/sm64.h | 2 +-
src/game/mario.c | 1 -
src/game/object_list_processor.c | 4 +++-
src/pc/configfile.c | 6 +++++-
src/pc/configfile.h | 2 ++
src/pc/controller/controller_keyboard.c | 2 ++
src/pc/controller/controller_sdl1.c | 2 ++
src/pc/controller/controller_sdl2.c | 2 ++
src/pc/djui/djui_panel_controls_n64.c | 2 ++
src/pc/lua/smlua_constants_autogen.c | 6 +++++-
12 files changed, 32 insertions(+), 5 deletions(-)
diff --git a/docs/lua/constants.md b/docs/lua/constants.md
index f58f21ccf..68b5b41f5 100644
--- a/docs/lua/constants.md
+++ b/docs/lua/constants.md
@@ -1769,6 +1769,8 @@
- CONT_TYPE_NORMAL
- CONT_TYPE_VOICE
- CONT_UP
+- CONT_X
+- CONT_Y
- D_CBUTTONS
- D_JPAD
- L_CBUTTONS
@@ -1780,6 +1782,8 @@
- START_BUTTON
- U_CBUTTONS
- U_JPAD
+- X_BUTTON
+- Y_BUTTON
- Z_TRIG
diff --git a/include/PR/os_cont.h b/include/PR/os_cont.h
index b266aa71f..e732f41ce 100644
--- a/include/PR/os_cont.h
+++ b/include/PR/os_cont.h
@@ -123,6 +123,8 @@ typedef struct {
#define CONT_A 0x8000
#define CONT_B 0x4000
+#define CONT_X 0x0040
+#define CONT_Y 0x0080
#define CONT_G 0x2000
#define CONT_START 0x1000
#define CONT_UP 0x0800
@@ -140,6 +142,8 @@ typedef struct {
#define A_BUTTON CONT_A
#define B_BUTTON CONT_B
+#define X_BUTTON CONT_X
+#define Y_BUTTON CONT_Y
#define L_TRIG CONT_L
#define R_TRIG CONT_R
#define Z_TRIG CONT_G
diff --git a/include/sm64.h b/include/sm64.h
index ab806a770..7f310ed4d 100644
--- a/include/sm64.h
+++ b/include/sm64.h
@@ -428,7 +428,7 @@
#define VALID_BUTTONS (A_BUTTON | B_BUTTON | Z_TRIG | START_BUTTON | \
U_JPAD | D_JPAD | L_JPAD | R_JPAD | \
- L_TRIG | R_TRIG | \
+ L_TRIG | R_TRIG | X_BUTTON | Y_BUTTON | \
U_CBUTTONS | D_CBUTTONS | L_CBUTTONS | R_CBUTTONS )
#define C_BUTTONS (U_CBUTTONS | D_CBUTTONS | L_CBUTTONS | R_CBUTTONS )
diff --git a/src/game/mario.c b/src/game/mario.c
index 09176a8fd..ed76b12ff 100644
--- a/src/game/mario.c
+++ b/src/game/mario.c
@@ -1467,7 +1467,6 @@ copyPlayerGoto:;
* Handles Mario's input flags as well as a couple timers.
*/
void update_mario_inputs(struct MarioState *m) {
- m->particleFlags = 0;
if (m->playerIndex == 0) { m->input = 0; }
u8 localIsPaused = (m->playerIndex == 0) && (sCurrPlayMode == PLAY_MODE_PAUSED || m->freeze > 0);
diff --git a/src/game/object_list_processor.c b/src/game/object_list_processor.c
index d63bbdf65..cb635a63f 100644
--- a/src/game/object_list_processor.c
+++ b/src/game/object_list_processor.c
@@ -282,14 +282,16 @@ void bhv_mario_update(void) {
vec3f_copy(gMarioState->marioBodyState->torsoPos, gMarioState->pos);
}
+ gMarioState->particleFlags = 0;
smlua_call_event_hooks_mario_param(HOOK_BEFORE_MARIO_UPDATE, gMarioState);
u32 particleFlags = 0;
s32 i;
particleFlags = execute_mario_action(gCurrentObject);
- gCurrentObject->oMarioParticleFlags = particleFlags;
smlua_call_event_hooks_mario_param(HOOK_MARIO_UPDATE, gMarioState);
+ particleFlags |= gMarioState->particleFlags;
+ gCurrentObject->oMarioParticleFlags = particleFlags;
// Mario code updates MarioState's versions of position etc, so we need
// to sync it with the Mario object
diff --git a/src/pc/configfile.c b/src/pc/configfile.c
index 49356f5a2..5e446f55b 100644
--- a/src/pc/configfile.c
+++ b/src/pc/configfile.c
@@ -62,7 +62,9 @@ unsigned int configEnvVolume = MAX_VOLUME;
// Keyboard mappings (VK_ values, by default keyboard/gamepad/mouse)
unsigned int configKeyA[MAX_BINDS] = { 0x0026, 0x1000, 0x1103 };
-unsigned int configKeyB[MAX_BINDS] = { 0x0033, 0x1002, 0x1101 };
+unsigned int configKeyB[MAX_BINDS] = { 0x0033, 0x1001, 0x1101 };
+unsigned int configKeyX[MAX_BINDS] = { 0x0025, 0x1002, VK_INVALID };
+unsigned int configKeyY[MAX_BINDS] = { 0x0032, 0x1003, VK_INVALID };
unsigned int configKeyStart[MAX_BINDS] = { 0x0039, 0x1006, VK_INVALID };
unsigned int configKeyL[MAX_BINDS] = { 0x002A, 0x1009, 0x1104 };
unsigned int configKeyR[MAX_BINDS] = { 0x0036, 0x100A, 0x101B };
@@ -137,6 +139,8 @@ static const struct ConfigOption options[] = {
{.name = "env_volume", .type = CONFIG_TYPE_UINT, .uintValue = &configEnvVolume},
{.name = "key_a", .type = CONFIG_TYPE_BIND, .uintValue = configKeyA},
{.name = "key_b", .type = CONFIG_TYPE_BIND, .uintValue = configKeyB},
+ {.name = "key_x", .type = CONFIG_TYPE_BIND, .uintValue = configKeyX},
+ {.name = "key_y", .type = CONFIG_TYPE_BIND, .uintValue = configKeyY},
{.name = "key_start", .type = CONFIG_TYPE_BIND, .uintValue = configKeyStart},
{.name = "key_l", .type = CONFIG_TYPE_BIND, .uintValue = configKeyL},
{.name = "key_r", .type = CONFIG_TYPE_BIND, .uintValue = configKeyR},
diff --git a/src/pc/configfile.h b/src/pc/configfile.h
index e3c69d1a3..3f1fb4161 100644
--- a/src/pc/configfile.h
+++ b/src/pc/configfile.h
@@ -30,6 +30,8 @@ extern unsigned int configSfxVolume;
extern unsigned int configEnvVolume;
extern unsigned int configKeyA[];
extern unsigned int configKeyB[];
+extern unsigned int configKeyX[];
+extern unsigned int configKeyY[];
extern unsigned int configKeyStart[];
extern unsigned int configKeyL[];
extern unsigned int configKeyR[];
diff --git a/src/pc/controller/controller_keyboard.c b/src/pc/controller/controller_keyboard.c
index 250e5c1d2..3d60980c3 100644
--- a/src/pc/controller/controller_keyboard.c
+++ b/src/pc/controller/controller_keyboard.c
@@ -92,6 +92,8 @@ static void keyboard_bindkeys(void) {
keyboard_add_binds(STICK_RIGHT, configKeyStickRight);
keyboard_add_binds(A_BUTTON, configKeyA);
keyboard_add_binds(B_BUTTON, configKeyB);
+ keyboard_add_binds(X_BUTTON, configKeyX);
+ keyboard_add_binds(Y_BUTTON, configKeyY);
keyboard_add_binds(Z_TRIG, configKeyZ);
keyboard_add_binds(U_CBUTTONS, configKeyCUp);
keyboard_add_binds(L_CBUTTONS, configKeyCLeft);
diff --git a/src/pc/controller/controller_sdl1.c b/src/pc/controller/controller_sdl1.c
index 70f45f2b7..bbc5a2774 100644
--- a/src/pc/controller/controller_sdl1.c
+++ b/src/pc/controller/controller_sdl1.c
@@ -88,6 +88,8 @@ static void controller_sdl_bind(void) {
controller_add_binds(A_BUTTON, configKeyA);
controller_add_binds(B_BUTTON, configKeyB);
+ controller_add_binds(X_BUTTON, configKeyX);
+ controller_add_binds(Y_BUTTON, configKeyY);
controller_add_binds(Z_TRIG, configKeyZ);
controller_add_binds(STICK_UP, configKeyStickUp);
controller_add_binds(STICK_LEFT, configKeyStickLeft);
diff --git a/src/pc/controller/controller_sdl2.c b/src/pc/controller/controller_sdl2.c
index d1de2c9c3..5437e06a4 100644
--- a/src/pc/controller/controller_sdl2.c
+++ b/src/pc/controller/controller_sdl2.c
@@ -75,6 +75,8 @@ static void controller_sdl_bind(void) {
controller_add_binds(A_BUTTON, configKeyA);
controller_add_binds(B_BUTTON, configKeyB);
+ controller_add_binds(X_BUTTON, configKeyX);
+ controller_add_binds(Y_BUTTON, configKeyY);
controller_add_binds(Z_TRIG, configKeyZ);
controller_add_binds(STICK_UP, configKeyStickUp);
controller_add_binds(STICK_LEFT, configKeyStickLeft);
diff --git a/src/pc/djui/djui_panel_controls_n64.c b/src/pc/djui/djui_panel_controls_n64.c
index 6188e7306..84a99a339 100644
--- a/src/pc/djui/djui_panel_controls_n64.c
+++ b/src/pc/djui/djui_panel_controls_n64.c
@@ -21,6 +21,8 @@ void djui_panel_controls_n64_create(struct DjuiBase* caller) {
djui_bind_create(&bindBody->base, "Right", configKeyStickRight);
djui_bind_create(&bindBody->base, "A", configKeyA);
djui_bind_create(&bindBody->base, "B", configKeyB);
+ djui_bind_create(&bindBody->base, "X", configKeyX);
+ djui_bind_create(&bindBody->base, "Y", configKeyY);
djui_bind_create(&bindBody->base, "Start", configKeyStart);
djui_bind_create(&bindBody->base, "L", configKeyL);
djui_bind_create(&bindBody->base, "R", configKeyR);
diff --git a/src/pc/lua/smlua_constants_autogen.c b/src/pc/lua/smlua_constants_autogen.c
index 28874cca0..6ff707b91 100644
--- a/src/pc/lua/smlua_constants_autogen.c
+++ b/src/pc/lua/smlua_constants_autogen.c
@@ -1766,6 +1766,8 @@ char gSmluaConstants[] = ""
"CONT_EEPROM_BUSY = 0x80\n"
"CONT_A = 0x8000\n"
"CONT_B = 0x4000\n"
+"CONT_X = 0x0040\n"
+"CONT_Y = 0x0080\n"
"CONT_G = 0x2000\n"
"CONT_START = 0x1000\n"
"CONT_UP = 0x0800\n"
@@ -1780,6 +1782,8 @@ char gSmluaConstants[] = ""
"CONT_F = 0x0001\n"
"A_BUTTON = CONT_A\n"
"B_BUTTON = CONT_B\n"
+"X_BUTTON = CONT_X\n"
+"Y_BUTTON = CONT_Y\n"
"L_TRIG = CONT_L\n"
"R_TRIG = CONT_R\n"
"Z_TRIG = CONT_G\n"
@@ -2143,7 +2147,7 @@ char gSmluaConstants[] = ""
"ACT_HOLDING_BOWSER = 0x00000391\n"
"ACT_RELEASING_BOWSER = 0x00000392\n"
"END_DEMO = (1 << 7)\n"
-"VALID_BUTTONS = (A_BUTTON | B_BUTTON | Z_TRIG | START_BUTTON | U_JPAD | D_JPAD | L_JPAD | R_JPAD | L_TRIG | R_TRIG | U_CBUTTONS | D_CBUTTONS | L_CBUTTONS | R_CBUTTONS )\n"
+"VALID_BUTTONS = (A_BUTTON | B_BUTTON | X_BUTTON | Y_BUTTON | Z_TRIG | START_BUTTON | U_JPAD | D_JPAD | L_JPAD | R_JPAD | L_TRIG | R_TRIG | U_CBUTTONS | D_CBUTTONS | L_CBUTTONS | R_CBUTTONS )\n"
"C_BUTTONS = (U_CBUTTONS | D_CBUTTONS | L_CBUTTONS | R_CBUTTONS )\n"
"HOOK_UPDATE = 0\n"
"HOOK_MARIO_UPDATE = 1\n"
From 9ca4a9684e3c71ca0d81746add5ee677ae2fefb8 Mon Sep 17 00:00:00 2001
From: MysterD
Date: Mon, 28 Feb 2022 21:33:52 -0800
Subject: [PATCH 2/6] Add cpp stuff for coop-compiler
---
Makefile | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/Makefile b/Makefile
index 754c1d101..3d8738d79 100644
--- a/Makefile
+++ b/Makefile
@@ -94,9 +94,15 @@ ifeq ($(WINDOWS_AUTO_BUILDER),1)
export SHELL=sh.exe
EXTRA_INCLUDES := -I ../include/1 -I ../include/2 -I ../include/3 -I ../include/4
EXTRA_CFLAGS := -Wno-expansion-to-defined
+
+ EXTRA_CPP_INCLUDES := -I ../include/cpp
+ EXTRA_CPP_FLAGS := -Wno-class-conversion -Wno-packed-not-aligned
else
EXTRA_INCLUDES ?=
EXTRA_CFLAGS ?=
+
+ EXTRA_CPP_INCLUDES ?=
+ EXTRA_CPP_FLAGS ?=
endif
EXTRACT_ASSETS := $(PYTHON) ./extract_assets.py
@@ -1161,8 +1167,8 @@ $(GLOBAL_ASM_DEP).$(NON_MATCHING):
touch $@
$(BUILD_DIR)/%.o: %.cpp
- @$(CXX) -fsyntax-only $(CFLAGS) -MMD -MP -MT $@ -MF $(BUILD_DIR)/$*.d $<
- $(CXX) -c $(CFLAGS) -o $@ $<
+ @$(CXX) -fsyntax-only $(EXTRA_CPP_FLAGS) $(EXTRA_CPP_INCLUDES) $(CFLAGS) -MMD -MP -MT $@ -MF $(BUILD_DIR)/$*.d $<
+ $(CXX) -c $(EXTRA_CPP_FLAGS) $(EXTRA_CPP_INCLUDES) $(CFLAGS) -o $@ $<
$(BUILD_DIR)/%.o: %.c
@$(CC_CHECK) $(CC_CHECK_CFLAGS) -MMD -MP -MT $@ -MF $(BUILD_DIR)/$*.d $<
From 5788d80c78d74df93a90f813a4ab8dca6d992d9e Mon Sep 17 00:00:00 2001
From: MysterD
Date: Mon, 28 Feb 2022 22:59:58 -0800
Subject: [PATCH 3/6] Delete custom sounds on 32-bit, they are currently
breaking the build
---
Makefile | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/Makefile b/Makefile
index 3d8738d79..f4a40965c 100644
--- a/Makefile
+++ b/Makefile
@@ -304,6 +304,15 @@ ifeq ($(NOEXTRACT),0)
endif
endif
+# Luigi and wario sounds don't work on 32-bit right now
+# And the audio code is so terrible I don't care enough to figure it out at the moment
+ifeq ($(TARGET_BITS), 32)
+ $(shell rm -rf sound/samples/sfx_custom_luigi/*.aiff)
+ $(shell rm -rf sound/samples/sfx_custom_luigi_peach/*.aiff)
+ $(shell rm -rf sound/samples/sfx_custom_wario/*.aiff)
+ $(shell rm -rf sound/samples/sfx_custom_wario_peach/*.aiff)
+endif
+
# Copy missing luigi sounds from mario sound banks
$(shell mkdir -p sound/samples/sfx_custom_luigi sound/samples/sfx_custom_luigi_peach )
$(shell cp -n sound/samples/sfx_mario/*.aiff sound/samples/sfx_custom_luigi/ )
From b8cdcf4795f1ecff37a867a512a689f316ec3b9e Mon Sep 17 00:00:00 2001
From: PeachyPeachSM64
Date: Mon, 28 Feb 2022 22:15:37 +0100
Subject: [PATCH 4/6] Added obj_get_* functions; Added set_camera_mode
---
docs/lua/functions.md | 199 +++++++++++++++++++++++++++
src/pc/lua/smlua_functions_autogen.c | 128 +++++++++++++++++
src/pc/lua/smlua_obj_utils.c | 101 +++++++++++++-
src/pc/lua/smlua_obj_utils.h | 15 ++
4 files changed, 442 insertions(+), 1 deletion(-)
diff --git a/docs/lua/functions.md b/docs/lua/functions.md
index 34edb92a2..c0cfb9b88 100644
--- a/docs/lua/functions.md
+++ b/docs/lua/functions.md
@@ -14,6 +14,7 @@
- [set_camera_shake_from_point](#set_camera_shake_from_point)
- [set_camera_yaw_shake](#set_camera_yaw_shake)
- [set_environmental_camera_shake](#set_environmental_camera_shake)
+ - [set_camera_mode](#set_camera_mode)
@@ -455,6 +456,14 @@
- smlua_obj_utils.h
- [spawn_sync_object](#spawn_sync_object)
+ - [obj_get_first](#obj_get_first)
+ - [obj_get_first_with_behavior_id](#obj_get_first_with_behavior_id)
+ - [obj_get_first_with_behavior_id_and_field_s32](#obj_get_first_with_behavior_id_and_field_s32)
+ - [obj_get_first_with_behavior_id_and_field_f32](#obj_get_first_with_behavior_id_and_field_f32)
+ - [obj_get_next](#obj_get_next)
+ - [obj_get_next_with_same_behavior_id](#obj_get_next_with_same_behavior_id)
+ - [obj_get_next_with_same_behavior_id_and_field_s32](#obj_get_next_with_same_behavior_id_and_field_s32)
+ - [obj_get_next_with_same_behavior_id_and_field_f32](#obj_get_next_with_same_behavior_id_and_field_f32)
@@ -676,6 +685,28 @@
+## [set_camera_mode](#set_camera_mode)
+
+### Lua Example
+`set_camera_mode(c, mode, frames)`
+
+### Parameters
+| Field | Type |
+| ----- | ---- |
+| c | Camera |
+| mode | integer |
+| frames | integer |
+
+### Returns
+- None
+
+### C Prototype
+`void set_camera_mode(struct Camera *c, s16 mode, s16 frames);`
+
+[:arrow_up_small:](#)
+
+
+
---
# functions from characters.h
@@ -8055,6 +8086,174 @@
+## [obj_get_first](#obj_get_first)
+
+### Lua Example
+`local obj = obj_get_first(objList)`
+
+### Parameters
+| Field | Type |
+| ----- | ---- |
+| objList | integer |
+
+### Returns
+[Object](structs.md#Object)
+
+### C Prototype
+`struct Object *obj_get_first(enum ObjectList objList);`
+
+[:arrow_up_small:](#)
+
+
+
+## [obj_get_first_with_behavior_id](#obj_get_first_with_behavior_id)
+
+### Lua Example
+`local obj = obj_get_first_with_behavior_id(behaviorId)`
+
+### Parameters
+| Field | Type |
+| ----- | ---- |
+| behaviorId | integer |
+
+### Returns
+[Object](structs.md#Object)
+
+### C Prototype
+`struct Object *obj_get_first_with_behavior_id(enum BehaviorId behaviorId);`
+
+[:arrow_up_small:](#)
+
+
+
+## [obj_get_first_with_behavior_id_and_field_s32](#obj_get_first_with_behavior_id_and_field_s32)
+
+### Lua Example
+`local obj = obj_get_first_with_behavior_id_and_field_s32(behaviorId, fieldIndex, value)`
+
+### Parameters
+| Field | Type |
+| ----- | ---- |
+| behaviorId | integer |
+| fieldIndex | integer |
+| value | integer |
+
+### Returns
+[Object](structs.md#Object)
+
+### C Prototype
+`struct Object *obj_get_first_with_behavior_id_and_field_s32(enum BehaviorId behaviorId, s32 fieldIndex, s32 value);`
+
+[:arrow_up_small:](#)
+
+
+
+## [obj_get_first_with_behavior_id_and_field_f32](#obj_get_first_with_behavior_id_and_field_f32)
+
+### Lua Example
+`local obj = obj_get_first_with_behavior_id_and_field_f32(behaviorId, fieldIndex, value)`
+
+### Parameters
+| Field | Type |
+| ----- | ---- |
+| behaviorId | integer |
+| fieldIndex | integer |
+| value | number |
+
+### Returns
+[Object](structs.md#Object)
+
+### C Prototype
+`struct Object *obj_get_first_with_behavior_id_and_field_f32(enum BehaviorId behaviorId, s32 fieldIndex, f32 value);`
+
+[:arrow_up_small:](#)
+
+
+
+## [obj_get_next](#obj_get_next)
+
+### Lua Example
+`local obj = obj_get_next(o)`
+
+### Parameters
+| Field | Type |
+| ----- | ---- |
+| o | Object |
+
+### Returns
+[Object](structs.md#Object)
+
+### C Prototype
+`struct Object *obj_get_next(struct Object *o);`
+
+[:arrow_up_small:](#)
+
+
+
+## [obj_get_next_with_same_behavior_id](#obj_get_next_with_same_behavior_id)
+
+### Lua Example
+`local obj = obj_get_next_with_same_behavior_id(o)`
+
+### Parameters
+| Field | Type |
+| ----- | ---- |
+| o | Object |
+
+### Returns
+[Object](structs.md#Object)
+
+### C Prototype
+`struct Object *obj_get_next_with_same_behavior_id(struct Object *o);`
+
+[:arrow_up_small:](#)
+
+
+
+## [obj_get_next_with_same_behavior_id_and_field_s32](#obj_get_next_with_same_behavior_id_and_field_s32)
+
+### Lua Example
+`local obj = obj_get_next_with_same_behavior_id_and_field_s32(o, fieldIndex, value)`
+
+### Parameters
+| Field | Type |
+| ----- | ---- |
+| o | Object |
+| fieldIndex | integer |
+| value | integer |
+
+### Returns
+[Object](structs.md#Object)
+
+### C Prototype
+`struct Object *obj_get_next_with_same_behavior_id_and_field_s32(struct Object *o, s32 fieldIndex, s32 value);`
+
+[:arrow_up_small:](#)
+
+
+
+## [obj_get_next_with_same_behavior_id_and_field_f32](#obj_get_next_with_same_behavior_id_and_field_f32)
+
+### Lua Example
+`local obj = obj_get_next_with_same_behavior_id_and_field_f32(o, fieldIndex, value)`
+
+### Parameters
+| Field | Type |
+| ----- | ---- |
+| o | Object |
+| fieldIndex | integer |
+| value | number |
+
+### Returns
+[Object](structs.md#Object)
+
+### C Prototype
+`struct Object *obj_get_next_with_same_behavior_id_and_field_f32(struct Object *o, s32 fieldIndex, f32 value);`
+
+[:arrow_up_small:](#)
+
+
+
---
# functions from sound_init.h
diff --git a/src/pc/lua/smlua_functions_autogen.c b/src/pc/lua/smlua_functions_autogen.c
index c85ee080d..6e38319c0 100644
--- a/src/pc/lua/smlua_functions_autogen.c
+++ b/src/pc/lua/smlua_functions_autogen.c
@@ -136,6 +136,21 @@ int smlua_func_set_environmental_camera_shake(lua_State* L) {
return 1;
}
+int smlua_func_set_camera_mode(lua_State* L) {
+ if(!smlua_functions_valid_param_count(L, 3)) { return 0; }
+
+ struct Camera* c = (struct Camera *) smlua_to_cobject(L, 1, LOT_CAMERA);
+ if (!gSmLuaConvertSuccess) { return 0; }
+ s16 mode = smlua_to_integer(L, 2);
+ if (!gSmLuaConvertSuccess) { return 0; }
+ s16 frames = smlua_to_integer(L, 3);
+ if (!gSmLuaConvertSuccess) { return 0; }
+
+ set_camera_mode(c, mode, frames);
+
+ return 1;
+}
+
//////////////////
// characters.h //
//////////////////
@@ -5307,6 +5322,110 @@ int smlua_func_spawn_sync_object(lua_State* L) {
return 1;
}
+int smlua_func_obj_get_first(lua_State *L) {
+ if(!smlua_functions_valid_param_count(L, 1)) { return 0; }
+
+ int objList = smlua_to_integer(L, 1);
+ if (!gSmLuaConvertSuccess) { return 0; }
+
+ smlua_push_object(L, LOT_OBJECT, obj_get_first(objList));
+
+ return 1;
+}
+
+int smlua_func_obj_get_first_with_behavior_id(lua_State *L) {
+ if(!smlua_functions_valid_param_count(L, 1)) { return 0; }
+
+ int behaviorId = smlua_to_integer(L, 1);
+ if (!gSmLuaConvertSuccess) { return 0; }
+
+ smlua_push_object(L, LOT_OBJECT, obj_get_first_with_behavior_id(behaviorId));
+
+ return 1;
+}
+
+int smlua_func_obj_get_first_with_behavior_id_and_field_s32(lua_State *L) {
+ if(!smlua_functions_valid_param_count(L, 3)) { return 0; }
+
+ int behaviorId = smlua_to_integer(L, 1);
+ if (!gSmLuaConvertSuccess) { return 0; }
+ int fieldIndex = smlua_to_integer(L, 2);
+ if (!gSmLuaConvertSuccess) { return 0; }
+ int value = smlua_to_integer(L, 3);
+ if (!gSmLuaConvertSuccess) { return 0; }
+
+ smlua_push_object(L, LOT_OBJECT, obj_get_first_with_behavior_id_and_field_s32(behaviorId, fieldIndex, value));
+
+ return 1;
+}
+
+int smlua_func_obj_get_first_with_behavior_id_and_field_f32(lua_State *L) {
+ if(!smlua_functions_valid_param_count(L, 3)) { return 0; }
+
+ int behaviorId = smlua_to_integer(L, 1);
+ if (!gSmLuaConvertSuccess) { return 0; }
+ int fieldIndex = smlua_to_integer(L, 2);
+ if (!gSmLuaConvertSuccess) { return 0; }
+ float value = smlua_to_number(L, 3);
+ if (!gSmLuaConvertSuccess) { return 0; }
+
+ smlua_push_object(L, LOT_OBJECT, obj_get_first_with_behavior_id_and_field_f32(behaviorId, fieldIndex, value));
+
+ return 1;
+}
+
+int smlua_func_obj_get_next(lua_State *L) {
+ if(!smlua_functions_valid_param_count(L, 1)) { return 0; }
+
+ struct Object *o = (struct Object *) smlua_to_cobject(L, 1, LOT_OBJECT);
+ if (!gSmLuaConvertSuccess) { return 0; }
+
+ smlua_push_object(L, LOT_OBJECT, obj_get_next(o));
+
+ return 1;
+}
+
+int smlua_func_obj_get_next_with_same_behavior_id(lua_State *L) {
+ if(!smlua_functions_valid_param_count(L, 1)) { return 0; }
+
+ struct Object *o = (struct Object *) smlua_to_cobject(L, 1, LOT_OBJECT);
+ if (!gSmLuaConvertSuccess) { return 0; }
+
+ smlua_push_object(L, LOT_OBJECT, obj_get_next_with_same_behavior_id(o));
+
+ return 1;
+}
+
+int smlua_func_obj_get_next_with_same_behavior_id_and_field_s32(lua_State *L) {
+ if(!smlua_functions_valid_param_count(L, 3)) { return 0; }
+
+ struct Object *o = (struct Object *) smlua_to_cobject(L, 1, LOT_OBJECT);
+ if (!gSmLuaConvertSuccess) { return 0; }
+ int fieldIndex = smlua_to_integer(L, 2);
+ if (!gSmLuaConvertSuccess) { return 0; }
+ int value = smlua_to_integer(L, 3);
+ if (!gSmLuaConvertSuccess) { return 0; }
+
+ smlua_push_object(L, LOT_OBJECT, obj_get_next_with_same_behavior_id_and_field_s32(o, fieldIndex, value));
+
+ return 1;
+}
+
+int smlua_func_obj_get_next_with_same_behavior_id_and_field_f32(lua_State *L) {
+ if(!smlua_functions_valid_param_count(L, 3)) { return 0; }
+
+ struct Object *o = (struct Object *) smlua_to_cobject(L, 1, LOT_OBJECT);
+ if (!gSmLuaConvertSuccess) { return 0; }
+ int fieldIndex = smlua_to_integer(L, 2);
+ if (!gSmLuaConvertSuccess) { return 0; }
+ float value = smlua_to_number(L, 3);
+ if (!gSmLuaConvertSuccess) { return 0; }
+
+ smlua_push_object(L, LOT_OBJECT, obj_get_next_with_same_behavior_id_and_field_f32(o, fieldIndex, value));
+
+ return 1;
+}
+
//////////////////
// sound_init.h //
//////////////////
@@ -5712,6 +5831,7 @@ void smlua_bind_functions_autogen(void) {
smlua_bind_function(L, "set_camera_shake_from_point", smlua_func_set_camera_shake_from_point);
smlua_bind_function(L, "set_camera_yaw_shake", smlua_func_set_camera_yaw_shake);
smlua_bind_function(L, "set_environmental_camera_shake", smlua_func_set_environmental_camera_shake);
+ smlua_bind_function(L, "set_camera_mode", smlua_func_set_camera_mode);
// characters.h
smlua_bind_function(L, "get_character", smlua_func_get_character);
@@ -6122,6 +6242,14 @@ void smlua_bind_functions_autogen(void) {
// smlua_obj_utils.h
smlua_bind_function(L, "spawn_sync_object", smlua_func_spawn_sync_object);
+ smlua_bind_function(L, "obj_get_first", smlua_func_obj_get_first);
+ smlua_bind_function(L, "obj_get_first_with_behavior_id", smlua_func_obj_get_first_with_behavior_id);
+ smlua_bind_function(L, "obj_get_first_with_behavior_id_and_field_s32", smlua_func_obj_get_first_with_behavior_id_and_field_s32);
+ smlua_bind_function(L, "obj_get_first_with_behavior_id_and_field_f32", smlua_func_obj_get_first_with_behavior_id_and_field_f32);
+ smlua_bind_function(L, "obj_get_next", smlua_func_obj_get_next);
+ smlua_bind_function(L, "obj_get_next_with_same_behavior_id", smlua_func_obj_get_next_with_same_behavior_id);
+ smlua_bind_function(L, "obj_get_next_with_same_behavior_id_and_field_s32", smlua_func_obj_get_next_with_same_behavior_id_and_field_s32);
+ smlua_bind_function(L, "obj_get_next_with_same_behavior_id_and_field_f32", smlua_func_obj_get_next_with_same_behavior_id_and_field_f32);
// 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 74dfba9bf..ac33e0ae8 100644
--- a/src/pc/lua/smlua_obj_utils.c
+++ b/src/pc/lua/smlua_obj_utils.c
@@ -76,4 +76,103 @@ struct Object* spawn_sync_object(enum BehaviorId behaviorId, enum ModelExtendedI
// 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
+}
+
+//
+// Helpers to iterate through the object table
+//
+
+struct Object *obj_get_first(enum ObjectList objList) {
+ if (gObjectLists && objList >= 0 && objList < NUM_OBJ_LISTS) {
+ struct Object *head = (struct Object *) &gObjectLists[objList];
+ struct Object *obj = (struct Object *) head->header.next;
+ if (obj != head) {
+ return obj;
+ }
+ }
+ return NULL;
+}
+
+struct Object *obj_get_first_with_behavior_id(enum BehaviorId behaviorId) {
+ const BehaviorScript* behavior = get_behavior_from_id(behaviorId);
+ if (behavior) {
+ enum ObjectList objList = get_object_list_from_behavior(behavior);
+ for (struct Object *obj = obj_get_first(objList); obj != NULL; obj = obj_get_next(obj)) {
+ if (obj->behavior == behavior && obj->activeFlags != ACTIVE_FLAG_DEACTIVATED) {
+ return obj;
+ }
+ }
+ }
+ return NULL;
+}
+
+struct Object *obj_get_first_with_behavior_id_and_field_s32(enum BehaviorId behaviorId, s32 fieldIndex, s32 value) {
+ const BehaviorScript* behavior = get_behavior_from_id(behaviorId);
+ if (behavior) {
+ enum ObjectList objList = get_object_list_from_behavior(behavior);
+ for (struct Object *obj = obj_get_first(objList); obj != NULL; obj = obj_get_next(obj)) {
+ if (obj->behavior == behavior && obj->activeFlags != ACTIVE_FLAG_DEACTIVATED && obj->OBJECT_FIELD_S32(fieldIndex) == value) {
+ return obj;
+ }
+ }
+ }
+ return NULL;
+}
+
+struct Object *obj_get_first_with_behavior_id_and_field_f32(enum BehaviorId behaviorId, s32 fieldIndex, f32 value) {
+ const BehaviorScript* behavior = get_behavior_from_id(behaviorId);
+ if (behavior) {
+ enum ObjectList objList = get_object_list_from_behavior(behavior);
+ for (struct Object *obj = obj_get_first(objList); obj != NULL; obj = obj_get_next(obj)) {
+ if (obj->behavior == behavior && obj->activeFlags != ACTIVE_FLAG_DEACTIVATED && obj->OBJECT_FIELD_F32(fieldIndex) == value) {
+ return obj;
+ }
+ }
+ }
+ return NULL;
+}
+
+struct Object *obj_get_next(struct Object *o) {
+ if (gObjectLists && o) {
+ enum ObjectList objList = get_object_list_from_behavior(o->behavior);
+ struct Object *head = (struct Object *) &gObjectLists[objList];
+ struct Object *next = (struct Object *) o->header.next;
+ if (next != head) {
+ return next;
+ }
+ }
+ return NULL;
+}
+
+struct Object *obj_get_next_with_same_behavior_id(struct Object *o) {
+ if (o) {
+ for (struct Object *obj = obj_get_next(o); obj != NULL; obj = obj_get_next(obj)) {
+ if (obj->behavior == o->behavior && obj->activeFlags != ACTIVE_FLAG_DEACTIVATED) {
+ return obj;
+ }
+ }
+ }
+ return NULL;
+}
+
+struct Object *obj_get_next_with_same_behavior_id_and_field_s32(struct Object *o, s32 fieldIndex, s32 value) {
+ if (o) {
+ for (struct Object *obj = obj_get_next(o); obj != NULL; obj = obj_get_next(obj)) {
+ if (obj->behavior == o->behavior && obj->activeFlags != ACTIVE_FLAG_DEACTIVATED && obj->OBJECT_FIELD_S32(fieldIndex) == value) {
+ return obj;
+ }
+ }
+ }
+ return NULL;
+}
+
+struct Object *obj_get_next_with_same_behavior_id_and_field_f32(struct Object *o, s32 fieldIndex, f32 value) {
+ if (o) {
+ for (struct Object *obj = obj_get_next(o); obj != NULL; obj = obj_get_next(obj)) {
+ if (obj->behavior == o->behavior && obj->activeFlags != ACTIVE_FLAG_DEACTIVATED && obj->OBJECT_FIELD_F32(fieldIndex) == value) {
+ return obj;
+ }
+ }
+ }
+ return NULL;
+}
diff --git a/src/pc/lua/smlua_obj_utils.h b/src/pc/lua/smlua_obj_utils.h
index e7db21124..6d010d637 100644
--- a/src/pc/lua/smlua_obj_utils.h
+++ b/src/pc/lua/smlua_obj_utils.h
@@ -3,10 +3,25 @@
#include "behavior_table.h"
#include "smlua_model_utils.h"
+#include "game/object_list_processor.h"
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);
+//
+// Helpers to iterate through the object table
+//
+
+struct Object *obj_get_first(enum ObjectList objList);
+struct Object *obj_get_first_with_behavior_id(enum BehaviorId behaviorId);
+struct Object *obj_get_first_with_behavior_id_and_field_s32(enum BehaviorId behaviorId, s32 fieldIndex, s32 value);
+struct Object *obj_get_first_with_behavior_id_and_field_f32(enum BehaviorId behaviorId, s32 fieldIndex, f32 value);
+
+struct Object *obj_get_next(struct Object *o);
+struct Object *obj_get_next_with_same_behavior_id(struct Object *o);
+struct Object *obj_get_next_with_same_behavior_id_and_field_s32(struct Object *o, s32 fieldIndex, s32 value);
+struct Object *obj_get_next_with_same_behavior_id_and_field_f32(struct Object *o, s32 fieldIndex, f32 value);
+
#endif
From 8d5ab43f66d3beb88611eed7acaf762e903a2246 Mon Sep 17 00:00:00 2001
From: MysterD
Date: Tue, 1 Mar 2022 18:02:54 -0800
Subject: [PATCH 5/6] Possible crash fix
---
src/game/object_helpers.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/src/game/object_helpers.c b/src/game/object_helpers.c
index b9a5ef874..ec4792e93 100644
--- a/src/game/object_helpers.c
+++ b/src/game/object_helpers.c
@@ -2464,6 +2464,7 @@ s32 cur_obj_is_mario_on_platform(void) {
s32 cur_obj_is_any_player_on_platform(void) {
for (int i = 0; i < MAX_PLAYERS; i++) {
if (!is_player_active(&gMarioStates[i])) { continue; }
+ if (gMarioStates[i].marioObj == NULL) { continue; }
if (gMarioStates[i].marioObj->platform == o) {
return TRUE;
}
From ecc33286ad8fed42e25be36d537faabbcb74d0c0 Mon Sep 17 00:00:00 2001
From: MysterD
Date: Tue, 1 Mar 2022 12:06:06 -0800
Subject: [PATCH 6/6] Ran autogen
---
autogen/convert_functions.py | 2 +-
docs/lua/functions.md | 412 ++++++++++++++-------------
src/pc/lua/smlua_constants_autogen.c | 2 +-
src/pc/lua/smlua_functions_autogen.c | 264 +++++++++--------
4 files changed, 361 insertions(+), 319 deletions(-)
diff --git a/autogen/convert_functions.py b/autogen/convert_functions.py
index 88dbd235a..7154e9168 100644
--- a/autogen/convert_functions.py
+++ b/autogen/convert_functions.py
@@ -43,7 +43,7 @@ in_files = [
override_allowed_functions = {
"src/audio/external.h": [ " play_", "fade" ],
- "src/game/camera.h": [ "set_.*camera_.*shake" ],
+ "src/game/camera.h": [ "set_.*camera_.*shake", "set_camera_mode" ],
"src/game/thread6.c": [ "queue_rumble_"],
"src/pc/djui/djui_popup.h" : [ "create" ],
"src/game/save_file.h": [ "save_file_get_" ],
diff --git a/docs/lua/functions.md b/docs/lua/functions.md
index c0cfb9b88..c9b51b076 100644
--- a/docs/lua/functions.md
+++ b/docs/lua/functions.md
@@ -8,13 +8,14 @@
- camera.h
+ - [set_camera_mode](#set_camera_mode)
+ - [set_camera_mode_fixed](#set_camera_mode_fixed)
- [set_camera_pitch_shake](#set_camera_pitch_shake)
- [set_camera_roll_shake](#set_camera_roll_shake)
- [set_camera_shake_from_hit](#set_camera_shake_from_hit)
- [set_camera_shake_from_point](#set_camera_shake_from_point)
- [set_camera_yaw_shake](#set_camera_yaw_shake)
- [set_environmental_camera_shake](#set_environmental_camera_shake)
- - [set_camera_mode](#set_camera_mode)
@@ -455,15 +456,15 @@
- smlua_obj_utils.h
- - [spawn_sync_object](#spawn_sync_object)
- [obj_get_first](#obj_get_first)
- [obj_get_first_with_behavior_id](#obj_get_first_with_behavior_id)
- - [obj_get_first_with_behavior_id_and_field_s32](#obj_get_first_with_behavior_id_and_field_s32)
- [obj_get_first_with_behavior_id_and_field_f32](#obj_get_first_with_behavior_id_and_field_f32)
+ - [obj_get_first_with_behavior_id_and_field_s32](#obj_get_first_with_behavior_id_and_field_s32)
- [obj_get_next](#obj_get_next)
- [obj_get_next_with_same_behavior_id](#obj_get_next_with_same_behavior_id)
- - [obj_get_next_with_same_behavior_id_and_field_s32](#obj_get_next_with_same_behavior_id_and_field_s32)
- [obj_get_next_with_same_behavior_id_and_field_f32](#obj_get_next_with_same_behavior_id_and_field_f32)
+ - [obj_get_next_with_same_behavior_id_and_field_s32](#obj_get_next_with_same_behavior_id_and_field_s32)
+ - [spawn_sync_object](#spawn_sync_object)
@@ -556,6 +557,51 @@
+## [set_camera_mode](#set_camera_mode)
+
+### Lua Example
+`set_camera_mode(c, mode, frames)`
+
+### Parameters
+| Field | Type |
+| ----- | ---- |
+| c | [Camera](structs.md#Camera) |
+| mode | integer |
+| frames | integer |
+
+### Returns
+- None
+
+### C Prototype
+`void set_camera_mode(struct Camera *c, s16 mode, s16 frames);`
+
+[:arrow_up_small:](#)
+
+
+
+## [set_camera_mode_fixed](#set_camera_mode_fixed)
+
+### Lua Example
+`local integerValue = set_camera_mode_fixed(c, x, y, z)`
+
+### Parameters
+| Field | Type |
+| ----- | ---- |
+| c | [Camera](structs.md#Camera) |
+| x | integer |
+| y | integer |
+| z | integer |
+
+### Returns
+- integer
+
+### C Prototype
+`s32 set_camera_mode_fixed(struct Camera* c, s16 x, s16 y, s16 z);`
+
+[:arrow_up_small:](#)
+
+
+
## [set_camera_pitch_shake](#set_camera_pitch_shake)
### Lua Example
@@ -685,28 +731,6 @@
-## [set_camera_mode](#set_camera_mode)
-
-### Lua Example
-`set_camera_mode(c, mode, frames)`
-
-### Parameters
-| Field | Type |
-| ----- | ---- |
-| c | Camera |
-| mode | integer |
-| frames | integer |
-
-### Returns
-- None
-
-### C Prototype
-`void set_camera_mode(struct Camera *c, s16 mode, s16 frames);`
-
-[:arrow_up_small:](#)
-
-
-
---
# functions from characters.h
@@ -8061,6 +8085,174 @@
+## [obj_get_first](#obj_get_first)
+
+### Lua Example
+`local ObjectValue = obj_get_first(objList)`
+
+### Parameters
+| Field | Type |
+| ----- | ---- |
+| objList | integer |
+
+### Returns
+[Object](structs.md#Object)
+
+### C Prototype
+`struct Object *obj_get_first(enum ObjectList objList);`
+
+[:arrow_up_small:](#)
+
+
+
+## [obj_get_first_with_behavior_id](#obj_get_first_with_behavior_id)
+
+### Lua Example
+`local ObjectValue = obj_get_first_with_behavior_id(behaviorId)`
+
+### Parameters
+| Field | Type |
+| ----- | ---- |
+| behaviorId | integer |
+
+### Returns
+[Object](structs.md#Object)
+
+### C Prototype
+`struct Object *obj_get_first_with_behavior_id(enum BehaviorId behaviorId);`
+
+[:arrow_up_small:](#)
+
+
+
+## [obj_get_first_with_behavior_id_and_field_f32](#obj_get_first_with_behavior_id_and_field_f32)
+
+### Lua Example
+`local ObjectValue = obj_get_first_with_behavior_id_and_field_f32(behaviorId, fieldIndex, value)`
+
+### Parameters
+| Field | Type |
+| ----- | ---- |
+| behaviorId | integer |
+| fieldIndex | integer |
+| value | number |
+
+### Returns
+[Object](structs.md#Object)
+
+### C Prototype
+`struct Object *obj_get_first_with_behavior_id_and_field_f32(enum BehaviorId behaviorId, s32 fieldIndex, f32 value);`
+
+[:arrow_up_small:](#)
+
+
+
+## [obj_get_first_with_behavior_id_and_field_s32](#obj_get_first_with_behavior_id_and_field_s32)
+
+### Lua Example
+`local ObjectValue = obj_get_first_with_behavior_id_and_field_s32(behaviorId, fieldIndex, value)`
+
+### Parameters
+| Field | Type |
+| ----- | ---- |
+| behaviorId | integer |
+| fieldIndex | integer |
+| value | integer |
+
+### Returns
+[Object](structs.md#Object)
+
+### C Prototype
+`struct Object *obj_get_first_with_behavior_id_and_field_s32(enum BehaviorId behaviorId, s32 fieldIndex, s32 value);`
+
+[:arrow_up_small:](#)
+
+
+
+## [obj_get_next](#obj_get_next)
+
+### Lua Example
+`local ObjectValue = obj_get_next(o)`
+
+### Parameters
+| Field | Type |
+| ----- | ---- |
+| o | [Object](structs.md#Object) |
+
+### Returns
+[Object](structs.md#Object)
+
+### C Prototype
+`struct Object *obj_get_next(struct Object *o);`
+
+[:arrow_up_small:](#)
+
+
+
+## [obj_get_next_with_same_behavior_id](#obj_get_next_with_same_behavior_id)
+
+### Lua Example
+`local ObjectValue = obj_get_next_with_same_behavior_id(o)`
+
+### Parameters
+| Field | Type |
+| ----- | ---- |
+| o | [Object](structs.md#Object) |
+
+### Returns
+[Object](structs.md#Object)
+
+### C Prototype
+`struct Object *obj_get_next_with_same_behavior_id(struct Object *o);`
+
+[:arrow_up_small:](#)
+
+
+
+## [obj_get_next_with_same_behavior_id_and_field_f32](#obj_get_next_with_same_behavior_id_and_field_f32)
+
+### Lua Example
+`local ObjectValue = obj_get_next_with_same_behavior_id_and_field_f32(o, fieldIndex, value)`
+
+### Parameters
+| Field | Type |
+| ----- | ---- |
+| o | [Object](structs.md#Object) |
+| fieldIndex | integer |
+| value | number |
+
+### Returns
+[Object](structs.md#Object)
+
+### C Prototype
+`struct Object *obj_get_next_with_same_behavior_id_and_field_f32(struct Object *o, s32 fieldIndex, f32 value);`
+
+[:arrow_up_small:](#)
+
+
+
+## [obj_get_next_with_same_behavior_id_and_field_s32](#obj_get_next_with_same_behavior_id_and_field_s32)
+
+### Lua Example
+`local ObjectValue = obj_get_next_with_same_behavior_id_and_field_s32(o, fieldIndex, value)`
+
+### Parameters
+| Field | Type |
+| ----- | ---- |
+| o | [Object](structs.md#Object) |
+| fieldIndex | integer |
+| value | integer |
+
+### Returns
+[Object](structs.md#Object)
+
+### C Prototype
+`struct Object *obj_get_next_with_same_behavior_id_and_field_s32(struct Object *o, s32 fieldIndex, s32 value);`
+
+[:arrow_up_small:](#)
+
+
+
## [spawn_sync_object](#spawn_sync_object)
### Lua Example
@@ -8086,174 +8278,6 @@
-## [obj_get_first](#obj_get_first)
-
-### Lua Example
-`local obj = obj_get_first(objList)`
-
-### Parameters
-| Field | Type |
-| ----- | ---- |
-| objList | integer |
-
-### Returns
-[Object](structs.md#Object)
-
-### C Prototype
-`struct Object *obj_get_first(enum ObjectList objList);`
-
-[:arrow_up_small:](#)
-
-
-
-## [obj_get_first_with_behavior_id](#obj_get_first_with_behavior_id)
-
-### Lua Example
-`local obj = obj_get_first_with_behavior_id(behaviorId)`
-
-### Parameters
-| Field | Type |
-| ----- | ---- |
-| behaviorId | integer |
-
-### Returns
-[Object](structs.md#Object)
-
-### C Prototype
-`struct Object *obj_get_first_with_behavior_id(enum BehaviorId behaviorId);`
-
-[:arrow_up_small:](#)
-
-
-
-## [obj_get_first_with_behavior_id_and_field_s32](#obj_get_first_with_behavior_id_and_field_s32)
-
-### Lua Example
-`local obj = obj_get_first_with_behavior_id_and_field_s32(behaviorId, fieldIndex, value)`
-
-### Parameters
-| Field | Type |
-| ----- | ---- |
-| behaviorId | integer |
-| fieldIndex | integer |
-| value | integer |
-
-### Returns
-[Object](structs.md#Object)
-
-### C Prototype
-`struct Object *obj_get_first_with_behavior_id_and_field_s32(enum BehaviorId behaviorId, s32 fieldIndex, s32 value);`
-
-[:arrow_up_small:](#)
-
-
-
-## [obj_get_first_with_behavior_id_and_field_f32](#obj_get_first_with_behavior_id_and_field_f32)
-
-### Lua Example
-`local obj = obj_get_first_with_behavior_id_and_field_f32(behaviorId, fieldIndex, value)`
-
-### Parameters
-| Field | Type |
-| ----- | ---- |
-| behaviorId | integer |
-| fieldIndex | integer |
-| value | number |
-
-### Returns
-[Object](structs.md#Object)
-
-### C Prototype
-`struct Object *obj_get_first_with_behavior_id_and_field_f32(enum BehaviorId behaviorId, s32 fieldIndex, f32 value);`
-
-[:arrow_up_small:](#)
-
-
-
-## [obj_get_next](#obj_get_next)
-
-### Lua Example
-`local obj = obj_get_next(o)`
-
-### Parameters
-| Field | Type |
-| ----- | ---- |
-| o | Object |
-
-### Returns
-[Object](structs.md#Object)
-
-### C Prototype
-`struct Object *obj_get_next(struct Object *o);`
-
-[:arrow_up_small:](#)
-
-
-
-## [obj_get_next_with_same_behavior_id](#obj_get_next_with_same_behavior_id)
-
-### Lua Example
-`local obj = obj_get_next_with_same_behavior_id(o)`
-
-### Parameters
-| Field | Type |
-| ----- | ---- |
-| o | Object |
-
-### Returns
-[Object](structs.md#Object)
-
-### C Prototype
-`struct Object *obj_get_next_with_same_behavior_id(struct Object *o);`
-
-[:arrow_up_small:](#)
-
-
-
-## [obj_get_next_with_same_behavior_id_and_field_s32](#obj_get_next_with_same_behavior_id_and_field_s32)
-
-### Lua Example
-`local obj = obj_get_next_with_same_behavior_id_and_field_s32(o, fieldIndex, value)`
-
-### Parameters
-| Field | Type |
-| ----- | ---- |
-| o | Object |
-| fieldIndex | integer |
-| value | integer |
-
-### Returns
-[Object](structs.md#Object)
-
-### C Prototype
-`struct Object *obj_get_next_with_same_behavior_id_and_field_s32(struct Object *o, s32 fieldIndex, s32 value);`
-
-[:arrow_up_small:](#)
-
-
-
-## [obj_get_next_with_same_behavior_id_and_field_f32](#obj_get_next_with_same_behavior_id_and_field_f32)
-
-### Lua Example
-`local obj = obj_get_next_with_same_behavior_id_and_field_f32(o, fieldIndex, value)`
-
-### Parameters
-| Field | Type |
-| ----- | ---- |
-| o | Object |
-| fieldIndex | integer |
-| value | number |
-
-### Returns
-[Object](structs.md#Object)
-
-### C Prototype
-`struct Object *obj_get_next_with_same_behavior_id_and_field_f32(struct Object *o, s32 fieldIndex, f32 value);`
-
-[:arrow_up_small:](#)
-
-
-
---
# functions from sound_init.h
diff --git a/src/pc/lua/smlua_constants_autogen.c b/src/pc/lua/smlua_constants_autogen.c
index 6ff707b91..ec6387afd 100644
--- a/src/pc/lua/smlua_constants_autogen.c
+++ b/src/pc/lua/smlua_constants_autogen.c
@@ -2147,7 +2147,7 @@ char gSmluaConstants[] = ""
"ACT_HOLDING_BOWSER = 0x00000391\n"
"ACT_RELEASING_BOWSER = 0x00000392\n"
"END_DEMO = (1 << 7)\n"
-"VALID_BUTTONS = (A_BUTTON | B_BUTTON | X_BUTTON | Y_BUTTON | Z_TRIG | START_BUTTON | U_JPAD | D_JPAD | L_JPAD | R_JPAD | L_TRIG | R_TRIG | U_CBUTTONS | D_CBUTTONS | L_CBUTTONS | R_CBUTTONS )\n"
+"VALID_BUTTONS = (A_BUTTON | B_BUTTON | Z_TRIG | START_BUTTON | U_JPAD | D_JPAD | L_JPAD | R_JPAD | L_TRIG | R_TRIG | X_BUTTON | Y_BUTTON | U_CBUTTONS | D_CBUTTONS | L_CBUTTONS | R_CBUTTONS )\n"
"C_BUTTONS = (U_CBUTTONS | D_CBUTTONS | L_CBUTTONS | R_CBUTTONS )\n"
"HOOK_UPDATE = 0\n"
"HOOK_MARIO_UPDATE = 1\n"
diff --git a/src/pc/lua/smlua_functions_autogen.c b/src/pc/lua/smlua_functions_autogen.c
index 6e38319c0..e31786135 100644
--- a/src/pc/lua/smlua_functions_autogen.c
+++ b/src/pc/lua/smlua_functions_autogen.c
@@ -52,6 +52,38 @@ int smlua_func_get_id_from_behavior(lua_State* L) {
// camera.h //
//////////////
+int smlua_func_set_camera_mode(lua_State* L) {
+ if(!smlua_functions_valid_param_count(L, 3)) { return 0; }
+
+ struct Camera* c = (struct Camera*)smlua_to_cobject(L, 1, LOT_CAMERA);
+ if (!gSmLuaConvertSuccess) { return 0; }
+ s16 mode = smlua_to_integer(L, 2);
+ if (!gSmLuaConvertSuccess) { return 0; }
+ s16 frames = smlua_to_integer(L, 3);
+ if (!gSmLuaConvertSuccess) { return 0; }
+
+ set_camera_mode(c, mode, frames);
+
+ return 1;
+}
+
+int smlua_func_set_camera_mode_fixed(lua_State* L) {
+ if(!smlua_functions_valid_param_count(L, 4)) { return 0; }
+
+ struct Camera* c = (struct Camera*)smlua_to_cobject(L, 1, LOT_CAMERA);
+ if (!gSmLuaConvertSuccess) { return 0; }
+ s16 x = smlua_to_integer(L, 2);
+ if (!gSmLuaConvertSuccess) { return 0; }
+ s16 y = smlua_to_integer(L, 3);
+ if (!gSmLuaConvertSuccess) { return 0; }
+ s16 z = smlua_to_integer(L, 4);
+ if (!gSmLuaConvertSuccess) { return 0; }
+
+ lua_pushinteger(L, set_camera_mode_fixed(c, x, y, z));
+
+ return 1;
+}
+
int smlua_func_set_camera_pitch_shake(lua_State* L) {
if(!smlua_functions_valid_param_count(L, 3)) { return 0; }
@@ -136,21 +168,6 @@ int smlua_func_set_environmental_camera_shake(lua_State* L) {
return 1;
}
-int smlua_func_set_camera_mode(lua_State* L) {
- if(!smlua_functions_valid_param_count(L, 3)) { return 0; }
-
- struct Camera* c = (struct Camera *) smlua_to_cobject(L, 1, LOT_CAMERA);
- if (!gSmLuaConvertSuccess) { return 0; }
- s16 mode = smlua_to_integer(L, 2);
- if (!gSmLuaConvertSuccess) { return 0; }
- s16 frames = smlua_to_integer(L, 3);
- if (!gSmLuaConvertSuccess) { return 0; }
-
- set_camera_mode(c, mode, frames);
-
- return 1;
-}
-
//////////////////
// characters.h //
//////////////////
@@ -5301,6 +5318,110 @@ int smlua_func_save_file_get_total_star_count(lua_State* L) {
// smlua_obj_utils.h //
///////////////////////
+int smlua_func_obj_get_first(lua_State* L) {
+ if(!smlua_functions_valid_param_count(L, 1)) { return 0; }
+
+ int objList = smlua_to_integer(L, 1);
+ if (!gSmLuaConvertSuccess) { return 0; }
+
+ smlua_push_object(L, LOT_OBJECT, obj_get_first(objList));
+
+ return 1;
+}
+
+int smlua_func_obj_get_first_with_behavior_id(lua_State* L) {
+ if(!smlua_functions_valid_param_count(L, 1)) { return 0; }
+
+ int behaviorId = smlua_to_integer(L, 1);
+ if (!gSmLuaConvertSuccess) { return 0; }
+
+ smlua_push_object(L, LOT_OBJECT, obj_get_first_with_behavior_id(behaviorId));
+
+ return 1;
+}
+
+int smlua_func_obj_get_first_with_behavior_id_and_field_f32(lua_State* L) {
+ if(!smlua_functions_valid_param_count(L, 3)) { return 0; }
+
+ int behaviorId = smlua_to_integer(L, 1);
+ if (!gSmLuaConvertSuccess) { return 0; }
+ s32 fieldIndex = smlua_to_integer(L, 2);
+ if (!gSmLuaConvertSuccess) { return 0; }
+ f32 value = smlua_to_number(L, 3);
+ if (!gSmLuaConvertSuccess) { return 0; }
+
+ smlua_push_object(L, LOT_OBJECT, obj_get_first_with_behavior_id_and_field_f32(behaviorId, fieldIndex, value));
+
+ return 1;
+}
+
+int smlua_func_obj_get_first_with_behavior_id_and_field_s32(lua_State* L) {
+ if(!smlua_functions_valid_param_count(L, 3)) { return 0; }
+
+ int behaviorId = smlua_to_integer(L, 1);
+ if (!gSmLuaConvertSuccess) { return 0; }
+ s32 fieldIndex = smlua_to_integer(L, 2);
+ if (!gSmLuaConvertSuccess) { return 0; }
+ s32 value = smlua_to_integer(L, 3);
+ if (!gSmLuaConvertSuccess) { return 0; }
+
+ smlua_push_object(L, LOT_OBJECT, obj_get_first_with_behavior_id_and_field_s32(behaviorId, fieldIndex, value));
+
+ return 1;
+}
+
+int smlua_func_obj_get_next(lua_State* L) {
+ if(!smlua_functions_valid_param_count(L, 1)) { return 0; }
+
+ struct Object* o = (struct Object*)smlua_to_cobject(L, 1, LOT_OBJECT);
+ if (!gSmLuaConvertSuccess) { return 0; }
+
+ smlua_push_object(L, LOT_OBJECT, obj_get_next(o));
+
+ return 1;
+}
+
+int smlua_func_obj_get_next_with_same_behavior_id(lua_State* L) {
+ if(!smlua_functions_valid_param_count(L, 1)) { return 0; }
+
+ struct Object* o = (struct Object*)smlua_to_cobject(L, 1, LOT_OBJECT);
+ if (!gSmLuaConvertSuccess) { return 0; }
+
+ smlua_push_object(L, LOT_OBJECT, obj_get_next_with_same_behavior_id(o));
+
+ return 1;
+}
+
+int smlua_func_obj_get_next_with_same_behavior_id_and_field_f32(lua_State* L) {
+ if(!smlua_functions_valid_param_count(L, 3)) { return 0; }
+
+ struct Object* o = (struct Object*)smlua_to_cobject(L, 1, LOT_OBJECT);
+ if (!gSmLuaConvertSuccess) { return 0; }
+ s32 fieldIndex = smlua_to_integer(L, 2);
+ if (!gSmLuaConvertSuccess) { return 0; }
+ f32 value = smlua_to_number(L, 3);
+ if (!gSmLuaConvertSuccess) { return 0; }
+
+ smlua_push_object(L, LOT_OBJECT, obj_get_next_with_same_behavior_id_and_field_f32(o, fieldIndex, value));
+
+ return 1;
+}
+
+int smlua_func_obj_get_next_with_same_behavior_id_and_field_s32(lua_State* L) {
+ if(!smlua_functions_valid_param_count(L, 3)) { return 0; }
+
+ struct Object* o = (struct Object*)smlua_to_cobject(L, 1, LOT_OBJECT);
+ if (!gSmLuaConvertSuccess) { return 0; }
+ s32 fieldIndex = smlua_to_integer(L, 2);
+ if (!gSmLuaConvertSuccess) { return 0; }
+ s32 value = smlua_to_integer(L, 3);
+ if (!gSmLuaConvertSuccess) { return 0; }
+
+ smlua_push_object(L, LOT_OBJECT, obj_get_next_with_same_behavior_id_and_field_s32(o, fieldIndex, value));
+
+ return 1;
+}
+
int smlua_func_spawn_sync_object(lua_State* L) {
if(!smlua_functions_valid_param_count(L, 6)) { return 0; }
@@ -5322,110 +5443,6 @@ int smlua_func_spawn_sync_object(lua_State* L) {
return 1;
}
-int smlua_func_obj_get_first(lua_State *L) {
- if(!smlua_functions_valid_param_count(L, 1)) { return 0; }
-
- int objList = smlua_to_integer(L, 1);
- if (!gSmLuaConvertSuccess) { return 0; }
-
- smlua_push_object(L, LOT_OBJECT, obj_get_first(objList));
-
- return 1;
-}
-
-int smlua_func_obj_get_first_with_behavior_id(lua_State *L) {
- if(!smlua_functions_valid_param_count(L, 1)) { return 0; }
-
- int behaviorId = smlua_to_integer(L, 1);
- if (!gSmLuaConvertSuccess) { return 0; }
-
- smlua_push_object(L, LOT_OBJECT, obj_get_first_with_behavior_id(behaviorId));
-
- return 1;
-}
-
-int smlua_func_obj_get_first_with_behavior_id_and_field_s32(lua_State *L) {
- if(!smlua_functions_valid_param_count(L, 3)) { return 0; }
-
- int behaviorId = smlua_to_integer(L, 1);
- if (!gSmLuaConvertSuccess) { return 0; }
- int fieldIndex = smlua_to_integer(L, 2);
- if (!gSmLuaConvertSuccess) { return 0; }
- int value = smlua_to_integer(L, 3);
- if (!gSmLuaConvertSuccess) { return 0; }
-
- smlua_push_object(L, LOT_OBJECT, obj_get_first_with_behavior_id_and_field_s32(behaviorId, fieldIndex, value));
-
- return 1;
-}
-
-int smlua_func_obj_get_first_with_behavior_id_and_field_f32(lua_State *L) {
- if(!smlua_functions_valid_param_count(L, 3)) { return 0; }
-
- int behaviorId = smlua_to_integer(L, 1);
- if (!gSmLuaConvertSuccess) { return 0; }
- int fieldIndex = smlua_to_integer(L, 2);
- if (!gSmLuaConvertSuccess) { return 0; }
- float value = smlua_to_number(L, 3);
- if (!gSmLuaConvertSuccess) { return 0; }
-
- smlua_push_object(L, LOT_OBJECT, obj_get_first_with_behavior_id_and_field_f32(behaviorId, fieldIndex, value));
-
- return 1;
-}
-
-int smlua_func_obj_get_next(lua_State *L) {
- if(!smlua_functions_valid_param_count(L, 1)) { return 0; }
-
- struct Object *o = (struct Object *) smlua_to_cobject(L, 1, LOT_OBJECT);
- if (!gSmLuaConvertSuccess) { return 0; }
-
- smlua_push_object(L, LOT_OBJECT, obj_get_next(o));
-
- return 1;
-}
-
-int smlua_func_obj_get_next_with_same_behavior_id(lua_State *L) {
- if(!smlua_functions_valid_param_count(L, 1)) { return 0; }
-
- struct Object *o = (struct Object *) smlua_to_cobject(L, 1, LOT_OBJECT);
- if (!gSmLuaConvertSuccess) { return 0; }
-
- smlua_push_object(L, LOT_OBJECT, obj_get_next_with_same_behavior_id(o));
-
- return 1;
-}
-
-int smlua_func_obj_get_next_with_same_behavior_id_and_field_s32(lua_State *L) {
- if(!smlua_functions_valid_param_count(L, 3)) { return 0; }
-
- struct Object *o = (struct Object *) smlua_to_cobject(L, 1, LOT_OBJECT);
- if (!gSmLuaConvertSuccess) { return 0; }
- int fieldIndex = smlua_to_integer(L, 2);
- if (!gSmLuaConvertSuccess) { return 0; }
- int value = smlua_to_integer(L, 3);
- if (!gSmLuaConvertSuccess) { return 0; }
-
- smlua_push_object(L, LOT_OBJECT, obj_get_next_with_same_behavior_id_and_field_s32(o, fieldIndex, value));
-
- return 1;
-}
-
-int smlua_func_obj_get_next_with_same_behavior_id_and_field_f32(lua_State *L) {
- if(!smlua_functions_valid_param_count(L, 3)) { return 0; }
-
- struct Object *o = (struct Object *) smlua_to_cobject(L, 1, LOT_OBJECT);
- if (!gSmLuaConvertSuccess) { return 0; }
- int fieldIndex = smlua_to_integer(L, 2);
- if (!gSmLuaConvertSuccess) { return 0; }
- float value = smlua_to_number(L, 3);
- if (!gSmLuaConvertSuccess) { return 0; }
-
- smlua_push_object(L, LOT_OBJECT, obj_get_next_with_same_behavior_id_and_field_f32(o, fieldIndex, value));
-
- return 1;
-}
-
//////////////////
// sound_init.h //
//////////////////
@@ -5825,13 +5842,14 @@ void smlua_bind_functions_autogen(void) {
smlua_bind_function(L, "get_id_from_behavior", smlua_func_get_id_from_behavior);
// camera.h
+ smlua_bind_function(L, "set_camera_mode", smlua_func_set_camera_mode);
+ smlua_bind_function(L, "set_camera_mode_fixed", smlua_func_set_camera_mode_fixed);
smlua_bind_function(L, "set_camera_pitch_shake", smlua_func_set_camera_pitch_shake);
smlua_bind_function(L, "set_camera_roll_shake", smlua_func_set_camera_roll_shake);
smlua_bind_function(L, "set_camera_shake_from_hit", smlua_func_set_camera_shake_from_hit);
smlua_bind_function(L, "set_camera_shake_from_point", smlua_func_set_camera_shake_from_point);
smlua_bind_function(L, "set_camera_yaw_shake", smlua_func_set_camera_yaw_shake);
smlua_bind_function(L, "set_environmental_camera_shake", smlua_func_set_environmental_camera_shake);
- smlua_bind_function(L, "set_camera_mode", smlua_func_set_camera_mode);
// characters.h
smlua_bind_function(L, "get_character", smlua_func_get_character);
@@ -6241,15 +6259,15 @@ 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_sync_object", smlua_func_spawn_sync_object);
smlua_bind_function(L, "obj_get_first", smlua_func_obj_get_first);
smlua_bind_function(L, "obj_get_first_with_behavior_id", smlua_func_obj_get_first_with_behavior_id);
- smlua_bind_function(L, "obj_get_first_with_behavior_id_and_field_s32", smlua_func_obj_get_first_with_behavior_id_and_field_s32);
smlua_bind_function(L, "obj_get_first_with_behavior_id_and_field_f32", smlua_func_obj_get_first_with_behavior_id_and_field_f32);
+ smlua_bind_function(L, "obj_get_first_with_behavior_id_and_field_s32", smlua_func_obj_get_first_with_behavior_id_and_field_s32);
smlua_bind_function(L, "obj_get_next", smlua_func_obj_get_next);
smlua_bind_function(L, "obj_get_next_with_same_behavior_id", smlua_func_obj_get_next_with_same_behavior_id);
- smlua_bind_function(L, "obj_get_next_with_same_behavior_id_and_field_s32", smlua_func_obj_get_next_with_same_behavior_id_and_field_s32);
smlua_bind_function(L, "obj_get_next_with_same_behavior_id_and_field_f32", smlua_func_obj_get_next_with_same_behavior_id_and_field_f32);
+ smlua_bind_function(L, "obj_get_next_with_same_behavior_id_and_field_s32", smlua_func_obj_get_next_with_same_behavior_id_and_field_s32);
+ 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);