From 3707ca9b2e885c43105c05fa75b4ec6e489053cc Mon Sep 17 00:00:00 2001 From: Agent X <44549182+AgentXLP@users.noreply.github.com> Date: Fri, 21 Jun 2024 23:26:13 -0400 Subject: [PATCH] Separate some smlua_misc_utils functions into their own files & add get/set_skybox_color --- autogen/convert_functions.py | 2 + autogen/convert_structs.py | 1 + autogen/lua_definitions/functions.lua | 452 +++--- docs/lua/functions-5.md | 1817 +++++++++++---------- docs/lua/functions.md | 96 +- src/game/bettercamera.inc.h | 2 +- src/game/first_person_cam.c | 2 +- src/game/object_helpers.c | 2 +- src/game/skybox.c | 22 +- src/game/skybox.h | 1 + src/pc/lua/smlua_cobject_autogen.c | 1 + src/pc/lua/smlua_functions_autogen.c | 2140 +++++++++++++------------ src/pc/lua/utils/smlua_camera_utils.c | 154 ++ src/pc/lua/utils/smlua_camera_utils.h | 43 + src/pc/lua/utils/smlua_gfx_utils.c | 94 ++ src/pc/lua/utils/smlua_gfx_utils.h | 29 + src/pc/lua/utils/smlua_misc_utils.c | 236 --- src/pc/lua/utils/smlua_misc_utils.h | 57 - src/pc/mods/mod.h | 2 +- src/pc/mods/mod_import.c | 2 +- src/pc/mods/mods.h | 2 +- src/pc/mods/mods_utils.h | 2 +- src/pc/network/network.c | 1 + src/pc/network/network.h | 2 +- src/pc/network/packets/packet.h | 2 +- 25 files changed, 2664 insertions(+), 2500 deletions(-) create mode 100644 src/pc/lua/utils/smlua_camera_utils.c create mode 100644 src/pc/lua/utils/smlua_camera_utils.h create mode 100644 src/pc/lua/utils/smlua_gfx_utils.c create mode 100644 src/pc/lua/utils/smlua_gfx_utils.h diff --git a/autogen/convert_functions.py b/autogen/convert_functions.py index 41ac91b4..c89acd14 100644 --- a/autogen/convert_functions.py +++ b/autogen/convert_functions.py @@ -42,6 +42,8 @@ in_files = [ "include/behavior_table.h", "src/pc/lua/utils/smlua_obj_utils.h", "src/pc/lua/utils/smlua_misc_utils.h", + "src/pc/lua/utils/smlua_camera_utils.h", + "src/pc/lua/utils/smlua_gfx_utils.h", "src/pc/lua/utils/smlua_collision_utils.h", "src/pc/lua/utils/smlua_math_utils.h", "src/pc/lua/utils/smlua_model_utils.h", diff --git a/autogen/convert_structs.py b/autogen/convert_structs.py index 6a53e222..354ef9cd 100644 --- a/autogen/convert_structs.py +++ b/autogen/convert_structs.py @@ -17,6 +17,7 @@ in_files = [ "src/game/mario_step.h", "src/pc/lua/utils/smlua_anim_utils.h", "src/pc/lua/utils/smlua_misc_utils.h", + "src/pc/lua/utils/smlua_camera_utils.h", "src/pc/lua/utils/smlua_collision_utils.h", "src/pc/lua/utils/smlua_level_utils.h", "src/game/spawn_sound.h", diff --git a/autogen/lua_definitions/functions.lua b/autogen/lua_definitions/functions.lua index 2381b511..35bcbbe1 100644 --- a/autogen/lua_definitions/functions.lua +++ b/autogen/lua_definitions/functions.lua @@ -7594,6 +7594,143 @@ function smlua_audio_utils_reset_all() -- ... end +--- @param allow integer +function camera_allow_toxic_gas_camera(allow) + -- ... +end + +--- @param enable boolean +function camera_config_enable_analog_cam(enable) + -- ... +end + +--- @param enable boolean +function camera_config_enable_free_cam(enable) + -- ... +end + +--- @param enable boolean +function camera_config_enable_mouse_look(enable) + -- ... +end + +--- @return integer +function camera_config_get_aggression() + -- ... +end + +--- @return integer +function camera_config_get_deceleration() + -- ... +end + +--- @return integer +function camera_config_get_pan_level() + -- ... +end + +--- @return integer +function camera_config_get_x_sensitivity() + -- ... +end + +--- @return integer +function camera_config_get_y_sensitivity() + -- ... +end + +--- @param invert boolean +function camera_config_invert_x(invert) + -- ... +end + +--- @param invert boolean +function camera_config_invert_y(invert) + -- ... +end + +--- @return boolean +function camera_config_is_analog_cam_enabled() + -- ... +end + +--- @return boolean +function camera_config_is_free_cam_enabled() + -- ... +end + +--- @return boolean +function camera_config_is_mouse_look_enabled() + -- ... +end + +--- @return boolean +function camera_config_is_x_inverted() + -- ... +end + +--- @return boolean +function camera_config_is_y_inverted() + -- ... +end + +--- @param value integer +function camera_config_set_aggression(value) + -- ... +end + +--- @param value integer +function camera_config_set_deceleration(value) + -- ... +end + +--- @param value integer +function camera_config_set_pan_level(value) + -- ... +end + +--- @param value integer +function camera_config_set_x_sensitivity(value) + -- ... +end + +--- @param value integer +function camera_config_set_y_sensitivity(value) + -- ... +end + +function camera_freeze() + -- ... +end + +--- @return boolean +function camera_is_frozen() + -- ... +end + +function camera_reset_overrides() + -- ... +end + +--- @param allow integer +function camera_romhack_allow_centering(allow) + -- ... +end + +--- @param allow integer +function camera_romhack_allow_dpad_usage(allow) + -- ... +end + +--- @param rco RomhackCameraOverride +function camera_set_romhack_override(rco) + -- ... +end + +function camera_unfreeze() + -- ... +end + --- @param x number --- @param y number --- @param z number @@ -7696,6 +7833,101 @@ function set_environment_region(index, value) -- ... end +--- @param index integer +--- @return integer +function get_fog_color(index) + -- ... +end + +--- @return number +function get_fog_intensity() + -- ... +end + +--- @param index integer +--- @return integer +function get_lighting_color(index) + -- ... +end + +--- @param index integer +--- @return number +function get_lighting_dir(index) + -- ... +end + +--- @return integer +function get_skybox() + -- ... +end + +--- @param index integer +--- @return integer +function get_skybox_color(index) + -- ... +end + +--- @param index integer +--- @return integer +function get_vertex_color(index) + -- ... +end + +--- @param index integer +--- @param value integer +function set_fog_color(index, value) + -- ... +end + +--- @param intensity number +function set_fog_intensity(intensity) + -- ... +end + +--- @param index integer +--- @param value integer +function set_lighting_color(index, value) + -- ... +end + +--- @param index integer +--- @param value number +function set_lighting_dir(index, value) + -- ... +end + +--- @param far number +function set_override_far(far) + -- ... +end + +--- @param fov number +function set_override_fov(fov) + -- ... +end + +--- @param near number +function set_override_near(near) + -- ... +end + +--- @param background integer +function set_override_skybox(background) + -- ... +end + +--- @param index integer +--- @param value integer +function set_skybox_color(index, value) + -- ... +end + +--- @param index integer +--- @param value integer +function set_vertex_color(index, value) + -- ... +end + --- @param levelNum integer --- @return boolean function level_is_vanilla_level(levelNum) @@ -7839,143 +8071,6 @@ function allocate_mario_action(actFlags) -- ... end ---- @param allow integer -function camera_allow_toxic_gas_camera(allow) - -- ... -end - ---- @param enable boolean -function camera_config_enable_analog_cam(enable) - -- ... -end - ---- @param enable boolean -function camera_config_enable_free_cam(enable) - -- ... -end - ---- @param enable boolean -function camera_config_enable_mouse_look(enable) - -- ... -end - ---- @return integer -function camera_config_get_aggression() - -- ... -end - ---- @return integer -function camera_config_get_deceleration() - -- ... -end - ---- @return integer -function camera_config_get_pan_level() - -- ... -end - ---- @return integer -function camera_config_get_x_sensitivity() - -- ... -end - ---- @return integer -function camera_config_get_y_sensitivity() - -- ... -end - ---- @param invert boolean -function camera_config_invert_x(invert) - -- ... -end - ---- @param invert boolean -function camera_config_invert_y(invert) - -- ... -end - ---- @return boolean -function camera_config_is_analog_cam_enabled() - -- ... -end - ---- @return boolean -function camera_config_is_free_cam_enabled() - -- ... -end - ---- @return boolean -function camera_config_is_mouse_look_enabled() - -- ... -end - ---- @return boolean -function camera_config_is_x_inverted() - -- ... -end - ---- @return boolean -function camera_config_is_y_inverted() - -- ... -end - ---- @param value integer -function camera_config_set_aggression(value) - -- ... -end - ---- @param value integer -function camera_config_set_deceleration(value) - -- ... -end - ---- @param value integer -function camera_config_set_pan_level(value) - -- ... -end - ---- @param value integer -function camera_config_set_x_sensitivity(value) - -- ... -end - ---- @param value integer -function camera_config_set_y_sensitivity(value) - -- ... -end - -function camera_freeze() - -- ... -end - ---- @return boolean -function camera_is_frozen() - -- ... -end - -function camera_reset_overrides() - -- ... -end - ---- @param allow integer -function camera_romhack_allow_centering(allow) - -- ... -end - ---- @param allow integer -function camera_romhack_allow_dpad_usage(allow) - -- ... -end - ---- @param rco RomhackCameraOverride -function camera_set_romhack_override(rco) - -- ... -end - -function camera_unfreeze() - -- ... -end - --- @param courseNum integer --- @return boolean function course_is_main_course(courseNum) @@ -8043,17 +8138,6 @@ function get_envfx() -- ... end ---- @param index integer ---- @return integer -function get_fog_color(index) - -- ... -end - ---- @return number -function get_fog_intensity() - -- ... -end - --- @return integer function get_global_timer() -- ... @@ -8100,18 +8184,6 @@ function get_last_star_or_key() -- ... end ---- @param index integer ---- @return integer -function get_lighting_color(index) - -- ... -end - ---- @param index integer ---- @return number -function get_lighting_dir(index) - -- ... -end - --- @return string function get_local_discord_id() -- ... @@ -8132,11 +8204,6 @@ function get_save_file_modified() -- ... end ---- @return integer -function get_skybox() - -- ... -end - --- @param initialValue integer --- @return Pointer_integer function get_temp_s32_pointer(initialValue) @@ -8153,12 +8220,6 @@ function get_ttc_speed_setting() -- ... end ---- @param index integer ---- @return integer -function get_vertex_color(index) - -- ... -end - --- @return number function get_volume_env() -- ... @@ -8283,17 +8344,6 @@ function save_file_set_using_backup_slot(usingBackupSlot) -- ... end ---- @param index integer ---- @param value integer -function set_fog_color(index, value) - -- ... -end - ---- @param intensity number -function set_fog_intensity(intensity) - -- ... -end - --- @param value boolean function set_got_file_coin_hi_score(value) -- ... @@ -8314,43 +8364,11 @@ function set_last_star_or_key(value) -- ... end ---- @param index integer ---- @param value integer -function set_lighting_color(index, value) - -- ... -end - ---- @param index integer ---- @param value number -function set_lighting_dir(index, value) - -- ... -end - --- @param envfx integer function set_override_envfx(envfx) -- ... end ---- @param far number -function set_override_far(far) - -- ... -end - ---- @param fov number -function set_override_fov(fov) - -- ... -end - ---- @param near number -function set_override_near(near) - -- ... -end - ---- @param background integer -function set_override_skybox(background) - -- ... -end - --- @param value boolean function set_save_file_modified(value) -- ... @@ -8361,12 +8379,6 @@ function set_ttc_speed_setting(speed) -- ... end ---- @param index integer ---- @param value integer -function set_vertex_color(index, value) - -- ... -end - --- @param volume number function set_volume_env(volume) -- ... diff --git a/docs/lua/functions-5.md b/docs/lua/functions-5.md index 1786e256..ae73a115 100644 --- a/docs/lua/functions-5.md +++ b/docs/lua/functions-5.md @@ -401,592 +401,11 @@
--- -# functions from smlua_collision_utils.h +# functions from smlua_camera_utils.h
-## [collision_find_ceil](#collision_find_ceil) - -### Lua Example -`local SurfaceValue = collision_find_ceil(x, y, z)` - -### Parameters -| Field | Type | -| ----- | ---- | -| x | `number` | -| y | `number` | -| z | `number` | - -### Returns -[Surface](structs.md#Surface) - -### C Prototype -`struct Surface* collision_find_ceil(f32 x, f32 y, f32 z);` - -[:arrow_up_small:](#) - -
- -## [collision_find_floor](#collision_find_floor) - -### Lua Example -`local SurfaceValue = collision_find_floor(x, y, z)` - -### Parameters -| Field | Type | -| ----- | ---- | -| x | `number` | -| y | `number` | -| z | `number` | - -### Returns -[Surface](structs.md#Surface) - -### C Prototype -`struct Surface* collision_find_floor(f32 x, f32 y, f32 z);` - -[:arrow_up_small:](#) - -
- -## [collision_get_temp_wall_collision_data](#collision_get_temp_wall_collision_data) - -### Lua Example -`local WallCollisionDataValue = collision_get_temp_wall_collision_data()` - -### Parameters -- None - -### Returns -[WallCollisionData](structs.md#WallCollisionData) - -### C Prototype -`struct WallCollisionData* collision_get_temp_wall_collision_data(void);` - -[:arrow_up_small:](#) - -
- -## [get_surface_from_wcd_index](#get_surface_from_wcd_index) - -### Lua Example -`local SurfaceValue = get_surface_from_wcd_index(wcd, index)` - -### Parameters -| Field | Type | -| ----- | ---- | -| wcd | [WallCollisionData](structs.md#WallCollisionData) | -| index | `integer` | - -### Returns -[Surface](structs.md#Surface) - -### C Prototype -`struct Surface* get_surface_from_wcd_index(struct WallCollisionData* wcd, s8 index);` - -[:arrow_up_small:](#) - -
- -## [get_water_surface_pseudo_floor](#get_water_surface_pseudo_floor) - -### Lua Example -`local SurfaceValue = get_water_surface_pseudo_floor()` - -### Parameters -- None - -### Returns -[Surface](structs.md#Surface) - -### C Prototype -`struct Surface* get_water_surface_pseudo_floor(void);` - -[:arrow_up_small:](#) - -
- -## [smlua_collision_util_get](#smlua_collision_util_get) - -### Lua Example -`local PointerValue = smlua_collision_util_get(name)` - -### Parameters -| Field | Type | -| ----- | ---- | -| name | `string` | - -### Returns -- `Pointer` <`Collision`> - -### C Prototype -`Collision* smlua_collision_util_get(const char* name);` - -[:arrow_up_small:](#) - -
- ---- -# functions from smlua_deprecated.h - -
- - ---- -# functions from smlua_level_utils.h - -
- - -## [level_is_vanilla_level](#level_is_vanilla_level) - -### Lua Example -`local booleanValue = level_is_vanilla_level(levelNum)` - -### Parameters -| Field | Type | -| ----- | ---- | -| levelNum | `integer` | - -### Returns -- `boolean` - -### C Prototype -`bool level_is_vanilla_level(s16 levelNum);` - -[:arrow_up_small:](#) - -
- -## [level_register](#level_register) - -### Lua Example -`local integerValue = level_register(scriptEntryName, courseNum, fullName, shortName, acousticReach, echoLevel1, echoLevel2, echoLevel3)` - -### Parameters -| Field | Type | -| ----- | ---- | -| scriptEntryName | `string` | -| courseNum | `integer` | -| fullName | `string` | -| shortName | `string` | -| acousticReach | `integer` | -| echoLevel1 | `integer` | -| echoLevel2 | `integer` | -| echoLevel3 | `integer` | - -### Returns -- `integer` - -### C Prototype -`s16 level_register(const char* scriptEntryName, s16 courseNum, const char* fullName, const char* shortName, u32 acousticReach, u32 echoLevel1, u32 echoLevel2, u32 echoLevel3);` - -[:arrow_up_small:](#) - -
- -## [smlua_level_util_change_area](#smlua_level_util_change_area) - -### Lua Example -`smlua_level_util_change_area(areaIndex)` - -### Parameters -| Field | Type | -| ----- | ---- | -| areaIndex | `integer` | - -### Returns -- None - -### C Prototype -`void smlua_level_util_change_area(s32 areaIndex);` - -[:arrow_up_small:](#) - -
- -## [smlua_level_util_get_info](#smlua_level_util_get_info) - -### Lua Example -`local CustomLevelInfoValue = smlua_level_util_get_info(levelNum)` - -### Parameters -| Field | Type | -| ----- | ---- | -| levelNum | `integer` | - -### Returns -[CustomLevelInfo](structs.md#CustomLevelInfo) - -### C Prototype -`struct CustomLevelInfo* smlua_level_util_get_info(s16 levelNum);` - -[:arrow_up_small:](#) - -
- -## [smlua_level_util_get_info_from_course_num](#smlua_level_util_get_info_from_course_num) - -### Lua Example -`local CustomLevelInfoValue = smlua_level_util_get_info_from_course_num(courseNum)` - -### Parameters -| Field | Type | -| ----- | ---- | -| courseNum | `integer` | - -### Returns -[CustomLevelInfo](structs.md#CustomLevelInfo) - -### C Prototype -`struct CustomLevelInfo* smlua_level_util_get_info_from_course_num(u8 courseNum);` - -[:arrow_up_small:](#) - -
- -## [smlua_level_util_get_info_from_short_name](#smlua_level_util_get_info_from_short_name) - -### Lua Example -`local CustomLevelInfoValue = smlua_level_util_get_info_from_short_name(shortName)` - -### Parameters -| Field | Type | -| ----- | ---- | -| shortName | `string` | - -### Returns -[CustomLevelInfo](structs.md#CustomLevelInfo) - -### C Prototype -`struct CustomLevelInfo* smlua_level_util_get_info_from_short_name(const char* shortName);` - -[:arrow_up_small:](#) - -
- -## [warp_exit_level](#warp_exit_level) - -### Lua Example -`local booleanValue = warp_exit_level(aDelay)` - -### Parameters -| Field | Type | -| ----- | ---- | -| aDelay | `integer` | - -### Returns -- `boolean` - -### C Prototype -`bool warp_exit_level(s32 aDelay);` - -[:arrow_up_small:](#) - -
- -## [warp_restart_level](#warp_restart_level) - -### Lua Example -`local booleanValue = warp_restart_level()` - -### Parameters -- None - -### Returns -- `boolean` - -### C Prototype -`bool warp_restart_level(void);` - -[:arrow_up_small:](#) - -
- -## [warp_to_castle](#warp_to_castle) - -### Lua Example -`local booleanValue = warp_to_castle(aLevel)` - -### Parameters -| Field | Type | -| ----- | ---- | -| aLevel | `integer` | - -### Returns -- `boolean` - -### C Prototype -`bool warp_to_castle(s32 aLevel);` - -[:arrow_up_small:](#) - -
- -## [warp_to_level](#warp_to_level) - -### Lua Example -`local booleanValue = warp_to_level(aLevel, aArea, aAct)` - -### Parameters -| Field | Type | -| ----- | ---- | -| aLevel | `integer` | -| aArea | `integer` | -| aAct | `integer` | - -### Returns -- `boolean` - -### C Prototype -`bool warp_to_level(s32 aLevel, s32 aArea, s32 aAct);` - -[:arrow_up_small:](#) - -
- -## [warp_to_start_level](#warp_to_start_level) - -### Lua Example -`local booleanValue = warp_to_start_level()` - -### Parameters -- None - -### Returns -- `boolean` - -### C Prototype -`bool warp_to_start_level(void);` - -[:arrow_up_small:](#) - -
- -## [warp_to_warpnode](#warp_to_warpnode) - -### Lua Example -`local booleanValue = warp_to_warpnode(aLevel, aArea, aAct, aWarpId)` - -### Parameters -| Field | Type | -| ----- | ---- | -| aLevel | `integer` | -| aArea | `integer` | -| aAct | `integer` | -| aWarpId | `integer` | - -### Returns -- `boolean` - -### C Prototype -`bool warp_to_warpnode(s32 aLevel, s32 aArea, s32 aAct, s32 aWarpId);` - -[:arrow_up_small:](#) - -
- ---- -# functions from smlua_math_utils.h - -
- - -## [clamp](#clamp) - -### Lua Example -`local integerValue = clamp(a, b, c)` - -### Parameters -| Field | Type | -| ----- | ---- | -| a | `integer` | -| b | `integer` | -| c | `integer` | - -### Returns -- `integer` - -### C Prototype -`s32 clamp(s32 a, s32 b, s32 c);` - -[:arrow_up_small:](#) - -
- -## [clampf](#clampf) - -### Lua Example -`local numberValue = clampf(a, b, c)` - -### Parameters -| Field | Type | -| ----- | ---- | -| a | `number` | -| b | `number` | -| c | `number` | - -### Returns -- `number` - -### C Prototype -`f32 clampf(f32 a, f32 b, f32 c);` - -[:arrow_up_small:](#) - -
- -## [max](#max) - -### Lua Example -`local integerValue = max(a, b)` - -### Parameters -| Field | Type | -| ----- | ---- | -| a | `integer` | -| b | `integer` | - -### Returns -- `integer` - -### C Prototype -`s32 max(s32 a, s32 b);` - -[:arrow_up_small:](#) - -
- -## [maxf](#maxf) - -### Lua Example -`local numberValue = maxf(a, b)` - -### Parameters -| Field | Type | -| ----- | ---- | -| a | `number` | -| b | `number` | - -### Returns -- `number` - -### C Prototype -`f32 maxf(f32 a, f32 b);` - -[:arrow_up_small:](#) - -
- -## [min](#min) - -### Lua Example -`local integerValue = min(a, b)` - -### Parameters -| Field | Type | -| ----- | ---- | -| a | `integer` | -| b | `integer` | - -### Returns -- `integer` - -### C Prototype -`s32 min(s32 a, s32 b);` - -[:arrow_up_small:](#) - -
- -## [minf](#minf) - -### Lua Example -`local numberValue = minf(a, b)` - -### Parameters -| Field | Type | -| ----- | ---- | -| a | `number` | -| b | `number` | - -### Returns -- `number` - -### C Prototype -`f32 minf(f32 a, f32 b);` - -[:arrow_up_small:](#) - -
- -## [sqr](#sqr) - -### Lua Example -`local integerValue = sqr(x)` - -### Parameters -| Field | Type | -| ----- | ---- | -| x | `integer` | - -### Returns -- `integer` - -### C Prototype -`s32 sqr(s32 x);` - -[:arrow_up_small:](#) - -
- -## [sqrf](#sqrf) - -### Lua Example -`local numberValue = sqrf(x)` - -### Parameters -| Field | Type | -| ----- | ---- | -| x | `number` | - -### Returns -- `number` - -### C Prototype -`f32 sqrf(f32 x);` - -[:arrow_up_small:](#) - -
- ---- -# functions from smlua_misc_utils.h - -
- - -## [allocate_mario_action](#allocate_mario_action) - -### Lua Example -`local integerValue = allocate_mario_action(actFlags)` - -### Parameters -| Field | Type | -| ----- | ---- | -| actFlags | `integer` | - -### Returns -- `integer` - -### C Prototype -`u32 allocate_mario_action(u32 actFlags);` - -[:arrow_up_small:](#) - -
- ## [camera_allow_toxic_gas_camera](#camera_allow_toxic_gas_camera) ### Lua Example @@ -1519,6 +938,940 @@
+--- +# functions from smlua_collision_utils.h + +
+ + +## [collision_find_ceil](#collision_find_ceil) + +### Lua Example +`local SurfaceValue = collision_find_ceil(x, y, z)` + +### Parameters +| Field | Type | +| ----- | ---- | +| x | `number` | +| y | `number` | +| z | `number` | + +### Returns +[Surface](structs.md#Surface) + +### C Prototype +`struct Surface* collision_find_ceil(f32 x, f32 y, f32 z);` + +[:arrow_up_small:](#) + +
+ +## [collision_find_floor](#collision_find_floor) + +### Lua Example +`local SurfaceValue = collision_find_floor(x, y, z)` + +### Parameters +| Field | Type | +| ----- | ---- | +| x | `number` | +| y | `number` | +| z | `number` | + +### Returns +[Surface](structs.md#Surface) + +### C Prototype +`struct Surface* collision_find_floor(f32 x, f32 y, f32 z);` + +[:arrow_up_small:](#) + +
+ +## [collision_get_temp_wall_collision_data](#collision_get_temp_wall_collision_data) + +### Lua Example +`local WallCollisionDataValue = collision_get_temp_wall_collision_data()` + +### Parameters +- None + +### Returns +[WallCollisionData](structs.md#WallCollisionData) + +### C Prototype +`struct WallCollisionData* collision_get_temp_wall_collision_data(void);` + +[:arrow_up_small:](#) + +
+ +## [get_surface_from_wcd_index](#get_surface_from_wcd_index) + +### Lua Example +`local SurfaceValue = get_surface_from_wcd_index(wcd, index)` + +### Parameters +| Field | Type | +| ----- | ---- | +| wcd | [WallCollisionData](structs.md#WallCollisionData) | +| index | `integer` | + +### Returns +[Surface](structs.md#Surface) + +### C Prototype +`struct Surface* get_surface_from_wcd_index(struct WallCollisionData* wcd, s8 index);` + +[:arrow_up_small:](#) + +
+ +## [get_water_surface_pseudo_floor](#get_water_surface_pseudo_floor) + +### Lua Example +`local SurfaceValue = get_water_surface_pseudo_floor()` + +### Parameters +- None + +### Returns +[Surface](structs.md#Surface) + +### C Prototype +`struct Surface* get_water_surface_pseudo_floor(void);` + +[:arrow_up_small:](#) + +
+ +## [smlua_collision_util_get](#smlua_collision_util_get) + +### Lua Example +`local PointerValue = smlua_collision_util_get(name)` + +### Parameters +| Field | Type | +| ----- | ---- | +| name | `string` | + +### Returns +- `Pointer` <`Collision`> + +### C Prototype +`Collision* smlua_collision_util_get(const char* name);` + +[:arrow_up_small:](#) + +
+ +--- +# functions from smlua_deprecated.h + +
+ + +--- +# functions from smlua_gfx_utils.h + +
+ + +## [get_fog_color](#get_fog_color) + +### Lua Example +`local integerValue = get_fog_color(index)` + +### Parameters +| Field | Type | +| ----- | ---- | +| index | `integer` | + +### Returns +- `integer` + +### C Prototype +`u8 get_fog_color(u8 index);` + +[:arrow_up_small:](#) + +
+ +## [get_fog_intensity](#get_fog_intensity) + +### Lua Example +`local numberValue = get_fog_intensity()` + +### Parameters +- None + +### Returns +- `number` + +### C Prototype +`f32 get_fog_intensity(void);` + +[:arrow_up_small:](#) + +
+ +## [get_lighting_color](#get_lighting_color) + +### Lua Example +`local integerValue = get_lighting_color(index)` + +### Parameters +| Field | Type | +| ----- | ---- | +| index | `integer` | + +### Returns +- `integer` + +### C Prototype +`u8 get_lighting_color(u8 index);` + +[:arrow_up_small:](#) + +
+ +## [get_lighting_dir](#get_lighting_dir) + +### Lua Example +`local numberValue = get_lighting_dir(index)` + +### Parameters +| Field | Type | +| ----- | ---- | +| index | `integer` | + +### Returns +- `number` + +### C Prototype +`f32 get_lighting_dir(u8 index);` + +[:arrow_up_small:](#) + +
+ +## [get_skybox](#get_skybox) + +### Lua Example +`local integerValue = get_skybox()` + +### Parameters +- None + +### Returns +- `integer` + +### C Prototype +`s8 get_skybox(void);` + +[:arrow_up_small:](#) + +
+ +## [get_skybox_color](#get_skybox_color) + +### Lua Example +`local integerValue = get_skybox_color(index)` + +### Parameters +| Field | Type | +| ----- | ---- | +| index | `integer` | + +### Returns +- `integer` + +### C Prototype +`u8 get_skybox_color(u8 index);` + +[:arrow_up_small:](#) + +
+ +## [get_vertex_color](#get_vertex_color) + +### Lua Example +`local integerValue = get_vertex_color(index)` + +### Parameters +| Field | Type | +| ----- | ---- | +| index | `integer` | + +### Returns +- `integer` + +### C Prototype +`u8 get_vertex_color(u8 index);` + +[:arrow_up_small:](#) + +
+ +## [set_fog_color](#set_fog_color) + +### Lua Example +`set_fog_color(index, value)` + +### Parameters +| Field | Type | +| ----- | ---- | +| index | `integer` | +| value | `integer` | + +### Returns +- None + +### C Prototype +`void set_fog_color(u8 index, u8 value);` + +[:arrow_up_small:](#) + +
+ +## [set_fog_intensity](#set_fog_intensity) + +### Lua Example +`set_fog_intensity(intensity)` + +### Parameters +| Field | Type | +| ----- | ---- | +| intensity | `number` | + +### Returns +- None + +### C Prototype +`void set_fog_intensity(f32 intensity);` + +[:arrow_up_small:](#) + +
+ +## [set_lighting_color](#set_lighting_color) + +### Lua Example +`set_lighting_color(index, value)` + +### Parameters +| Field | Type | +| ----- | ---- | +| index | `integer` | +| value | `integer` | + +### Returns +- None + +### C Prototype +`void set_lighting_color(u8 index, u8 value);` + +[:arrow_up_small:](#) + +
+ +## [set_lighting_dir](#set_lighting_dir) + +### Lua Example +`set_lighting_dir(index, value)` + +### Parameters +| Field | Type | +| ----- | ---- | +| index | `integer` | +| value | `number` | + +### Returns +- None + +### C Prototype +`void set_lighting_dir(u8 index, f32 value);` + +[:arrow_up_small:](#) + +
+ +## [set_override_far](#set_override_far) + +### Lua Example +`set_override_far(far)` + +### Parameters +| Field | Type | +| ----- | ---- | +| far | `number` | + +### Returns +- None + +### C Prototype +`void set_override_far(f32 far);` + +[:arrow_up_small:](#) + +
+ +## [set_override_fov](#set_override_fov) + +### Lua Example +`set_override_fov(fov)` + +### Parameters +| Field | Type | +| ----- | ---- | +| fov | `number` | + +### Returns +- None + +### C Prototype +`void set_override_fov(f32 fov);` + +[:arrow_up_small:](#) + +
+ +## [set_override_near](#set_override_near) + +### Lua Example +`set_override_near(near)` + +### Parameters +| Field | Type | +| ----- | ---- | +| near | `number` | + +### Returns +- None + +### C Prototype +`void set_override_near(f32 near);` + +[:arrow_up_small:](#) + +
+ +## [set_override_skybox](#set_override_skybox) + +### Lua Example +`set_override_skybox(background)` + +### Parameters +| Field | Type | +| ----- | ---- | +| background | `integer` | + +### Returns +- None + +### C Prototype +`void set_override_skybox(s8 background);` + +[:arrow_up_small:](#) + +
+ +## [set_skybox_color](#set_skybox_color) + +### Lua Example +`set_skybox_color(index, value)` + +### Parameters +| Field | Type | +| ----- | ---- | +| index | `integer` | +| value | `integer` | + +### Returns +- None + +### C Prototype +`void set_skybox_color(u8 index, u8 value);` + +[:arrow_up_small:](#) + +
+ +## [set_vertex_color](#set_vertex_color) + +### Lua Example +`set_vertex_color(index, value)` + +### Parameters +| Field | Type | +| ----- | ---- | +| index | `integer` | +| value | `integer` | + +### Returns +- None + +### C Prototype +`void set_vertex_color(u8 index, u8 value);` + +[:arrow_up_small:](#) + +
+ +--- +# functions from smlua_level_utils.h + +
+ + +## [level_is_vanilla_level](#level_is_vanilla_level) + +### Lua Example +`local booleanValue = level_is_vanilla_level(levelNum)` + +### Parameters +| Field | Type | +| ----- | ---- | +| levelNum | `integer` | + +### Returns +- `boolean` + +### C Prototype +`bool level_is_vanilla_level(s16 levelNum);` + +[:arrow_up_small:](#) + +
+ +## [level_register](#level_register) + +### Lua Example +`local integerValue = level_register(scriptEntryName, courseNum, fullName, shortName, acousticReach, echoLevel1, echoLevel2, echoLevel3)` + +### Parameters +| Field | Type | +| ----- | ---- | +| scriptEntryName | `string` | +| courseNum | `integer` | +| fullName | `string` | +| shortName | `string` | +| acousticReach | `integer` | +| echoLevel1 | `integer` | +| echoLevel2 | `integer` | +| echoLevel3 | `integer` | + +### Returns +- `integer` + +### C Prototype +`s16 level_register(const char* scriptEntryName, s16 courseNum, const char* fullName, const char* shortName, u32 acousticReach, u32 echoLevel1, u32 echoLevel2, u32 echoLevel3);` + +[:arrow_up_small:](#) + +
+ +## [smlua_level_util_change_area](#smlua_level_util_change_area) + +### Lua Example +`smlua_level_util_change_area(areaIndex)` + +### Parameters +| Field | Type | +| ----- | ---- | +| areaIndex | `integer` | + +### Returns +- None + +### C Prototype +`void smlua_level_util_change_area(s32 areaIndex);` + +[:arrow_up_small:](#) + +
+ +## [smlua_level_util_get_info](#smlua_level_util_get_info) + +### Lua Example +`local CustomLevelInfoValue = smlua_level_util_get_info(levelNum)` + +### Parameters +| Field | Type | +| ----- | ---- | +| levelNum | `integer` | + +### Returns +[CustomLevelInfo](structs.md#CustomLevelInfo) + +### C Prototype +`struct CustomLevelInfo* smlua_level_util_get_info(s16 levelNum);` + +[:arrow_up_small:](#) + +
+ +## [smlua_level_util_get_info_from_course_num](#smlua_level_util_get_info_from_course_num) + +### Lua Example +`local CustomLevelInfoValue = smlua_level_util_get_info_from_course_num(courseNum)` + +### Parameters +| Field | Type | +| ----- | ---- | +| courseNum | `integer` | + +### Returns +[CustomLevelInfo](structs.md#CustomLevelInfo) + +### C Prototype +`struct CustomLevelInfo* smlua_level_util_get_info_from_course_num(u8 courseNum);` + +[:arrow_up_small:](#) + +
+ +## [smlua_level_util_get_info_from_short_name](#smlua_level_util_get_info_from_short_name) + +### Lua Example +`local CustomLevelInfoValue = smlua_level_util_get_info_from_short_name(shortName)` + +### Parameters +| Field | Type | +| ----- | ---- | +| shortName | `string` | + +### Returns +[CustomLevelInfo](structs.md#CustomLevelInfo) + +### C Prototype +`struct CustomLevelInfo* smlua_level_util_get_info_from_short_name(const char* shortName);` + +[:arrow_up_small:](#) + +
+ +## [warp_exit_level](#warp_exit_level) + +### Lua Example +`local booleanValue = warp_exit_level(aDelay)` + +### Parameters +| Field | Type | +| ----- | ---- | +| aDelay | `integer` | + +### Returns +- `boolean` + +### C Prototype +`bool warp_exit_level(s32 aDelay);` + +[:arrow_up_small:](#) + +
+ +## [warp_restart_level](#warp_restart_level) + +### Lua Example +`local booleanValue = warp_restart_level()` + +### Parameters +- None + +### Returns +- `boolean` + +### C Prototype +`bool warp_restart_level(void);` + +[:arrow_up_small:](#) + +
+ +## [warp_to_castle](#warp_to_castle) + +### Lua Example +`local booleanValue = warp_to_castle(aLevel)` + +### Parameters +| Field | Type | +| ----- | ---- | +| aLevel | `integer` | + +### Returns +- `boolean` + +### C Prototype +`bool warp_to_castle(s32 aLevel);` + +[:arrow_up_small:](#) + +
+ +## [warp_to_level](#warp_to_level) + +### Lua Example +`local booleanValue = warp_to_level(aLevel, aArea, aAct)` + +### Parameters +| Field | Type | +| ----- | ---- | +| aLevel | `integer` | +| aArea | `integer` | +| aAct | `integer` | + +### Returns +- `boolean` + +### C Prototype +`bool warp_to_level(s32 aLevel, s32 aArea, s32 aAct);` + +[:arrow_up_small:](#) + +
+ +## [warp_to_start_level](#warp_to_start_level) + +### Lua Example +`local booleanValue = warp_to_start_level()` + +### Parameters +- None + +### Returns +- `boolean` + +### C Prototype +`bool warp_to_start_level(void);` + +[:arrow_up_small:](#) + +
+ +## [warp_to_warpnode](#warp_to_warpnode) + +### Lua Example +`local booleanValue = warp_to_warpnode(aLevel, aArea, aAct, aWarpId)` + +### Parameters +| Field | Type | +| ----- | ---- | +| aLevel | `integer` | +| aArea | `integer` | +| aAct | `integer` | +| aWarpId | `integer` | + +### Returns +- `boolean` + +### C Prototype +`bool warp_to_warpnode(s32 aLevel, s32 aArea, s32 aAct, s32 aWarpId);` + +[:arrow_up_small:](#) + +
+ +--- +# functions from smlua_math_utils.h + +
+ + +## [clamp](#clamp) + +### Lua Example +`local integerValue = clamp(a, b, c)` + +### Parameters +| Field | Type | +| ----- | ---- | +| a | `integer` | +| b | `integer` | +| c | `integer` | + +### Returns +- `integer` + +### C Prototype +`s32 clamp(s32 a, s32 b, s32 c);` + +[:arrow_up_small:](#) + +
+ +## [clampf](#clampf) + +### Lua Example +`local numberValue = clampf(a, b, c)` + +### Parameters +| Field | Type | +| ----- | ---- | +| a | `number` | +| b | `number` | +| c | `number` | + +### Returns +- `number` + +### C Prototype +`f32 clampf(f32 a, f32 b, f32 c);` + +[:arrow_up_small:](#) + +
+ +## [max](#max) + +### Lua Example +`local integerValue = max(a, b)` + +### Parameters +| Field | Type | +| ----- | ---- | +| a | `integer` | +| b | `integer` | + +### Returns +- `integer` + +### C Prototype +`s32 max(s32 a, s32 b);` + +[:arrow_up_small:](#) + +
+ +## [maxf](#maxf) + +### Lua Example +`local numberValue = maxf(a, b)` + +### Parameters +| Field | Type | +| ----- | ---- | +| a | `number` | +| b | `number` | + +### Returns +- `number` + +### C Prototype +`f32 maxf(f32 a, f32 b);` + +[:arrow_up_small:](#) + +
+ +## [min](#min) + +### Lua Example +`local integerValue = min(a, b)` + +### Parameters +| Field | Type | +| ----- | ---- | +| a | `integer` | +| b | `integer` | + +### Returns +- `integer` + +### C Prototype +`s32 min(s32 a, s32 b);` + +[:arrow_up_small:](#) + +
+ +## [minf](#minf) + +### Lua Example +`local numberValue = minf(a, b)` + +### Parameters +| Field | Type | +| ----- | ---- | +| a | `number` | +| b | `number` | + +### Returns +- `number` + +### C Prototype +`f32 minf(f32 a, f32 b);` + +[:arrow_up_small:](#) + +
+ +## [sqr](#sqr) + +### Lua Example +`local integerValue = sqr(x)` + +### Parameters +| Field | Type | +| ----- | ---- | +| x | `integer` | + +### Returns +- `integer` + +### C Prototype +`s32 sqr(s32 x);` + +[:arrow_up_small:](#) + +
+ +## [sqrf](#sqrf) + +### Lua Example +`local numberValue = sqrf(x)` + +### Parameters +| Field | Type | +| ----- | ---- | +| x | `number` | + +### Returns +- `number` + +### C Prototype +`f32 sqrf(f32 x);` + +[:arrow_up_small:](#) + +
+ +--- +# functions from smlua_misc_utils.h + +
+ + +## [allocate_mario_action](#allocate_mario_action) + +### Lua Example +`local integerValue = allocate_mario_action(actFlags)` + +### Parameters +| Field | Type | +| ----- | ---- | +| actFlags | `integer` | + +### Returns +- `integer` + +### C Prototype +`u32 allocate_mario_action(u32 actFlags);` + +[:arrow_up_small:](#) + +
+ ## [course_is_main_course](#course_is_main_course) ### Lua Example @@ -1762,44 +2115,6 @@
-## [get_fog_color](#get_fog_color) - -### Lua Example -`local integerValue = get_fog_color(index)` - -### Parameters -| Field | Type | -| ----- | ---- | -| index | `integer` | - -### Returns -- `integer` - -### C Prototype -`u8 get_fog_color(u8 index);` - -[:arrow_up_small:](#) - -
- -## [get_fog_intensity](#get_fog_intensity) - -### Lua Example -`local numberValue = get_fog_intensity()` - -### Parameters -- None - -### Returns -- `number` - -### C Prototype -`f32 get_fog_intensity(void);` - -[:arrow_up_small:](#) - -
- ## [get_global_timer](#get_global_timer) ### Lua Example @@ -1953,46 +2268,6 @@
-## [get_lighting_color](#get_lighting_color) - -### Lua Example -`local integerValue = get_lighting_color(index)` - -### Parameters -| Field | Type | -| ----- | ---- | -| index | `integer` | - -### Returns -- `integer` - -### C Prototype -`u8 get_lighting_color(u8 index);` - -[:arrow_up_small:](#) - -
- -## [get_lighting_dir](#get_lighting_dir) - -### Lua Example -`local numberValue = get_lighting_dir(index)` - -### Parameters -| Field | Type | -| ----- | ---- | -| index | `integer` | - -### Returns -- `number` - -### C Prototype -`f32 get_lighting_dir(u8 index);` - -[:arrow_up_small:](#) - -
- ## [get_local_discord_id](#get_local_discord_id) ### Lua Example @@ -2065,24 +2340,6 @@
-## [get_skybox](#get_skybox) - -### Lua Example -`local integerValue = get_skybox()` - -### Parameters -- None - -### Returns -- `integer` - -### C Prototype -`s8 get_skybox(void);` - -[:arrow_up_small:](#) - -
- ## [get_temp_s32_pointer](#get_temp_s32_pointer) ### Lua Example @@ -2139,26 +2396,6 @@
-## [get_vertex_color](#get_vertex_color) - -### Lua Example -`local integerValue = get_vertex_color(index)` - -### Parameters -| Field | Type | -| ----- | ---- | -| index | `integer` | - -### Returns -- `integer` - -### C Prototype -`u8 get_vertex_color(u8 index);` - -[:arrow_up_small:](#) - -
- ## [get_volume_env](#get_volume_env) ### Lua Example @@ -2575,47 +2812,6 @@
-## [set_fog_color](#set_fog_color) - -### Lua Example -`set_fog_color(index, value)` - -### Parameters -| Field | Type | -| ----- | ---- | -| index | `integer` | -| value | `integer` | - -### Returns -- None - -### C Prototype -`void set_fog_color(u8 index, u8 value);` - -[:arrow_up_small:](#) - -
- -## [set_fog_intensity](#set_fog_intensity) - -### Lua Example -`set_fog_intensity(intensity)` - -### Parameters -| Field | Type | -| ----- | ---- | -| intensity | `number` | - -### Returns -- None - -### C Prototype -`void set_fog_intensity(f32 intensity);` - -[:arrow_up_small:](#) - -
- ## [set_got_file_coin_hi_score](#set_got_file_coin_hi_score) ### Lua Example @@ -2696,48 +2892,6 @@
-## [set_lighting_color](#set_lighting_color) - -### Lua Example -`set_lighting_color(index, value)` - -### Parameters -| Field | Type | -| ----- | ---- | -| index | `integer` | -| value | `integer` | - -### Returns -- None - -### C Prototype -`void set_lighting_color(u8 index, u8 value);` - -[:arrow_up_small:](#) - -
- -## [set_lighting_dir](#set_lighting_dir) - -### Lua Example -`set_lighting_dir(index, value)` - -### Parameters -| Field | Type | -| ----- | ---- | -| index | `integer` | -| value | `number` | - -### Returns -- None - -### C Prototype -`void set_lighting_dir(u8 index, f32 value);` - -[:arrow_up_small:](#) - -
- ## [set_override_envfx](#set_override_envfx) ### Lua Example @@ -2758,86 +2912,6 @@
-## [set_override_far](#set_override_far) - -### Lua Example -`set_override_far(far)` - -### Parameters -| Field | Type | -| ----- | ---- | -| far | `number` | - -### Returns -- None - -### C Prototype -`void set_override_far(f32 far);` - -[:arrow_up_small:](#) - -
- -## [set_override_fov](#set_override_fov) - -### Lua Example -`set_override_fov(fov)` - -### Parameters -| Field | Type | -| ----- | ---- | -| fov | `number` | - -### Returns -- None - -### C Prototype -`void set_override_fov(f32 fov);` - -[:arrow_up_small:](#) - -
- -## [set_override_near](#set_override_near) - -### Lua Example -`set_override_near(near)` - -### Parameters -| Field | Type | -| ----- | ---- | -| near | `number` | - -### Returns -- None - -### C Prototype -`void set_override_near(f32 near);` - -[:arrow_up_small:](#) - -
- -## [set_override_skybox](#set_override_skybox) - -### Lua Example -`set_override_skybox(background)` - -### Parameters -| Field | Type | -| ----- | ---- | -| background | `integer` | - -### Returns -- None - -### C Prototype -`void set_override_skybox(s8 background);` - -[:arrow_up_small:](#) - -
- ## [set_save_file_modified](#set_save_file_modified) ### Lua Example @@ -2878,27 +2952,6 @@
-## [set_vertex_color](#set_vertex_color) - -### Lua Example -`set_vertex_color(index, value)` - -### Parameters -| Field | Type | -| ----- | ---- | -| index | `integer` | -| value | `integer` | - -### Returns -- None - -### C Prototype -`void set_vertex_color(u8 index, u8 value);` - -[:arrow_up_small:](#) - -
- ## [set_volume_env](#set_volume_env) ### Lua Example diff --git a/docs/lua/functions.md b/docs/lua/functions.md index 2ded0dc6..54cdcd22 100644 --- a/docs/lua/functions.md +++ b/docs/lua/functions.md @@ -1594,6 +1594,38 @@
+- smlua_camera_utils.h + - [camera_allow_toxic_gas_camera](functions-5.md#camera_allow_toxic_gas_camera) + - [camera_config_enable_analog_cam](functions-5.md#camera_config_enable_analog_cam) + - [camera_config_enable_free_cam](functions-5.md#camera_config_enable_free_cam) + - [camera_config_enable_mouse_look](functions-5.md#camera_config_enable_mouse_look) + - [camera_config_get_aggression](functions-5.md#camera_config_get_aggression) + - [camera_config_get_deceleration](functions-5.md#camera_config_get_deceleration) + - [camera_config_get_pan_level](functions-5.md#camera_config_get_pan_level) + - [camera_config_get_x_sensitivity](functions-5.md#camera_config_get_x_sensitivity) + - [camera_config_get_y_sensitivity](functions-5.md#camera_config_get_y_sensitivity) + - [camera_config_invert_x](functions-5.md#camera_config_invert_x) + - [camera_config_invert_y](functions-5.md#camera_config_invert_y) + - [camera_config_is_analog_cam_enabled](functions-5.md#camera_config_is_analog_cam_enabled) + - [camera_config_is_free_cam_enabled](functions-5.md#camera_config_is_free_cam_enabled) + - [camera_config_is_mouse_look_enabled](functions-5.md#camera_config_is_mouse_look_enabled) + - [camera_config_is_x_inverted](functions-5.md#camera_config_is_x_inverted) + - [camera_config_is_y_inverted](functions-5.md#camera_config_is_y_inverted) + - [camera_config_set_aggression](functions-5.md#camera_config_set_aggression) + - [camera_config_set_deceleration](functions-5.md#camera_config_set_deceleration) + - [camera_config_set_pan_level](functions-5.md#camera_config_set_pan_level) + - [camera_config_set_x_sensitivity](functions-5.md#camera_config_set_x_sensitivity) + - [camera_config_set_y_sensitivity](functions-5.md#camera_config_set_y_sensitivity) + - [camera_freeze](functions-5.md#camera_freeze) + - [camera_is_frozen](functions-5.md#camera_is_frozen) + - [camera_reset_overrides](functions-5.md#camera_reset_overrides) + - [camera_romhack_allow_centering](functions-5.md#camera_romhack_allow_centering) + - [camera_romhack_allow_dpad_usage](functions-5.md#camera_romhack_allow_dpad_usage) + - [camera_set_romhack_override](functions-5.md#camera_set_romhack_override) + - [camera_unfreeze](functions-5.md#camera_unfreeze) + +
+ - smlua_collision_utils.h - [collision_find_ceil](functions-5.md#collision_find_ceil) - [collision_find_floor](functions-5.md#collision_find_floor) @@ -1608,6 +1640,27 @@
+- smlua_gfx_utils.h + - [get_fog_color](functions-5.md#get_fog_color) + - [get_fog_intensity](functions-5.md#get_fog_intensity) + - [get_lighting_color](functions-5.md#get_lighting_color) + - [get_lighting_dir](functions-5.md#get_lighting_dir) + - [get_skybox](functions-5.md#get_skybox) + - [get_skybox_color](functions-5.md#get_skybox_color) + - [get_vertex_color](functions-5.md#get_vertex_color) + - [set_fog_color](functions-5.md#set_fog_color) + - [set_fog_intensity](functions-5.md#set_fog_intensity) + - [set_lighting_color](functions-5.md#set_lighting_color) + - [set_lighting_dir](functions-5.md#set_lighting_dir) + - [set_override_far](functions-5.md#set_override_far) + - [set_override_fov](functions-5.md#set_override_fov) + - [set_override_near](functions-5.md#set_override_near) + - [set_override_skybox](functions-5.md#set_override_skybox) + - [set_skybox_color](functions-5.md#set_skybox_color) + - [set_vertex_color](functions-5.md#set_vertex_color) + +
+ - smlua_level_utils.h - [level_is_vanilla_level](functions-5.md#level_is_vanilla_level) - [level_register](functions-5.md#level_register) @@ -1638,34 +1691,6 @@ - smlua_misc_utils.h - [allocate_mario_action](functions-5.md#allocate_mario_action) - - [camera_allow_toxic_gas_camera](functions-5.md#camera_allow_toxic_gas_camera) - - [camera_config_enable_analog_cam](functions-5.md#camera_config_enable_analog_cam) - - [camera_config_enable_free_cam](functions-5.md#camera_config_enable_free_cam) - - [camera_config_enable_mouse_look](functions-5.md#camera_config_enable_mouse_look) - - [camera_config_get_aggression](functions-5.md#camera_config_get_aggression) - - [camera_config_get_deceleration](functions-5.md#camera_config_get_deceleration) - - [camera_config_get_pan_level](functions-5.md#camera_config_get_pan_level) - - [camera_config_get_x_sensitivity](functions-5.md#camera_config_get_x_sensitivity) - - [camera_config_get_y_sensitivity](functions-5.md#camera_config_get_y_sensitivity) - - [camera_config_invert_x](functions-5.md#camera_config_invert_x) - - [camera_config_invert_y](functions-5.md#camera_config_invert_y) - - [camera_config_is_analog_cam_enabled](functions-5.md#camera_config_is_analog_cam_enabled) - - [camera_config_is_free_cam_enabled](functions-5.md#camera_config_is_free_cam_enabled) - - [camera_config_is_mouse_look_enabled](functions-5.md#camera_config_is_mouse_look_enabled) - - [camera_config_is_x_inverted](functions-5.md#camera_config_is_x_inverted) - - [camera_config_is_y_inverted](functions-5.md#camera_config_is_y_inverted) - - [camera_config_set_aggression](functions-5.md#camera_config_set_aggression) - - [camera_config_set_deceleration](functions-5.md#camera_config_set_deceleration) - - [camera_config_set_pan_level](functions-5.md#camera_config_set_pan_level) - - [camera_config_set_x_sensitivity](functions-5.md#camera_config_set_x_sensitivity) - - [camera_config_set_y_sensitivity](functions-5.md#camera_config_set_y_sensitivity) - - [camera_freeze](functions-5.md#camera_freeze) - - [camera_is_frozen](functions-5.md#camera_is_frozen) - - [camera_reset_overrides](functions-5.md#camera_reset_overrides) - - [camera_romhack_allow_centering](functions-5.md#camera_romhack_allow_centering) - - [camera_romhack_allow_dpad_usage](functions-5.md#camera_romhack_allow_dpad_usage) - - [camera_set_romhack_override](functions-5.md#camera_set_romhack_override) - - [camera_unfreeze](functions-5.md#camera_unfreeze) - [course_is_main_course](functions-5.md#course_is_main_course) - [deref_s32_pointer](functions-5.md#deref_s32_pointer) - [djui_is_playerlist_open](functions-5.md#djui_is_playerlist_open) @@ -1679,8 +1704,6 @@ - [get_dialog_id](functions-5.md#get_dialog_id) - [get_dialog_response](functions-5.md#get_dialog_response) - [get_envfx](functions-5.md#get_envfx) - - [get_fog_color](functions-5.md#get_fog_color) - - [get_fog_intensity](functions-5.md#get_fog_intensity) - [get_global_timer](functions-5.md#get_global_timer) - [get_got_file_coin_hi_score](functions-5.md#get_got_file_coin_hi_score) - [get_hand_foot_pos_x](functions-5.md#get_hand_foot_pos_x) @@ -1689,17 +1712,13 @@ - [get_last_completed_course_num](functions-5.md#get_last_completed_course_num) - [get_last_completed_star_num](functions-5.md#get_last_completed_star_num) - [get_last_star_or_key](functions-5.md#get_last_star_or_key) - - [get_lighting_color](functions-5.md#get_lighting_color) - - [get_lighting_dir](functions-5.md#get_lighting_dir) - [get_local_discord_id](functions-5.md#get_local_discord_id) - [get_network_area_timer](functions-5.md#get_network_area_timer) - [get_os_name](functions-5.md#get_os_name) - [get_save_file_modified](functions-5.md#get_save_file_modified) - - [get_skybox](functions-5.md#get_skybox) - [get_temp_s32_pointer](functions-5.md#get_temp_s32_pointer) - [get_time](functions-5.md#get_time) - [get_ttc_speed_setting](functions-5.md#get_ttc_speed_setting) - - [get_vertex_color](functions-5.md#get_vertex_color) - [get_volume_env](functions-5.md#get_volume_env) - [get_volume_level](functions-5.md#get_volume_level) - [get_volume_master](functions-5.md#get_volume_master) @@ -1721,22 +1740,13 @@ - [reset_window_title](functions-5.md#reset_window_title) - [save_file_get_using_backup_slot](functions-5.md#save_file_get_using_backup_slot) - [save_file_set_using_backup_slot](functions-5.md#save_file_set_using_backup_slot) - - [set_fog_color](functions-5.md#set_fog_color) - - [set_fog_intensity](functions-5.md#set_fog_intensity) - [set_got_file_coin_hi_score](functions-5.md#set_got_file_coin_hi_score) - [set_last_completed_course_num](functions-5.md#set_last_completed_course_num) - [set_last_completed_star_num](functions-5.md#set_last_completed_star_num) - [set_last_star_or_key](functions-5.md#set_last_star_or_key) - - [set_lighting_color](functions-5.md#set_lighting_color) - - [set_lighting_dir](functions-5.md#set_lighting_dir) - [set_override_envfx](functions-5.md#set_override_envfx) - - [set_override_far](functions-5.md#set_override_far) - - [set_override_fov](functions-5.md#set_override_fov) - - [set_override_near](functions-5.md#set_override_near) - - [set_override_skybox](functions-5.md#set_override_skybox) - [set_save_file_modified](functions-5.md#set_save_file_modified) - [set_ttc_speed_setting](functions-5.md#set_ttc_speed_setting) - - [set_vertex_color](functions-5.md#set_vertex_color) - [set_volume_env](functions-5.md#set_volume_env) - [set_volume_level](functions-5.md#set_volume_level) - [set_volume_master](functions-5.md#set_volume_master) diff --git a/src/game/bettercamera.inc.h b/src/game/bettercamera.inc.h index ebe47088..ac5c4526 100644 --- a/src/game/bettercamera.inc.h +++ b/src/game/bettercamera.inc.h @@ -9,7 +9,7 @@ #include "engine/surface_collision.h" #include "pc/configfile.h" #include "pc/controller/controller_mouse.h" -#include "pc/lua/utils/smlua_misc_utils.h" +#include "pc/lua/utils/smlua_camera_utils.h" #if defined(__MINGW32__) && !defined(__MINGW64_VERSION_MAJOR) //quick and dirty fix for some older MinGW.org mingwrt diff --git a/src/game/first_person_cam.c b/src/game/first_person_cam.c index 680f112f..9e1a7e2c 100644 --- a/src/game/first_person_cam.c +++ b/src/game/first_person_cam.c @@ -15,7 +15,7 @@ #include "pc/controller/controller_mouse.h" #include "pc/djui/djui.h" #include "pc/djui/djui_hud_utils.h" -#include "pc/lua/utils/smlua_misc_utils.h" +#include "pc/lua/utils/smlua_camera_utils.h" #include "pc/lua/smlua_hooks.h" #define CLAMP(_val, _min, _max) MAX(MIN((_val), _max), _min) diff --git a/src/game/object_helpers.c b/src/game/object_helpers.c index 09c92bca..5f2f8453 100644 --- a/src/game/object_helpers.c +++ b/src/game/object_helpers.c @@ -29,7 +29,7 @@ #include "spawn_sound.h" #include "pc/network/network.h" #include "pc/lua/smlua_hooks.h" -#include "pc/lua/utils/smlua_misc_utils.h" +#include "pc/lua/utils/smlua_camera_utils.h" #include "first_person_cam.h" u8 (*gContinueDialogFunction)(void) = NULL; diff --git a/src/game/skybox.c b/src/game/skybox.c index b469f1ae..29220537 100644 --- a/src/game/skybox.c +++ b/src/game/skybox.c @@ -68,6 +68,7 @@ extern u8 gRenderingInterpolated; s8 gReadOnlyBackground; s8 gOverrideBackground = -1; +Color gSkyboxColor = { 255, 255, 255 }; extern SkyboxTexture bbh_skybox_ptrlist; extern SkyboxTexture bitdw_skybox_ptrlist; @@ -213,14 +214,17 @@ Vtx *make_skybox_rect(s32 tileIndex, s8 colorIndex, s32 row, s32 col) { f32 y = SKYBOX_HEIGHT - tileIndex / SKYBOX_COLS * SKYBOX_TILE_HEIGHT; if (verts != NULL) { - make_vertex(verts, 0, x, y, -1, 0, 0, sSkyboxColors[colorIndex][0], sSkyboxColors[colorIndex][1], - sSkyboxColors[colorIndex][2], 255); - make_vertex(verts, 1, x, y - SKYBOX_TILE_HEIGHT, -1, 0, 31 << 5, sSkyboxColors[colorIndex][0], sSkyboxColors[colorIndex][1], - sSkyboxColors[colorIndex][2], 255); - make_vertex(verts, 2, x + SKYBOX_TILE_WIDTH, y - SKYBOX_TILE_HEIGHT, -1, 31 << 5, 31 << 5, sSkyboxColors[colorIndex][0], - sSkyboxColors[colorIndex][1], sSkyboxColors[colorIndex][2], 255); - make_vertex(verts, 3, x + SKYBOX_TILE_WIDTH, y, -1, 31 << 5, 0, sSkyboxColors[colorIndex][0], sSkyboxColors[colorIndex][1], - sSkyboxColors[colorIndex][2], 255); + f32 r = gSkyboxColor[0] / 255.0f; + f32 g = gSkyboxColor[1] / 255.0f; + f32 b = gSkyboxColor[2] / 255.0f; + make_vertex(verts, 0, x, y, -1, 0, 0, sSkyboxColors[colorIndex][0] * r, sSkyboxColors[colorIndex][1] * g, + sSkyboxColors[colorIndex][2] * b, 255); + make_vertex(verts, 1, x, y - SKYBOX_TILE_HEIGHT, -1, 0, 31 << 5, sSkyboxColors[colorIndex][0] * r, sSkyboxColors[colorIndex][1] * g, + sSkyboxColors[colorIndex][2] * b, 255); + make_vertex(verts, 2, x + SKYBOX_TILE_WIDTH, y - SKYBOX_TILE_HEIGHT, -1, 31 << 5, 31 << 5, sSkyboxColors[colorIndex][0] * r, + sSkyboxColors[colorIndex][1] * g, sSkyboxColors[colorIndex][2] * b, 255); + make_vertex(verts, 3, x + SKYBOX_TILE_WIDTH, y, -1, 31 << 5, 0, sSkyboxColors[colorIndex][0] * r, sSkyboxColors[colorIndex][1] * g, + sSkyboxColors[colorIndex][2] * b, 255); } else { } return verts; @@ -251,7 +255,7 @@ void draw_skybox_tile_grid(Gfx **dlist, s8 background, s8 player, s8 colorIndex) Vtx *vertices = make_skybox_rect(tileIndex, colorIndex, row, col); gLoadBlockTexture((*dlist)++, 32, 32, G_IM_FMT_RGBA, texture); - gSPVertex((*dlist)++, VIRTUAL_TO_PHYSICAL(vertices), 4, 0); + gSPVertexNonGlobal((*dlist)++, VIRTUAL_TO_PHYSICAL(vertices), 4, 0); gSPDisplayList((*dlist)++, dl_draw_quad_verts_0123); } } diff --git a/src/game/skybox.h b/src/game/skybox.h index 11dfff8b..1595e85d 100644 --- a/src/game/skybox.h +++ b/src/game/skybox.h @@ -6,6 +6,7 @@ extern s8 gReadOnlyBackground; extern s8 gOverrideBackground; +extern Color gSkyboxColor; extern Texture* gCustomSkyboxPtrList[]; diff --git a/src/pc/lua/smlua_cobject_autogen.c b/src/pc/lua/smlua_cobject_autogen.c index e444ae9f..94df0bc2 100644 --- a/src/pc/lua/smlua_cobject_autogen.c +++ b/src/pc/lua/smlua_cobject_autogen.c @@ -12,6 +12,7 @@ #include "src/game/mario_step.h" #include "src/pc/lua/utils/smlua_anim_utils.h" #include "src/pc/lua/utils/smlua_misc_utils.h" +#include "src/pc/lua/utils/smlua_camera_utils.h" #include "src/pc/lua/utils/smlua_collision_utils.h" #include "src/pc/lua/utils/smlua_level_utils.h" #include "src/game/spawn_sound.h" diff --git a/src/pc/lua/smlua_functions_autogen.c b/src/pc/lua/smlua_functions_autogen.c index 32502ce5..07572245 100644 --- a/src/pc/lua/smlua_functions_autogen.c +++ b/src/pc/lua/smlua_functions_autogen.c @@ -25,6 +25,8 @@ #include "include/behavior_table.h" #include "src/pc/lua/utils/smlua_obj_utils.h" #include "src/pc/lua/utils/smlua_misc_utils.h" +#include "src/pc/lua/utils/smlua_camera_utils.h" +#include "src/pc/lua/utils/smlua_gfx_utils.h" #include "src/pc/lua/utils/smlua_collision_utils.h" #include "src/pc/lua/utils/smlua_math_utils.h" #include "src/pc/lua/utils/smlua_model_utils.h" @@ -28337,730 +28339,9 @@ int smlua_func_smlua_audio_utils_reset_all(UNUSED lua_State* L) { return 1; } - ///////////////////////////// - // smlua_collision_utils.h // -///////////////////////////// - -int smlua_func_collision_find_ceil(lua_State* L) { - if (L == NULL) { return 0; } - - int top = lua_gettop(L); - if (top != 3) { - LOG_LUA_LINE("Improper param count for '%s': Expected %u, Received %u", "collision_find_ceil", 3, top); - return 0; - } - - f32 x = smlua_to_number(L, 1); - if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "collision_find_ceil"); return 0; } - f32 y = smlua_to_number(L, 2); - if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 2, "collision_find_ceil"); return 0; } - f32 z = smlua_to_number(L, 3); - if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 3, "collision_find_ceil"); return 0; } - - smlua_push_object(L, LOT_SURFACE, collision_find_ceil(x, y, z)); - - return 1; -} - -int smlua_func_collision_find_floor(lua_State* L) { - if (L == NULL) { return 0; } - - int top = lua_gettop(L); - if (top != 3) { - LOG_LUA_LINE("Improper param count for '%s': Expected %u, Received %u", "collision_find_floor", 3, top); - return 0; - } - - f32 x = smlua_to_number(L, 1); - if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "collision_find_floor"); return 0; } - f32 y = smlua_to_number(L, 2); - if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 2, "collision_find_floor"); return 0; } - f32 z = smlua_to_number(L, 3); - if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 3, "collision_find_floor"); return 0; } - - smlua_push_object(L, LOT_SURFACE, collision_find_floor(x, y, z)); - - return 1; -} - -int smlua_func_collision_get_temp_wall_collision_data(UNUSED lua_State* L) { - if (L == NULL) { return 0; } - - int top = lua_gettop(L); - if (top != 0) { - LOG_LUA_LINE("Improper param count for '%s': Expected %u, Received %u", "collision_get_temp_wall_collision_data", 0, top); - return 0; - } - - - smlua_push_object(L, LOT_WALLCOLLISIONDATA, collision_get_temp_wall_collision_data()); - - return 1; -} - -int smlua_func_get_surface_from_wcd_index(lua_State* L) { - if (L == NULL) { return 0; } - - int top = lua_gettop(L); - if (top != 2) { - LOG_LUA_LINE("Improper param count for '%s': Expected %u, Received %u", "get_surface_from_wcd_index", 2, top); - return 0; - } - - struct WallCollisionData* wcd = (struct WallCollisionData*)smlua_to_cobject(L, 1, LOT_WALLCOLLISIONDATA); - if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "get_surface_from_wcd_index"); return 0; } - s8 index = smlua_to_integer(L, 2); - if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 2, "get_surface_from_wcd_index"); return 0; } - - smlua_push_object(L, LOT_SURFACE, get_surface_from_wcd_index(wcd, index)); - - return 1; -} - -int smlua_func_get_water_surface_pseudo_floor(UNUSED lua_State* L) { - if (L == NULL) { return 0; } - - int top = lua_gettop(L); - if (top != 0) { - LOG_LUA_LINE("Improper param count for '%s': Expected %u, Received %u", "get_water_surface_pseudo_floor", 0, top); - return 0; - } - - - smlua_push_object(L, LOT_SURFACE, get_water_surface_pseudo_floor()); - - return 1; -} - -int smlua_func_smlua_collision_util_get(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", "smlua_collision_util_get", 1, top); - return 0; - } - - const char* name = smlua_to_string(L, 1); - if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "smlua_collision_util_get"); return 0; } - - smlua_push_pointer(L, LVT_COLLISION_P, (void*)smlua_collision_util_get(name)); - - return 1; -} - - //////////////////////// - // smlua_deprecated.h // -//////////////////////// - -int smlua_func_audio_stream_get_tempo(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", "audio_stream_get_tempo", 1, top); - return 0; - } - - struct ModAudio* audio = (struct ModAudio*)smlua_to_cobject(L, 1, LOT_MODAUDIO); - if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "audio_stream_get_tempo"); return 0; } - - lua_pushnumber(L, audio_stream_get_tempo(audio)); - - return 1; -} - -int smlua_func_audio_stream_load_url(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", "audio_stream_load_url", 1, top); - return 0; - } - - const char* url = smlua_to_string(L, 1); - if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "audio_stream_load_url"); return 0; } - - smlua_push_object(L, LOT_MODAUDIO, audio_stream_load_url(url)); - - return 1; -} - -int smlua_func_audio_stream_set_speed(lua_State* L) { - if (L == NULL) { return 0; } - - int top = lua_gettop(L); - if (top != 4) { - LOG_LUA_LINE("Improper param count for '%s': Expected %u, Received %u", "audio_stream_set_speed", 4, top); - return 0; - } - - struct ModAudio* audio = (struct ModAudio*)smlua_to_cobject(L, 1, LOT_MODAUDIO); - if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "audio_stream_set_speed"); return 0; } - f32 initial_freq = smlua_to_number(L, 2); - if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 2, "audio_stream_set_speed"); return 0; } - f32 speed = smlua_to_number(L, 3); - if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 3, "audio_stream_set_speed"); return 0; } - bool pitch = smlua_to_boolean(L, 4); - if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 4, "audio_stream_set_speed"); return 0; } - - audio_stream_set_speed(audio, initial_freq, speed, pitch); - - return 1; -} - -int smlua_func_audio_stream_set_tempo(lua_State* L) { - if (L == NULL) { return 0; } - - int top = lua_gettop(L); - if (top != 2) { - LOG_LUA_LINE("Improper param count for '%s': Expected %u, Received %u", "audio_stream_set_tempo", 2, top); - return 0; - } - - struct ModAudio* audio = (struct ModAudio*)smlua_to_cobject(L, 1, LOT_MODAUDIO); - if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "audio_stream_set_tempo"); return 0; } - f32 tempo = smlua_to_number(L, 2); - if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 2, "audio_stream_set_tempo"); return 0; } - - audio_stream_set_tempo(audio, tempo); - - return 1; -} - -int smlua_func_djui_hud_set_render_behind_hud(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", "djui_hud_set_render_behind_hud", 1, top); - return 0; - } - - bool enable = smlua_to_boolean(L, 1); - if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "djui_hud_set_render_behind_hud"); return 0; } - - djui_hud_set_render_behind_hud(enable); - - return 1; -} - -int smlua_func_get_environment_region(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", "get_environment_region", 1, top); - return 0; - } - - u8 index = smlua_to_integer(L, 1); - if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "get_environment_region"); return 0; } - - lua_pushnumber(L, get_environment_region(index)); - - return 1; -} - -int smlua_func_network_discord_id_from_local_index(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", "network_discord_id_from_local_index", 1, top); - return 0; - } - - u8 localIndex = smlua_to_integer(L, 1); - if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "network_discord_id_from_local_index"); return 0; } - - lua_pushstring(L, network_discord_id_from_local_index(localIndex)); - - return 1; -} - -int smlua_func_network_player_color_to_palette(lua_State* L) { - if (L == NULL) { return 0; } - - int top = lua_gettop(L); - if (top != 3) { - LOG_LUA_LINE("Improper param count for '%s': Expected %u, Received %u", "network_player_color_to_palette", 3, top); - return 0; - } - - struct NetworkPlayer* np = (struct NetworkPlayer*)smlua_to_cobject(L, 1, LOT_NETWORKPLAYER); - if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "network_player_color_to_palette"); return 0; } - int part = smlua_to_integer(L, 2); - if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 2, "network_player_color_to_palette"); return 0; } - - u8* color = smlua_get_color_from_buffer(); - color[0] = smlua_get_integer_field(3, "r"); - color[1] = smlua_get_integer_field(3, "g"); - color[2] = smlua_get_integer_field(3, "b"); - if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 3, "network_player_color_to_palette"); return 0; } - - network_player_color_to_palette(np, part, color); - - smlua_push_integer_field(3, "r", color[0]); - smlua_push_integer_field(3, "g", color[1]); - smlua_push_integer_field(3, "b", color[2]); - - return 1; -} - -int smlua_func_network_player_palette_to_color(lua_State* L) { - if (L == NULL) { return 0; } - - int top = lua_gettop(L); - if (top != 3) { - LOG_LUA_LINE("Improper param count for '%s': Expected %u, Received %u", "network_player_palette_to_color", 3, top); - return 0; - } - - struct NetworkPlayer* np = (struct NetworkPlayer*)smlua_to_cobject(L, 1, LOT_NETWORKPLAYER); - if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "network_player_palette_to_color"); return 0; } - int part = smlua_to_integer(L, 2); - if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 2, "network_player_palette_to_color"); return 0; } - - u8* out = smlua_get_color_from_buffer(); - out[0] = smlua_get_integer_field(3, "r"); - out[1] = smlua_get_integer_field(3, "g"); - out[2] = smlua_get_integer_field(3, "b"); - if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 3, "network_player_palette_to_color"); return 0; } - - network_player_palette_to_color(np, part, out); - - smlua_push_integer_field(3, "r", out[0]); - smlua_push_integer_field(3, "g", out[1]); - smlua_push_integer_field(3, "b", out[2]); - - return 1; -} - -int smlua_func_set_environment_region(lua_State* L) { - if (L == NULL) { return 0; } - - int top = lua_gettop(L); - if (top != 2) { - LOG_LUA_LINE("Improper param count for '%s': Expected %u, Received %u", "set_environment_region", 2, top); - return 0; - } - - u8 index = smlua_to_integer(L, 1); - if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "set_environment_region"); return 0; } - s32 value = smlua_to_integer(L, 2); - if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 2, "set_environment_region"); return 0; } - - set_environment_region(index, value); - - return 1; -} - - ///////////////////////// - // smlua_level_utils.h // -///////////////////////// - -int smlua_func_level_is_vanilla_level(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", "level_is_vanilla_level", 1, top); - return 0; - } - - s16 levelNum = smlua_to_integer(L, 1); - if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "level_is_vanilla_level"); return 0; } - - lua_pushboolean(L, level_is_vanilla_level(levelNum)); - - return 1; -} - -int smlua_func_level_register(lua_State* L) { - if (L == NULL) { return 0; } - - int top = lua_gettop(L); - if (top != 8) { - LOG_LUA_LINE("Improper param count for '%s': Expected %u, Received %u", "level_register", 8, top); - return 0; - } - - const char* scriptEntryName = smlua_to_string(L, 1); - if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "level_register"); return 0; } - s16 courseNum = smlua_to_integer(L, 2); - if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 2, "level_register"); return 0; } - const char* fullName = smlua_to_string(L, 3); - if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 3, "level_register"); return 0; } - const char* shortName = smlua_to_string(L, 4); - if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 4, "level_register"); return 0; } - u32 acousticReach = smlua_to_integer(L, 5); - if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 5, "level_register"); return 0; } - u32 echoLevel1 = smlua_to_integer(L, 6); - if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 6, "level_register"); return 0; } - u32 echoLevel2 = smlua_to_integer(L, 7); - if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 7, "level_register"); return 0; } - u32 echoLevel3 = smlua_to_integer(L, 8); - if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 8, "level_register"); return 0; } - - lua_pushinteger(L, level_register(scriptEntryName, courseNum, fullName, shortName, acousticReach, echoLevel1, echoLevel2, echoLevel3)); - - return 1; -} - -int smlua_func_smlua_level_util_change_area(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", "smlua_level_util_change_area", 1, top); - return 0; - } - - s32 areaIndex = smlua_to_integer(L, 1); - if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "smlua_level_util_change_area"); return 0; } - - smlua_level_util_change_area(areaIndex); - - return 1; -} - -int smlua_func_smlua_level_util_get_info(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", "smlua_level_util_get_info", 1, top); - return 0; - } - - s16 levelNum = smlua_to_integer(L, 1); - if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "smlua_level_util_get_info"); return 0; } - - smlua_push_object(L, LOT_CUSTOMLEVELINFO, smlua_level_util_get_info(levelNum)); - - return 1; -} - -int smlua_func_smlua_level_util_get_info_from_course_num(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", "smlua_level_util_get_info_from_course_num", 1, top); - return 0; - } - - u8 courseNum = smlua_to_integer(L, 1); - if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "smlua_level_util_get_info_from_course_num"); return 0; } - - smlua_push_object(L, LOT_CUSTOMLEVELINFO, smlua_level_util_get_info_from_course_num(courseNum)); - - return 1; -} - -int smlua_func_smlua_level_util_get_info_from_short_name(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", "smlua_level_util_get_info_from_short_name", 1, top); - return 0; - } - - const char* shortName = smlua_to_string(L, 1); - if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "smlua_level_util_get_info_from_short_name"); return 0; } - - smlua_push_object(L, LOT_CUSTOMLEVELINFO, smlua_level_util_get_info_from_short_name(shortName)); - - return 1; -} - -int smlua_func_warp_exit_level(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", "warp_exit_level", 1, top); - return 0; - } - - s32 aDelay = smlua_to_integer(L, 1); - if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "warp_exit_level"); return 0; } - - lua_pushboolean(L, warp_exit_level(aDelay)); - - return 1; -} - -int smlua_func_warp_restart_level(UNUSED lua_State* L) { - if (L == NULL) { return 0; } - - int top = lua_gettop(L); - if (top != 0) { - LOG_LUA_LINE("Improper param count for '%s': Expected %u, Received %u", "warp_restart_level", 0, top); - return 0; - } - - - lua_pushboolean(L, warp_restart_level()); - - return 1; -} - -int smlua_func_warp_to_castle(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", "warp_to_castle", 1, top); - return 0; - } - - s32 aLevel = smlua_to_integer(L, 1); - if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "warp_to_castle"); return 0; } - - lua_pushboolean(L, warp_to_castle(aLevel)); - - return 1; -} - -int smlua_func_warp_to_level(lua_State* L) { - if (L == NULL) { return 0; } - - int top = lua_gettop(L); - if (top != 3) { - LOG_LUA_LINE("Improper param count for '%s': Expected %u, Received %u", "warp_to_level", 3, top); - return 0; - } - - s32 aLevel = smlua_to_integer(L, 1); - if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "warp_to_level"); return 0; } - s32 aArea = smlua_to_integer(L, 2); - if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 2, "warp_to_level"); return 0; } - s32 aAct = smlua_to_integer(L, 3); - if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 3, "warp_to_level"); return 0; } - - lua_pushboolean(L, warp_to_level(aLevel, aArea, aAct)); - - return 1; -} - -int smlua_func_warp_to_start_level(UNUSED lua_State* L) { - if (L == NULL) { return 0; } - - int top = lua_gettop(L); - if (top != 0) { - LOG_LUA_LINE("Improper param count for '%s': Expected %u, Received %u", "warp_to_start_level", 0, top); - return 0; - } - - - lua_pushboolean(L, warp_to_start_level()); - - return 1; -} - -int smlua_func_warp_to_warpnode(lua_State* L) { - if (L == NULL) { return 0; } - - int top = lua_gettop(L); - if (top != 4) { - LOG_LUA_LINE("Improper param count for '%s': Expected %u, Received %u", "warp_to_warpnode", 4, top); - return 0; - } - - s32 aLevel = smlua_to_integer(L, 1); - if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "warp_to_warpnode"); return 0; } - s32 aArea = smlua_to_integer(L, 2); - if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 2, "warp_to_warpnode"); return 0; } - s32 aAct = smlua_to_integer(L, 3); - if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 3, "warp_to_warpnode"); return 0; } - s32 aWarpId = smlua_to_integer(L, 4); - if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 4, "warp_to_warpnode"); return 0; } - - lua_pushboolean(L, warp_to_warpnode(aLevel, aArea, aAct, aWarpId)); - - return 1; -} - - //////////////////////// - // smlua_math_utils.h // -//////////////////////// - -int smlua_func_clamp(lua_State* L) { - if (L == NULL) { return 0; } - - int top = lua_gettop(L); - if (top != 3) { - LOG_LUA_LINE("Improper param count for '%s': Expected %u, Received %u", "clamp", 3, top); - return 0; - } - - s32 a = smlua_to_integer(L, 1); - if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "clamp"); return 0; } - s32 b = smlua_to_integer(L, 2); - if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 2, "clamp"); return 0; } - s32 c = smlua_to_integer(L, 3); - if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 3, "clamp"); return 0; } - - lua_pushinteger(L, clamp(a, b, c)); - - return 1; -} - -int smlua_func_clampf(lua_State* L) { - if (L == NULL) { return 0; } - - int top = lua_gettop(L); - if (top != 3) { - LOG_LUA_LINE("Improper param count for '%s': Expected %u, Received %u", "clampf", 3, top); - return 0; - } - - f32 a = smlua_to_number(L, 1); - if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "clampf"); return 0; } - f32 b = smlua_to_number(L, 2); - if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 2, "clampf"); return 0; } - f32 c = smlua_to_number(L, 3); - if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 3, "clampf"); return 0; } - - lua_pushnumber(L, clampf(a, b, c)); - - return 1; -} - -int smlua_func_max(lua_State* L) { - if (L == NULL) { return 0; } - - int top = lua_gettop(L); - if (top != 2) { - LOG_LUA_LINE("Improper param count for '%s': Expected %u, Received %u", "max", 2, top); - return 0; - } - - s32 a = smlua_to_integer(L, 1); - if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "max"); return 0; } - s32 b = smlua_to_integer(L, 2); - if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 2, "max"); return 0; } - - lua_pushinteger(L, max(a, b)); - - return 1; -} - -int smlua_func_maxf(lua_State* L) { - if (L == NULL) { return 0; } - - int top = lua_gettop(L); - if (top != 2) { - LOG_LUA_LINE("Improper param count for '%s': Expected %u, Received %u", "maxf", 2, top); - return 0; - } - - f32 a = smlua_to_number(L, 1); - if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "maxf"); return 0; } - f32 b = smlua_to_number(L, 2); - if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 2, "maxf"); return 0; } - - lua_pushnumber(L, maxf(a, b)); - - return 1; -} - -int smlua_func_min(lua_State* L) { - if (L == NULL) { return 0; } - - int top = lua_gettop(L); - if (top != 2) { - LOG_LUA_LINE("Improper param count for '%s': Expected %u, Received %u", "min", 2, top); - return 0; - } - - s32 a = smlua_to_integer(L, 1); - if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "min"); return 0; } - s32 b = smlua_to_integer(L, 2); - if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 2, "min"); return 0; } - - lua_pushinteger(L, min(a, b)); - - return 1; -} - -int smlua_func_minf(lua_State* L) { - if (L == NULL) { return 0; } - - int top = lua_gettop(L); - if (top != 2) { - LOG_LUA_LINE("Improper param count for '%s': Expected %u, Received %u", "minf", 2, top); - return 0; - } - - f32 a = smlua_to_number(L, 1); - if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "minf"); return 0; } - f32 b = smlua_to_number(L, 2); - if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 2, "minf"); return 0; } - - lua_pushnumber(L, minf(a, b)); - - return 1; -} - -int smlua_func_sqr(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", "sqr", 1, top); - return 0; - } - - s32 x = smlua_to_integer(L, 1); - if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "sqr"); return 0; } - - lua_pushinteger(L, sqr(x)); - - return 1; -} - -int smlua_func_sqrf(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", "sqrf", 1, top); - return 0; - } - - f32 x = smlua_to_number(L, 1); - if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "sqrf"); return 0; } - - lua_pushnumber(L, sqrf(x)); - - return 1; -} - - //////////////////////// - // smlua_misc_utils.h // -//////////////////////// - -int smlua_func_allocate_mario_action(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", "allocate_mario_action", 1, top); - return 0; - } - - u32 actFlags = smlua_to_integer(L, 1); - if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "allocate_mario_action"); return 0; } - - lua_pushinteger(L, allocate_mario_action(actFlags)); - - return 1; -} + ////////////////////////// + // smlua_camera_utils.h // +////////////////////////// int smlua_func_camera_allow_toxic_gas_camera(lua_State* L) { if (L == NULL) { return 0; } @@ -29510,6 +28791,1030 @@ int smlua_func_camera_unfreeze(UNUSED lua_State* L) { return 1; } + ///////////////////////////// + // smlua_collision_utils.h // +///////////////////////////// + +int smlua_func_collision_find_ceil(lua_State* L) { + if (L == NULL) { return 0; } + + int top = lua_gettop(L); + if (top != 3) { + LOG_LUA_LINE("Improper param count for '%s': Expected %u, Received %u", "collision_find_ceil", 3, top); + return 0; + } + + f32 x = smlua_to_number(L, 1); + if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "collision_find_ceil"); return 0; } + f32 y = smlua_to_number(L, 2); + if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 2, "collision_find_ceil"); return 0; } + f32 z = smlua_to_number(L, 3); + if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 3, "collision_find_ceil"); return 0; } + + smlua_push_object(L, LOT_SURFACE, collision_find_ceil(x, y, z)); + + return 1; +} + +int smlua_func_collision_find_floor(lua_State* L) { + if (L == NULL) { return 0; } + + int top = lua_gettop(L); + if (top != 3) { + LOG_LUA_LINE("Improper param count for '%s': Expected %u, Received %u", "collision_find_floor", 3, top); + return 0; + } + + f32 x = smlua_to_number(L, 1); + if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "collision_find_floor"); return 0; } + f32 y = smlua_to_number(L, 2); + if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 2, "collision_find_floor"); return 0; } + f32 z = smlua_to_number(L, 3); + if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 3, "collision_find_floor"); return 0; } + + smlua_push_object(L, LOT_SURFACE, collision_find_floor(x, y, z)); + + return 1; +} + +int smlua_func_collision_get_temp_wall_collision_data(UNUSED lua_State* L) { + if (L == NULL) { return 0; } + + int top = lua_gettop(L); + if (top != 0) { + LOG_LUA_LINE("Improper param count for '%s': Expected %u, Received %u", "collision_get_temp_wall_collision_data", 0, top); + return 0; + } + + + smlua_push_object(L, LOT_WALLCOLLISIONDATA, collision_get_temp_wall_collision_data()); + + return 1; +} + +int smlua_func_get_surface_from_wcd_index(lua_State* L) { + if (L == NULL) { return 0; } + + int top = lua_gettop(L); + if (top != 2) { + LOG_LUA_LINE("Improper param count for '%s': Expected %u, Received %u", "get_surface_from_wcd_index", 2, top); + return 0; + } + + struct WallCollisionData* wcd = (struct WallCollisionData*)smlua_to_cobject(L, 1, LOT_WALLCOLLISIONDATA); + if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "get_surface_from_wcd_index"); return 0; } + s8 index = smlua_to_integer(L, 2); + if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 2, "get_surface_from_wcd_index"); return 0; } + + smlua_push_object(L, LOT_SURFACE, get_surface_from_wcd_index(wcd, index)); + + return 1; +} + +int smlua_func_get_water_surface_pseudo_floor(UNUSED lua_State* L) { + if (L == NULL) { return 0; } + + int top = lua_gettop(L); + if (top != 0) { + LOG_LUA_LINE("Improper param count for '%s': Expected %u, Received %u", "get_water_surface_pseudo_floor", 0, top); + return 0; + } + + + smlua_push_object(L, LOT_SURFACE, get_water_surface_pseudo_floor()); + + return 1; +} + +int smlua_func_smlua_collision_util_get(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", "smlua_collision_util_get", 1, top); + return 0; + } + + const char* name = smlua_to_string(L, 1); + if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "smlua_collision_util_get"); return 0; } + + smlua_push_pointer(L, LVT_COLLISION_P, (void*)smlua_collision_util_get(name)); + + return 1; +} + + //////////////////////// + // smlua_deprecated.h // +//////////////////////// + +int smlua_func_audio_stream_get_tempo(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", "audio_stream_get_tempo", 1, top); + return 0; + } + + struct ModAudio* audio = (struct ModAudio*)smlua_to_cobject(L, 1, LOT_MODAUDIO); + if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "audio_stream_get_tempo"); return 0; } + + lua_pushnumber(L, audio_stream_get_tempo(audio)); + + return 1; +} + +int smlua_func_audio_stream_load_url(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", "audio_stream_load_url", 1, top); + return 0; + } + + const char* url = smlua_to_string(L, 1); + if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "audio_stream_load_url"); return 0; } + + smlua_push_object(L, LOT_MODAUDIO, audio_stream_load_url(url)); + + return 1; +} + +int smlua_func_audio_stream_set_speed(lua_State* L) { + if (L == NULL) { return 0; } + + int top = lua_gettop(L); + if (top != 4) { + LOG_LUA_LINE("Improper param count for '%s': Expected %u, Received %u", "audio_stream_set_speed", 4, top); + return 0; + } + + struct ModAudio* audio = (struct ModAudio*)smlua_to_cobject(L, 1, LOT_MODAUDIO); + if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "audio_stream_set_speed"); return 0; } + f32 initial_freq = smlua_to_number(L, 2); + if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 2, "audio_stream_set_speed"); return 0; } + f32 speed = smlua_to_number(L, 3); + if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 3, "audio_stream_set_speed"); return 0; } + bool pitch = smlua_to_boolean(L, 4); + if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 4, "audio_stream_set_speed"); return 0; } + + audio_stream_set_speed(audio, initial_freq, speed, pitch); + + return 1; +} + +int smlua_func_audio_stream_set_tempo(lua_State* L) { + if (L == NULL) { return 0; } + + int top = lua_gettop(L); + if (top != 2) { + LOG_LUA_LINE("Improper param count for '%s': Expected %u, Received %u", "audio_stream_set_tempo", 2, top); + return 0; + } + + struct ModAudio* audio = (struct ModAudio*)smlua_to_cobject(L, 1, LOT_MODAUDIO); + if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "audio_stream_set_tempo"); return 0; } + f32 tempo = smlua_to_number(L, 2); + if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 2, "audio_stream_set_tempo"); return 0; } + + audio_stream_set_tempo(audio, tempo); + + return 1; +} + +int smlua_func_djui_hud_set_render_behind_hud(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", "djui_hud_set_render_behind_hud", 1, top); + return 0; + } + + bool enable = smlua_to_boolean(L, 1); + if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "djui_hud_set_render_behind_hud"); return 0; } + + djui_hud_set_render_behind_hud(enable); + + return 1; +} + +int smlua_func_get_environment_region(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", "get_environment_region", 1, top); + return 0; + } + + u8 index = smlua_to_integer(L, 1); + if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "get_environment_region"); return 0; } + + lua_pushnumber(L, get_environment_region(index)); + + return 1; +} + +int smlua_func_network_discord_id_from_local_index(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", "network_discord_id_from_local_index", 1, top); + return 0; + } + + u8 localIndex = smlua_to_integer(L, 1); + if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "network_discord_id_from_local_index"); return 0; } + + lua_pushstring(L, network_discord_id_from_local_index(localIndex)); + + return 1; +} + +int smlua_func_network_player_color_to_palette(lua_State* L) { + if (L == NULL) { return 0; } + + int top = lua_gettop(L); + if (top != 3) { + LOG_LUA_LINE("Improper param count for '%s': Expected %u, Received %u", "network_player_color_to_palette", 3, top); + return 0; + } + + struct NetworkPlayer* np = (struct NetworkPlayer*)smlua_to_cobject(L, 1, LOT_NETWORKPLAYER); + if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "network_player_color_to_palette"); return 0; } + int part = smlua_to_integer(L, 2); + if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 2, "network_player_color_to_palette"); return 0; } + + u8* color = smlua_get_color_from_buffer(); + color[0] = smlua_get_integer_field(3, "r"); + color[1] = smlua_get_integer_field(3, "g"); + color[2] = smlua_get_integer_field(3, "b"); + if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 3, "network_player_color_to_palette"); return 0; } + + network_player_color_to_palette(np, part, color); + + smlua_push_integer_field(3, "r", color[0]); + smlua_push_integer_field(3, "g", color[1]); + smlua_push_integer_field(3, "b", color[2]); + + return 1; +} + +int smlua_func_network_player_palette_to_color(lua_State* L) { + if (L == NULL) { return 0; } + + int top = lua_gettop(L); + if (top != 3) { + LOG_LUA_LINE("Improper param count for '%s': Expected %u, Received %u", "network_player_palette_to_color", 3, top); + return 0; + } + + struct NetworkPlayer* np = (struct NetworkPlayer*)smlua_to_cobject(L, 1, LOT_NETWORKPLAYER); + if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "network_player_palette_to_color"); return 0; } + int part = smlua_to_integer(L, 2); + if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 2, "network_player_palette_to_color"); return 0; } + + u8* out = smlua_get_color_from_buffer(); + out[0] = smlua_get_integer_field(3, "r"); + out[1] = smlua_get_integer_field(3, "g"); + out[2] = smlua_get_integer_field(3, "b"); + if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 3, "network_player_palette_to_color"); return 0; } + + network_player_palette_to_color(np, part, out); + + smlua_push_integer_field(3, "r", out[0]); + smlua_push_integer_field(3, "g", out[1]); + smlua_push_integer_field(3, "b", out[2]); + + return 1; +} + +int smlua_func_set_environment_region(lua_State* L) { + if (L == NULL) { return 0; } + + int top = lua_gettop(L); + if (top != 2) { + LOG_LUA_LINE("Improper param count for '%s': Expected %u, Received %u", "set_environment_region", 2, top); + return 0; + } + + u8 index = smlua_to_integer(L, 1); + if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "set_environment_region"); return 0; } + s32 value = smlua_to_integer(L, 2); + if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 2, "set_environment_region"); return 0; } + + set_environment_region(index, value); + + return 1; +} + + /////////////////////// + // smlua_gfx_utils.h // +/////////////////////// + +int smlua_func_get_fog_color(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", "get_fog_color", 1, top); + return 0; + } + + u8 index = smlua_to_integer(L, 1); + if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "get_fog_color"); return 0; } + + lua_pushinteger(L, get_fog_color(index)); + + return 1; +} + +int smlua_func_get_fog_intensity(UNUSED lua_State* L) { + if (L == NULL) { return 0; } + + int top = lua_gettop(L); + if (top != 0) { + LOG_LUA_LINE("Improper param count for '%s': Expected %u, Received %u", "get_fog_intensity", 0, top); + return 0; + } + + + lua_pushnumber(L, get_fog_intensity()); + + return 1; +} + +int smlua_func_get_lighting_color(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", "get_lighting_color", 1, top); + return 0; + } + + u8 index = smlua_to_integer(L, 1); + if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "get_lighting_color"); return 0; } + + lua_pushinteger(L, get_lighting_color(index)); + + return 1; +} + +int smlua_func_get_lighting_dir(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", "get_lighting_dir", 1, top); + return 0; + } + + u8 index = smlua_to_integer(L, 1); + if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "get_lighting_dir"); return 0; } + + lua_pushnumber(L, get_lighting_dir(index)); + + return 1; +} + +int smlua_func_get_skybox(UNUSED lua_State* L) { + if (L == NULL) { return 0; } + + int top = lua_gettop(L); + if (top != 0) { + LOG_LUA_LINE("Improper param count for '%s': Expected %u, Received %u", "get_skybox", 0, top); + return 0; + } + + + lua_pushinteger(L, get_skybox()); + + return 1; +} + +int smlua_func_get_skybox_color(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", "get_skybox_color", 1, top); + return 0; + } + + u8 index = smlua_to_integer(L, 1); + if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "get_skybox_color"); return 0; } + + lua_pushinteger(L, get_skybox_color(index)); + + return 1; +} + +int smlua_func_get_vertex_color(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", "get_vertex_color", 1, top); + return 0; + } + + u8 index = smlua_to_integer(L, 1); + if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "get_vertex_color"); return 0; } + + lua_pushinteger(L, get_vertex_color(index)); + + return 1; +} + +int smlua_func_set_fog_color(lua_State* L) { + if (L == NULL) { return 0; } + + int top = lua_gettop(L); + if (top != 2) { + LOG_LUA_LINE("Improper param count for '%s': Expected %u, Received %u", "set_fog_color", 2, top); + return 0; + } + + u8 index = smlua_to_integer(L, 1); + if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "set_fog_color"); return 0; } + u8 value = smlua_to_integer(L, 2); + if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 2, "set_fog_color"); return 0; } + + set_fog_color(index, value); + + return 1; +} + +int smlua_func_set_fog_intensity(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", "set_fog_intensity", 1, top); + return 0; + } + + f32 intensity = smlua_to_number(L, 1); + if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "set_fog_intensity"); return 0; } + + set_fog_intensity(intensity); + + return 1; +} + +int smlua_func_set_lighting_color(lua_State* L) { + if (L == NULL) { return 0; } + + int top = lua_gettop(L); + if (top != 2) { + LOG_LUA_LINE("Improper param count for '%s': Expected %u, Received %u", "set_lighting_color", 2, top); + return 0; + } + + u8 index = smlua_to_integer(L, 1); + if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "set_lighting_color"); return 0; } + u8 value = smlua_to_integer(L, 2); + if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 2, "set_lighting_color"); return 0; } + + set_lighting_color(index, value); + + return 1; +} + +int smlua_func_set_lighting_dir(lua_State* L) { + if (L == NULL) { return 0; } + + int top = lua_gettop(L); + if (top != 2) { + LOG_LUA_LINE("Improper param count for '%s': Expected %u, Received %u", "set_lighting_dir", 2, top); + return 0; + } + + u8 index = smlua_to_integer(L, 1); + if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "set_lighting_dir"); return 0; } + f32 value = smlua_to_number(L, 2); + if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 2, "set_lighting_dir"); return 0; } + + set_lighting_dir(index, value); + + return 1; +} + +int smlua_func_set_override_far(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", "set_override_far", 1, top); + return 0; + } + + f32 far = smlua_to_number(L, 1); + if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "set_override_far"); return 0; } + + set_override_far(far); + + return 1; +} + +int smlua_func_set_override_fov(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", "set_override_fov", 1, top); + return 0; + } + + f32 fov = smlua_to_number(L, 1); + if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "set_override_fov"); return 0; } + + set_override_fov(fov); + + return 1; +} + +int smlua_func_set_override_near(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", "set_override_near", 1, top); + return 0; + } + + f32 near = smlua_to_number(L, 1); + if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "set_override_near"); return 0; } + + set_override_near(near); + + return 1; +} + +int smlua_func_set_override_skybox(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", "set_override_skybox", 1, top); + return 0; + } + + s8 background = smlua_to_integer(L, 1); + if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "set_override_skybox"); return 0; } + + set_override_skybox(background); + + return 1; +} + +int smlua_func_set_skybox_color(lua_State* L) { + if (L == NULL) { return 0; } + + int top = lua_gettop(L); + if (top != 2) { + LOG_LUA_LINE("Improper param count for '%s': Expected %u, Received %u", "set_skybox_color", 2, top); + return 0; + } + + u8 index = smlua_to_integer(L, 1); + if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "set_skybox_color"); return 0; } + u8 value = smlua_to_integer(L, 2); + if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 2, "set_skybox_color"); return 0; } + + set_skybox_color(index, value); + + return 1; +} + +int smlua_func_set_vertex_color(lua_State* L) { + if (L == NULL) { return 0; } + + int top = lua_gettop(L); + if (top != 2) { + LOG_LUA_LINE("Improper param count for '%s': Expected %u, Received %u", "set_vertex_color", 2, top); + return 0; + } + + u8 index = smlua_to_integer(L, 1); + if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "set_vertex_color"); return 0; } + u8 value = smlua_to_integer(L, 2); + if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 2, "set_vertex_color"); return 0; } + + set_vertex_color(index, value); + + return 1; +} + + ///////////////////////// + // smlua_level_utils.h // +///////////////////////// + +int smlua_func_level_is_vanilla_level(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", "level_is_vanilla_level", 1, top); + return 0; + } + + s16 levelNum = smlua_to_integer(L, 1); + if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "level_is_vanilla_level"); return 0; } + + lua_pushboolean(L, level_is_vanilla_level(levelNum)); + + return 1; +} + +int smlua_func_level_register(lua_State* L) { + if (L == NULL) { return 0; } + + int top = lua_gettop(L); + if (top != 8) { + LOG_LUA_LINE("Improper param count for '%s': Expected %u, Received %u", "level_register", 8, top); + return 0; + } + + const char* scriptEntryName = smlua_to_string(L, 1); + if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "level_register"); return 0; } + s16 courseNum = smlua_to_integer(L, 2); + if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 2, "level_register"); return 0; } + const char* fullName = smlua_to_string(L, 3); + if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 3, "level_register"); return 0; } + const char* shortName = smlua_to_string(L, 4); + if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 4, "level_register"); return 0; } + u32 acousticReach = smlua_to_integer(L, 5); + if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 5, "level_register"); return 0; } + u32 echoLevel1 = smlua_to_integer(L, 6); + if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 6, "level_register"); return 0; } + u32 echoLevel2 = smlua_to_integer(L, 7); + if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 7, "level_register"); return 0; } + u32 echoLevel3 = smlua_to_integer(L, 8); + if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 8, "level_register"); return 0; } + + lua_pushinteger(L, level_register(scriptEntryName, courseNum, fullName, shortName, acousticReach, echoLevel1, echoLevel2, echoLevel3)); + + return 1; +} + +int smlua_func_smlua_level_util_change_area(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", "smlua_level_util_change_area", 1, top); + return 0; + } + + s32 areaIndex = smlua_to_integer(L, 1); + if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "smlua_level_util_change_area"); return 0; } + + smlua_level_util_change_area(areaIndex); + + return 1; +} + +int smlua_func_smlua_level_util_get_info(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", "smlua_level_util_get_info", 1, top); + return 0; + } + + s16 levelNum = smlua_to_integer(L, 1); + if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "smlua_level_util_get_info"); return 0; } + + smlua_push_object(L, LOT_CUSTOMLEVELINFO, smlua_level_util_get_info(levelNum)); + + return 1; +} + +int smlua_func_smlua_level_util_get_info_from_course_num(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", "smlua_level_util_get_info_from_course_num", 1, top); + return 0; + } + + u8 courseNum = smlua_to_integer(L, 1); + if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "smlua_level_util_get_info_from_course_num"); return 0; } + + smlua_push_object(L, LOT_CUSTOMLEVELINFO, smlua_level_util_get_info_from_course_num(courseNum)); + + return 1; +} + +int smlua_func_smlua_level_util_get_info_from_short_name(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", "smlua_level_util_get_info_from_short_name", 1, top); + return 0; + } + + const char* shortName = smlua_to_string(L, 1); + if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "smlua_level_util_get_info_from_short_name"); return 0; } + + smlua_push_object(L, LOT_CUSTOMLEVELINFO, smlua_level_util_get_info_from_short_name(shortName)); + + return 1; +} + +int smlua_func_warp_exit_level(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", "warp_exit_level", 1, top); + return 0; + } + + s32 aDelay = smlua_to_integer(L, 1); + if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "warp_exit_level"); return 0; } + + lua_pushboolean(L, warp_exit_level(aDelay)); + + return 1; +} + +int smlua_func_warp_restart_level(UNUSED lua_State* L) { + if (L == NULL) { return 0; } + + int top = lua_gettop(L); + if (top != 0) { + LOG_LUA_LINE("Improper param count for '%s': Expected %u, Received %u", "warp_restart_level", 0, top); + return 0; + } + + + lua_pushboolean(L, warp_restart_level()); + + return 1; +} + +int smlua_func_warp_to_castle(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", "warp_to_castle", 1, top); + return 0; + } + + s32 aLevel = smlua_to_integer(L, 1); + if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "warp_to_castle"); return 0; } + + lua_pushboolean(L, warp_to_castle(aLevel)); + + return 1; +} + +int smlua_func_warp_to_level(lua_State* L) { + if (L == NULL) { return 0; } + + int top = lua_gettop(L); + if (top != 3) { + LOG_LUA_LINE("Improper param count for '%s': Expected %u, Received %u", "warp_to_level", 3, top); + return 0; + } + + s32 aLevel = smlua_to_integer(L, 1); + if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "warp_to_level"); return 0; } + s32 aArea = smlua_to_integer(L, 2); + if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 2, "warp_to_level"); return 0; } + s32 aAct = smlua_to_integer(L, 3); + if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 3, "warp_to_level"); return 0; } + + lua_pushboolean(L, warp_to_level(aLevel, aArea, aAct)); + + return 1; +} + +int smlua_func_warp_to_start_level(UNUSED lua_State* L) { + if (L == NULL) { return 0; } + + int top = lua_gettop(L); + if (top != 0) { + LOG_LUA_LINE("Improper param count for '%s': Expected %u, Received %u", "warp_to_start_level", 0, top); + return 0; + } + + + lua_pushboolean(L, warp_to_start_level()); + + return 1; +} + +int smlua_func_warp_to_warpnode(lua_State* L) { + if (L == NULL) { return 0; } + + int top = lua_gettop(L); + if (top != 4) { + LOG_LUA_LINE("Improper param count for '%s': Expected %u, Received %u", "warp_to_warpnode", 4, top); + return 0; + } + + s32 aLevel = smlua_to_integer(L, 1); + if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "warp_to_warpnode"); return 0; } + s32 aArea = smlua_to_integer(L, 2); + if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 2, "warp_to_warpnode"); return 0; } + s32 aAct = smlua_to_integer(L, 3); + if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 3, "warp_to_warpnode"); return 0; } + s32 aWarpId = smlua_to_integer(L, 4); + if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 4, "warp_to_warpnode"); return 0; } + + lua_pushboolean(L, warp_to_warpnode(aLevel, aArea, aAct, aWarpId)); + + return 1; +} + + //////////////////////// + // smlua_math_utils.h // +//////////////////////// + +int smlua_func_clamp(lua_State* L) { + if (L == NULL) { return 0; } + + int top = lua_gettop(L); + if (top != 3) { + LOG_LUA_LINE("Improper param count for '%s': Expected %u, Received %u", "clamp", 3, top); + return 0; + } + + s32 a = smlua_to_integer(L, 1); + if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "clamp"); return 0; } + s32 b = smlua_to_integer(L, 2); + if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 2, "clamp"); return 0; } + s32 c = smlua_to_integer(L, 3); + if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 3, "clamp"); return 0; } + + lua_pushinteger(L, clamp(a, b, c)); + + return 1; +} + +int smlua_func_clampf(lua_State* L) { + if (L == NULL) { return 0; } + + int top = lua_gettop(L); + if (top != 3) { + LOG_LUA_LINE("Improper param count for '%s': Expected %u, Received %u", "clampf", 3, top); + return 0; + } + + f32 a = smlua_to_number(L, 1); + if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "clampf"); return 0; } + f32 b = smlua_to_number(L, 2); + if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 2, "clampf"); return 0; } + f32 c = smlua_to_number(L, 3); + if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 3, "clampf"); return 0; } + + lua_pushnumber(L, clampf(a, b, c)); + + return 1; +} + +int smlua_func_max(lua_State* L) { + if (L == NULL) { return 0; } + + int top = lua_gettop(L); + if (top != 2) { + LOG_LUA_LINE("Improper param count for '%s': Expected %u, Received %u", "max", 2, top); + return 0; + } + + s32 a = smlua_to_integer(L, 1); + if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "max"); return 0; } + s32 b = smlua_to_integer(L, 2); + if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 2, "max"); return 0; } + + lua_pushinteger(L, max(a, b)); + + return 1; +} + +int smlua_func_maxf(lua_State* L) { + if (L == NULL) { return 0; } + + int top = lua_gettop(L); + if (top != 2) { + LOG_LUA_LINE("Improper param count for '%s': Expected %u, Received %u", "maxf", 2, top); + return 0; + } + + f32 a = smlua_to_number(L, 1); + if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "maxf"); return 0; } + f32 b = smlua_to_number(L, 2); + if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 2, "maxf"); return 0; } + + lua_pushnumber(L, maxf(a, b)); + + return 1; +} + +int smlua_func_min(lua_State* L) { + if (L == NULL) { return 0; } + + int top = lua_gettop(L); + if (top != 2) { + LOG_LUA_LINE("Improper param count for '%s': Expected %u, Received %u", "min", 2, top); + return 0; + } + + s32 a = smlua_to_integer(L, 1); + if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "min"); return 0; } + s32 b = smlua_to_integer(L, 2); + if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 2, "min"); return 0; } + + lua_pushinteger(L, min(a, b)); + + return 1; +} + +int smlua_func_minf(lua_State* L) { + if (L == NULL) { return 0; } + + int top = lua_gettop(L); + if (top != 2) { + LOG_LUA_LINE("Improper param count for '%s': Expected %u, Received %u", "minf", 2, top); + return 0; + } + + f32 a = smlua_to_number(L, 1); + if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "minf"); return 0; } + f32 b = smlua_to_number(L, 2); + if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 2, "minf"); return 0; } + + lua_pushnumber(L, minf(a, b)); + + return 1; +} + +int smlua_func_sqr(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", "sqr", 1, top); + return 0; + } + + s32 x = smlua_to_integer(L, 1); + if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "sqr"); return 0; } + + lua_pushinteger(L, sqr(x)); + + return 1; +} + +int smlua_func_sqrf(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", "sqrf", 1, top); + return 0; + } + + f32 x = smlua_to_number(L, 1); + if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "sqrf"); return 0; } + + lua_pushnumber(L, sqrf(x)); + + return 1; +} + + //////////////////////// + // smlua_misc_utils.h // +//////////////////////// + +int smlua_func_allocate_mario_action(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", "allocate_mario_action", 1, top); + return 0; + } + + u32 actFlags = smlua_to_integer(L, 1); + if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "allocate_mario_action"); return 0; } + + lua_pushinteger(L, allocate_mario_action(actFlags)); + + return 1; +} + int smlua_func_course_is_main_course(lua_State* L) { if (L == NULL) { return 0; } @@ -29715,38 +30020,6 @@ int smlua_func_get_envfx(UNUSED lua_State* L) { return 1; } -int smlua_func_get_fog_color(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", "get_fog_color", 1, top); - return 0; - } - - u8 index = smlua_to_integer(L, 1); - if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "get_fog_color"); return 0; } - - lua_pushinteger(L, get_fog_color(index)); - - return 1; -} - -int smlua_func_get_fog_intensity(UNUSED lua_State* L) { - if (L == NULL) { return 0; } - - int top = lua_gettop(L); - if (top != 0) { - LOG_LUA_LINE("Improper param count for '%s': Expected %u, Received %u", "get_fog_intensity", 0, top); - return 0; - } - - - lua_pushnumber(L, get_fog_intensity()); - - return 1; -} - int smlua_func_get_global_timer(UNUSED lua_State* L) { if (L == NULL) { return 0; } @@ -29879,40 +30152,6 @@ int smlua_func_get_last_star_or_key(UNUSED lua_State* L) { return 1; } -int smlua_func_get_lighting_color(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", "get_lighting_color", 1, top); - return 0; - } - - u8 index = smlua_to_integer(L, 1); - if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "get_lighting_color"); return 0; } - - lua_pushinteger(L, get_lighting_color(index)); - - return 1; -} - -int smlua_func_get_lighting_dir(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", "get_lighting_dir", 1, top); - return 0; - } - - u8 index = smlua_to_integer(L, 1); - if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "get_lighting_dir"); return 0; } - - lua_pushnumber(L, get_lighting_dir(index)); - - return 1; -} - int smlua_func_get_local_discord_id(UNUSED lua_State* L) { if (L == NULL) { return 0; } @@ -29973,21 +30212,6 @@ int smlua_func_get_save_file_modified(UNUSED lua_State* L) { return 1; } -int smlua_func_get_skybox(UNUSED lua_State* L) { - if (L == NULL) { return 0; } - - int top = lua_gettop(L); - if (top != 0) { - LOG_LUA_LINE("Improper param count for '%s': Expected %u, Received %u", "get_skybox", 0, top); - return 0; - } - - - lua_pushinteger(L, get_skybox()); - - return 1; -} - int smlua_func_get_temp_s32_pointer(lua_State* L) { if (L == NULL) { return 0; } @@ -30035,23 +30259,6 @@ int smlua_func_get_ttc_speed_setting(UNUSED lua_State* L) { return 1; } -int smlua_func_get_vertex_color(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", "get_vertex_color", 1, top); - return 0; - } - - u8 index = smlua_to_integer(L, 1); - if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "get_vertex_color"); return 0; } - - lua_pushinteger(L, get_vertex_color(index)); - - return 1; -} - int smlua_func_get_volume_env(UNUSED lua_State* L) { if (L == NULL) { return 0; } @@ -30425,42 +30632,6 @@ int smlua_func_save_file_set_using_backup_slot(lua_State* L) { return 1; } -int smlua_func_set_fog_color(lua_State* L) { - if (L == NULL) { return 0; } - - int top = lua_gettop(L); - if (top != 2) { - LOG_LUA_LINE("Improper param count for '%s': Expected %u, Received %u", "set_fog_color", 2, top); - return 0; - } - - u8 index = smlua_to_integer(L, 1); - if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "set_fog_color"); return 0; } - u8 value = smlua_to_integer(L, 2); - if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 2, "set_fog_color"); return 0; } - - set_fog_color(index, value); - - return 1; -} - -int smlua_func_set_fog_intensity(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", "set_fog_intensity", 1, top); - return 0; - } - - f32 intensity = smlua_to_number(L, 1); - if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "set_fog_intensity"); return 0; } - - set_fog_intensity(intensity); - - return 1; -} - int smlua_func_set_got_file_coin_hi_score(lua_State* L) { if (L == NULL) { return 0; } @@ -30529,44 +30700,6 @@ int smlua_func_set_last_star_or_key(lua_State* L) { return 1; } -int smlua_func_set_lighting_color(lua_State* L) { - if (L == NULL) { return 0; } - - int top = lua_gettop(L); - if (top != 2) { - LOG_LUA_LINE("Improper param count for '%s': Expected %u, Received %u", "set_lighting_color", 2, top); - return 0; - } - - u8 index = smlua_to_integer(L, 1); - if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "set_lighting_color"); return 0; } - u8 value = smlua_to_integer(L, 2); - if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 2, "set_lighting_color"); return 0; } - - set_lighting_color(index, value); - - return 1; -} - -int smlua_func_set_lighting_dir(lua_State* L) { - if (L == NULL) { return 0; } - - int top = lua_gettop(L); - if (top != 2) { - LOG_LUA_LINE("Improper param count for '%s': Expected %u, Received %u", "set_lighting_dir", 2, top); - return 0; - } - - u8 index = smlua_to_integer(L, 1); - if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "set_lighting_dir"); return 0; } - f32 value = smlua_to_number(L, 2); - if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 2, "set_lighting_dir"); return 0; } - - set_lighting_dir(index, value); - - return 1; -} - int smlua_func_set_override_envfx(lua_State* L) { if (L == NULL) { return 0; } @@ -30584,74 +30717,6 @@ int smlua_func_set_override_envfx(lua_State* L) { return 1; } -int smlua_func_set_override_far(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", "set_override_far", 1, top); - return 0; - } - - f32 far = smlua_to_number(L, 1); - if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "set_override_far"); return 0; } - - set_override_far(far); - - return 1; -} - -int smlua_func_set_override_fov(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", "set_override_fov", 1, top); - return 0; - } - - f32 fov = smlua_to_number(L, 1); - if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "set_override_fov"); return 0; } - - set_override_fov(fov); - - return 1; -} - -int smlua_func_set_override_near(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", "set_override_near", 1, top); - return 0; - } - - f32 near = smlua_to_number(L, 1); - if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "set_override_near"); return 0; } - - set_override_near(near); - - return 1; -} - -int smlua_func_set_override_skybox(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", "set_override_skybox", 1, top); - return 0; - } - - s8 background = smlua_to_integer(L, 1); - if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "set_override_skybox"); return 0; } - - set_override_skybox(background); - - return 1; -} - int smlua_func_set_save_file_modified(lua_State* L) { if (L == NULL) { return 0; } @@ -30686,25 +30751,6 @@ int smlua_func_set_ttc_speed_setting(lua_State* L) { return 1; } -int smlua_func_set_vertex_color(lua_State* L) { - if (L == NULL) { return 0; } - - int top = lua_gettop(L); - if (top != 2) { - LOG_LUA_LINE("Improper param count for '%s': Expected %u, Received %u", "set_vertex_color", 2, top); - return 0; - } - - u8 index = smlua_to_integer(L, 1); - if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "set_vertex_color"); return 0; } - u8 value = smlua_to_integer(L, 2); - if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 2, "set_vertex_color"); return 0; } - - set_vertex_color(index, value); - - return 1; -} - int smlua_func_set_volume_env(lua_State* L) { if (L == NULL) { return 0; } @@ -34150,52 +34196,7 @@ void smlua_bind_functions_autogen(void) { smlua_bind_function(L, "smlua_audio_utils_replace_sequence", smlua_func_smlua_audio_utils_replace_sequence); smlua_bind_function(L, "smlua_audio_utils_reset_all", smlua_func_smlua_audio_utils_reset_all); - // smlua_collision_utils.h - smlua_bind_function(L, "collision_find_ceil", smlua_func_collision_find_ceil); - smlua_bind_function(L, "collision_find_floor", smlua_func_collision_find_floor); - smlua_bind_function(L, "collision_get_temp_wall_collision_data", smlua_func_collision_get_temp_wall_collision_data); - smlua_bind_function(L, "get_surface_from_wcd_index", smlua_func_get_surface_from_wcd_index); - smlua_bind_function(L, "get_water_surface_pseudo_floor", smlua_func_get_water_surface_pseudo_floor); - smlua_bind_function(L, "smlua_collision_util_get", smlua_func_smlua_collision_util_get); - - // smlua_deprecated.h - smlua_bind_function(L, "audio_stream_get_tempo", smlua_func_audio_stream_get_tempo); - smlua_bind_function(L, "audio_stream_load_url", smlua_func_audio_stream_load_url); - smlua_bind_function(L, "audio_stream_set_speed", smlua_func_audio_stream_set_speed); - smlua_bind_function(L, "audio_stream_set_tempo", smlua_func_audio_stream_set_tempo); - smlua_bind_function(L, "djui_hud_set_render_behind_hud", smlua_func_djui_hud_set_render_behind_hud); - smlua_bind_function(L, "get_environment_region", smlua_func_get_environment_region); - smlua_bind_function(L, "network_discord_id_from_local_index", smlua_func_network_discord_id_from_local_index); - smlua_bind_function(L, "network_player_color_to_palette", smlua_func_network_player_color_to_palette); - smlua_bind_function(L, "network_player_palette_to_color", smlua_func_network_player_palette_to_color); - smlua_bind_function(L, "set_environment_region", smlua_func_set_environment_region); - - // smlua_level_utils.h - smlua_bind_function(L, "level_is_vanilla_level", smlua_func_level_is_vanilla_level); - smlua_bind_function(L, "level_register", smlua_func_level_register); - smlua_bind_function(L, "smlua_level_util_change_area", smlua_func_smlua_level_util_change_area); - smlua_bind_function(L, "smlua_level_util_get_info", smlua_func_smlua_level_util_get_info); - smlua_bind_function(L, "smlua_level_util_get_info_from_course_num", smlua_func_smlua_level_util_get_info_from_course_num); - smlua_bind_function(L, "smlua_level_util_get_info_from_short_name", smlua_func_smlua_level_util_get_info_from_short_name); - smlua_bind_function(L, "warp_exit_level", smlua_func_warp_exit_level); - smlua_bind_function(L, "warp_restart_level", smlua_func_warp_restart_level); - smlua_bind_function(L, "warp_to_castle", smlua_func_warp_to_castle); - smlua_bind_function(L, "warp_to_level", smlua_func_warp_to_level); - smlua_bind_function(L, "warp_to_start_level", smlua_func_warp_to_start_level); - smlua_bind_function(L, "warp_to_warpnode", smlua_func_warp_to_warpnode); - - // smlua_math_utils.h - smlua_bind_function(L, "clamp", smlua_func_clamp); - smlua_bind_function(L, "clampf", smlua_func_clampf); - smlua_bind_function(L, "max", smlua_func_max); - smlua_bind_function(L, "maxf", smlua_func_maxf); - smlua_bind_function(L, "min", smlua_func_min); - smlua_bind_function(L, "minf", smlua_func_minf); - smlua_bind_function(L, "sqr", smlua_func_sqr); - smlua_bind_function(L, "sqrf", smlua_func_sqrf); - - // smlua_misc_utils.h - smlua_bind_function(L, "allocate_mario_action", smlua_func_allocate_mario_action); + // smlua_camera_utils.h smlua_bind_function(L, "camera_allow_toxic_gas_camera", smlua_func_camera_allow_toxic_gas_camera); smlua_bind_function(L, "camera_config_enable_analog_cam", smlua_func_camera_config_enable_analog_cam); smlua_bind_function(L, "camera_config_enable_free_cam", smlua_func_camera_config_enable_free_cam); @@ -34224,6 +34225,72 @@ void smlua_bind_functions_autogen(void) { smlua_bind_function(L, "camera_romhack_allow_dpad_usage", smlua_func_camera_romhack_allow_dpad_usage); smlua_bind_function(L, "camera_set_romhack_override", smlua_func_camera_set_romhack_override); smlua_bind_function(L, "camera_unfreeze", smlua_func_camera_unfreeze); + + // smlua_collision_utils.h + smlua_bind_function(L, "collision_find_ceil", smlua_func_collision_find_ceil); + smlua_bind_function(L, "collision_find_floor", smlua_func_collision_find_floor); + smlua_bind_function(L, "collision_get_temp_wall_collision_data", smlua_func_collision_get_temp_wall_collision_data); + smlua_bind_function(L, "get_surface_from_wcd_index", smlua_func_get_surface_from_wcd_index); + smlua_bind_function(L, "get_water_surface_pseudo_floor", smlua_func_get_water_surface_pseudo_floor); + smlua_bind_function(L, "smlua_collision_util_get", smlua_func_smlua_collision_util_get); + + // smlua_deprecated.h + smlua_bind_function(L, "audio_stream_get_tempo", smlua_func_audio_stream_get_tempo); + smlua_bind_function(L, "audio_stream_load_url", smlua_func_audio_stream_load_url); + smlua_bind_function(L, "audio_stream_set_speed", smlua_func_audio_stream_set_speed); + smlua_bind_function(L, "audio_stream_set_tempo", smlua_func_audio_stream_set_tempo); + smlua_bind_function(L, "djui_hud_set_render_behind_hud", smlua_func_djui_hud_set_render_behind_hud); + smlua_bind_function(L, "get_environment_region", smlua_func_get_environment_region); + smlua_bind_function(L, "network_discord_id_from_local_index", smlua_func_network_discord_id_from_local_index); + smlua_bind_function(L, "network_player_color_to_palette", smlua_func_network_player_color_to_palette); + smlua_bind_function(L, "network_player_palette_to_color", smlua_func_network_player_palette_to_color); + smlua_bind_function(L, "set_environment_region", smlua_func_set_environment_region); + + // smlua_gfx_utils.h + smlua_bind_function(L, "get_fog_color", smlua_func_get_fog_color); + smlua_bind_function(L, "get_fog_intensity", smlua_func_get_fog_intensity); + smlua_bind_function(L, "get_lighting_color", smlua_func_get_lighting_color); + smlua_bind_function(L, "get_lighting_dir", smlua_func_get_lighting_dir); + smlua_bind_function(L, "get_skybox", smlua_func_get_skybox); + smlua_bind_function(L, "get_skybox_color", smlua_func_get_skybox_color); + smlua_bind_function(L, "get_vertex_color", smlua_func_get_vertex_color); + smlua_bind_function(L, "set_fog_color", smlua_func_set_fog_color); + smlua_bind_function(L, "set_fog_intensity", smlua_func_set_fog_intensity); + smlua_bind_function(L, "set_lighting_color", smlua_func_set_lighting_color); + smlua_bind_function(L, "set_lighting_dir", smlua_func_set_lighting_dir); + smlua_bind_function(L, "set_override_far", smlua_func_set_override_far); + smlua_bind_function(L, "set_override_fov", smlua_func_set_override_fov); + smlua_bind_function(L, "set_override_near", smlua_func_set_override_near); + smlua_bind_function(L, "set_override_skybox", smlua_func_set_override_skybox); + smlua_bind_function(L, "set_skybox_color", smlua_func_set_skybox_color); + smlua_bind_function(L, "set_vertex_color", smlua_func_set_vertex_color); + + // smlua_level_utils.h + smlua_bind_function(L, "level_is_vanilla_level", smlua_func_level_is_vanilla_level); + smlua_bind_function(L, "level_register", smlua_func_level_register); + smlua_bind_function(L, "smlua_level_util_change_area", smlua_func_smlua_level_util_change_area); + smlua_bind_function(L, "smlua_level_util_get_info", smlua_func_smlua_level_util_get_info); + smlua_bind_function(L, "smlua_level_util_get_info_from_course_num", smlua_func_smlua_level_util_get_info_from_course_num); + smlua_bind_function(L, "smlua_level_util_get_info_from_short_name", smlua_func_smlua_level_util_get_info_from_short_name); + smlua_bind_function(L, "warp_exit_level", smlua_func_warp_exit_level); + smlua_bind_function(L, "warp_restart_level", smlua_func_warp_restart_level); + smlua_bind_function(L, "warp_to_castle", smlua_func_warp_to_castle); + smlua_bind_function(L, "warp_to_level", smlua_func_warp_to_level); + smlua_bind_function(L, "warp_to_start_level", smlua_func_warp_to_start_level); + smlua_bind_function(L, "warp_to_warpnode", smlua_func_warp_to_warpnode); + + // smlua_math_utils.h + smlua_bind_function(L, "clamp", smlua_func_clamp); + smlua_bind_function(L, "clampf", smlua_func_clampf); + smlua_bind_function(L, "max", smlua_func_max); + smlua_bind_function(L, "maxf", smlua_func_maxf); + smlua_bind_function(L, "min", smlua_func_min); + smlua_bind_function(L, "minf", smlua_func_minf); + smlua_bind_function(L, "sqr", smlua_func_sqr); + smlua_bind_function(L, "sqrf", smlua_func_sqrf); + + // smlua_misc_utils.h + smlua_bind_function(L, "allocate_mario_action", smlua_func_allocate_mario_action); smlua_bind_function(L, "course_is_main_course", smlua_func_course_is_main_course); smlua_bind_function(L, "deref_s32_pointer", smlua_func_deref_s32_pointer); smlua_bind_function(L, "djui_is_playerlist_open", smlua_func_djui_is_playerlist_open); @@ -34237,8 +34304,6 @@ void smlua_bind_functions_autogen(void) { smlua_bind_function(L, "get_dialog_id", smlua_func_get_dialog_id); smlua_bind_function(L, "get_dialog_response", smlua_func_get_dialog_response); smlua_bind_function(L, "get_envfx", smlua_func_get_envfx); - smlua_bind_function(L, "get_fog_color", smlua_func_get_fog_color); - smlua_bind_function(L, "get_fog_intensity", smlua_func_get_fog_intensity); smlua_bind_function(L, "get_global_timer", smlua_func_get_global_timer); smlua_bind_function(L, "get_got_file_coin_hi_score", smlua_func_get_got_file_coin_hi_score); smlua_bind_function(L, "get_hand_foot_pos_x", smlua_func_get_hand_foot_pos_x); @@ -34247,17 +34312,13 @@ void smlua_bind_functions_autogen(void) { smlua_bind_function(L, "get_last_completed_course_num", smlua_func_get_last_completed_course_num); smlua_bind_function(L, "get_last_completed_star_num", smlua_func_get_last_completed_star_num); smlua_bind_function(L, "get_last_star_or_key", smlua_func_get_last_star_or_key); - smlua_bind_function(L, "get_lighting_color", smlua_func_get_lighting_color); - smlua_bind_function(L, "get_lighting_dir", smlua_func_get_lighting_dir); smlua_bind_function(L, "get_local_discord_id", smlua_func_get_local_discord_id); smlua_bind_function(L, "get_network_area_timer", smlua_func_get_network_area_timer); smlua_bind_function(L, "get_os_name", smlua_func_get_os_name); smlua_bind_function(L, "get_save_file_modified", smlua_func_get_save_file_modified); - smlua_bind_function(L, "get_skybox", smlua_func_get_skybox); smlua_bind_function(L, "get_temp_s32_pointer", smlua_func_get_temp_s32_pointer); smlua_bind_function(L, "get_time", smlua_func_get_time); smlua_bind_function(L, "get_ttc_speed_setting", smlua_func_get_ttc_speed_setting); - smlua_bind_function(L, "get_vertex_color", smlua_func_get_vertex_color); smlua_bind_function(L, "get_volume_env", smlua_func_get_volume_env); smlua_bind_function(L, "get_volume_level", smlua_func_get_volume_level); smlua_bind_function(L, "get_volume_master", smlua_func_get_volume_master); @@ -34279,22 +34340,13 @@ void smlua_bind_functions_autogen(void) { smlua_bind_function(L, "reset_window_title", smlua_func_reset_window_title); smlua_bind_function(L, "save_file_get_using_backup_slot", smlua_func_save_file_get_using_backup_slot); smlua_bind_function(L, "save_file_set_using_backup_slot", smlua_func_save_file_set_using_backup_slot); - smlua_bind_function(L, "set_fog_color", smlua_func_set_fog_color); - smlua_bind_function(L, "set_fog_intensity", smlua_func_set_fog_intensity); smlua_bind_function(L, "set_got_file_coin_hi_score", smlua_func_set_got_file_coin_hi_score); smlua_bind_function(L, "set_last_completed_course_num", smlua_func_set_last_completed_course_num); smlua_bind_function(L, "set_last_completed_star_num", smlua_func_set_last_completed_star_num); smlua_bind_function(L, "set_last_star_or_key", smlua_func_set_last_star_or_key); - smlua_bind_function(L, "set_lighting_color", smlua_func_set_lighting_color); - smlua_bind_function(L, "set_lighting_dir", smlua_func_set_lighting_dir); smlua_bind_function(L, "set_override_envfx", smlua_func_set_override_envfx); - smlua_bind_function(L, "set_override_far", smlua_func_set_override_far); - smlua_bind_function(L, "set_override_fov", smlua_func_set_override_fov); - smlua_bind_function(L, "set_override_near", smlua_func_set_override_near); - smlua_bind_function(L, "set_override_skybox", smlua_func_set_override_skybox); smlua_bind_function(L, "set_save_file_modified", smlua_func_set_save_file_modified); smlua_bind_function(L, "set_ttc_speed_setting", smlua_func_set_ttc_speed_setting); - smlua_bind_function(L, "set_vertex_color", smlua_func_set_vertex_color); smlua_bind_function(L, "set_volume_env", smlua_func_set_volume_env); smlua_bind_function(L, "set_volume_level", smlua_func_set_volume_level); smlua_bind_function(L, "set_volume_master", smlua_func_set_volume_master); diff --git a/src/pc/lua/utils/smlua_camera_utils.c b/src/pc/lua/utils/smlua_camera_utils.c new file mode 100644 index 00000000..e20ae995 --- /dev/null +++ b/src/pc/lua/utils/smlua_camera_utils.c @@ -0,0 +1,154 @@ +#include "smlua_camera_utils.h" +#include "game/bettercamera.h" + +static struct CameraOverride sOverrideCameraXSens = { 0 }; +static struct CameraOverride sOverrideCameraYSens = { 0 }; +static struct CameraOverride sOverrideCameraAggr = { 0 }; +static struct CameraOverride sOverrideCameraPan = { 0 }; +static struct CameraOverride sOverrideCameraDegrade = { 0 }; +static struct CameraOverride sOverrideCameraInvertX = { 0 }; +static struct CameraOverride sOverrideCameraInvertY = { 0 }; +static struct CameraOverride sOverrideEnableCamera = { 0 }; +static struct CameraOverride sOverrideCameraAnalog = { 0 }; +static struct CameraOverride sOverrideCameraMouse = { 0 }; + +void camera_reset_overrides(void) { + sOverrideCameraXSens.override = false; + sOverrideCameraYSens.override = false; + sOverrideCameraAggr.override = false; + sOverrideCameraPan.override = false; + sOverrideCameraDegrade.override = false; + sOverrideCameraInvertX.override = false; + sOverrideCameraInvertY.override = false; + sOverrideEnableCamera.override = false; + sOverrideCameraAnalog.override = false; + sOverrideCameraMouse.override = false; +} + +void camera_freeze(void) { + gOverrideFreezeCamera = TRUE; +} + +void camera_unfreeze(void) { + gOverrideFreezeCamera = FALSE; +} + +bool camera_is_frozen(void) { + return gOverrideFreezeCamera; +} + +void camera_set_romhack_override(enum RomhackCameraOverride rco) { + gOverrideRomhackCamera = rco; +} + +void camera_romhack_allow_centering(u8 allow) { + gRomhackCameraAllowCentering = allow; +} + +void camera_allow_toxic_gas_camera(u8 allow) { + gOverrideAllowToxicGasCamera = allow; +} + +void camera_romhack_allow_dpad_usage(u8 allow) { + gRomhackCameraAllowDpad = allow; +} + +bool camera_config_is_free_cam_enabled(void) { + return sOverrideEnableCamera.override ? sOverrideEnableCamera.value : configEnableCamera; +} + +bool camera_config_is_analog_cam_enabled(void) { + return sOverrideCameraAnalog.override ? sOverrideCameraAnalog.value : configCameraAnalog; +} + +bool camera_config_is_mouse_look_enabled(void) { + return sOverrideCameraMouse.override ? sOverrideCameraMouse.value : configCameraMouse; +} + +bool camera_config_is_x_inverted(void) { + return sOverrideCameraInvertX.override ? sOverrideCameraInvertX.value : configCameraInvertX; +} + +bool camera_config_is_y_inverted(void) { + return sOverrideCameraInvertY.override ? sOverrideCameraInvertY.value : configCameraInvertY; +} + +u32 camera_config_get_x_sensitivity(void) { + return sOverrideCameraXSens.override ? sOverrideCameraXSens.value : configCameraXSens; +} + +u32 camera_config_get_y_sensitivity(void) { + return sOverrideCameraYSens.override ? sOverrideCameraYSens.value : configCameraYSens; +} + +u32 camera_config_get_aggression(void) { + return sOverrideCameraAggr.override ? sOverrideCameraAggr.value : configCameraAggr; +} + +u32 camera_config_get_pan_level(void) { + return sOverrideCameraPan.override ? sOverrideCameraPan.value : configCameraPan; +} + +u32 camera_config_get_deceleration(void) { + return sOverrideCameraDegrade.override ? sOverrideCameraDegrade.value : configCameraDegrade; +} + +void camera_config_enable_free_cam(bool enable) { + sOverrideEnableCamera.value = enable; + sOverrideEnableCamera.override = true; + newcam_init_settings(); +} + +void camera_config_enable_analog_cam(bool enable) { + sOverrideCameraAnalog.value = enable; + sOverrideCameraAnalog.override = true; + newcam_init_settings(); +} + +void camera_config_enable_mouse_look(bool enable) { + sOverrideCameraMouse.value = enable; + sOverrideCameraMouse.override = true; + newcam_init_settings(); +} + +void camera_config_invert_x(bool invert) { + sOverrideCameraInvertX.value = invert; + sOverrideCameraInvertX.override = true; + newcam_init_settings(); +} + +void camera_config_invert_y(bool invert) { + sOverrideCameraInvertY.value = invert; + sOverrideCameraInvertY.override = true; + newcam_init_settings(); +} + +void camera_config_set_x_sensitivity(u32 value) { + sOverrideCameraXSens.value = MIN(MAX(value, 1), 100); + sOverrideCameraXSens.override = true; + newcam_init_settings(); +} + +void camera_config_set_y_sensitivity(u32 value) { + sOverrideCameraYSens.value = MIN(MAX(value, 1), 100); + sOverrideCameraYSens.override = true; + newcam_init_settings(); +} + +void camera_config_set_aggression(u32 value) { + sOverrideCameraAggr.value = MIN(MAX(value, 0), 100); + sOverrideCameraAggr.override = true; + newcam_init_settings(); +} + +void camera_config_set_pan_level(u32 value) { + sOverrideCameraPan.value = MIN(MAX(value, 0), 100); + sOverrideCameraPan.override = true; + newcam_init_settings(); +} + +void camera_config_set_deceleration(u32 value) { + sOverrideCameraDegrade.value = MIN(MAX(value, 0), 100); + sOverrideCameraDegrade.override = true; + newcam_init_settings(); +} diff --git a/src/pc/lua/utils/smlua_camera_utils.h b/src/pc/lua/utils/smlua_camera_utils.h new file mode 100644 index 00000000..57ac352b --- /dev/null +++ b/src/pc/lua/utils/smlua_camera_utils.h @@ -0,0 +1,43 @@ +#ifndef SMLUA_CAMERA_UTILS_H +#define SMLUA_CAMERA_UTILS_H + +#include "types.h" +#include "game/camera.h" + +struct CameraOverride { + unsigned int value; + bool override; +}; + +void camera_reset_overrides(void); +void camera_freeze(void); +void camera_unfreeze(void); +bool camera_is_frozen(void); +void camera_set_romhack_override(enum RomhackCameraOverride rco); +void camera_romhack_allow_centering(u8 allow); +void camera_allow_toxic_gas_camera(u8 allow); +void camera_romhack_allow_dpad_usage(u8 allow); + +bool camera_config_is_free_cam_enabled(void); +bool camera_config_is_analog_cam_enabled(void); +bool camera_config_is_mouse_look_enabled(void); +bool camera_config_is_x_inverted(void); +bool camera_config_is_y_inverted(void); +u32 camera_config_get_x_sensitivity(void); +u32 camera_config_get_y_sensitivity(void); +u32 camera_config_get_aggression(void); +u32 camera_config_get_pan_level(void); +u32 camera_config_get_deceleration(void); + +void camera_config_enable_free_cam(bool enable); +void camera_config_enable_analog_cam(bool enable); +void camera_config_enable_mouse_look(bool enable); +void camera_config_invert_x(bool invert); +void camera_config_invert_y(bool invert); +void camera_config_set_x_sensitivity(u32 value); +void camera_config_set_y_sensitivity(u32 value); +void camera_config_set_aggression(u32 value); +void camera_config_set_pan_level(u32 value); +void camera_config_set_deceleration(u32 value); + +#endif diff --git a/src/pc/lua/utils/smlua_gfx_utils.c b/src/pc/lua/utils/smlua_gfx_utils.c new file mode 100644 index 00000000..67fea012 --- /dev/null +++ b/src/pc/lua/utils/smlua_gfx_utils.c @@ -0,0 +1,94 @@ +#include "smlua_gfx_utils.h" +#include "pc/gfx/gfx_pc.h" +#include "game/rendering_graph_node.h" +#include "game/skybox.h" + +void set_override_fov(f32 fov) { + gOverrideFOV = fov; +} + +/// + +void set_override_near(f32 nearClip) { + gOverrideNear = nearClip; +} + +/// + +void set_override_far(f32 farClip) { + gOverrideFar = farClip; +} + +/// + +f32 get_lighting_dir(u8 index) { + if (index > 2) { return 0; } + return gLightingDir[index]; +} + +void set_lighting_dir(u8 index, f32 value) { + if (index > 2) { return; } + gLightingDir[index] = value; +} + +u8 get_lighting_color(u8 index) { + if (index > 2) { return 0; } + return gLightingColor[index]; +} + +void set_lighting_color(u8 index, u8 value) { + if (index > 2) { return; } + gLightingColor[index] = value; +} + +/// + +u8 get_vertex_color(u8 index) { + if (index > 2) { return 0; } + return gVertexColor[index]; +} + +void set_vertex_color(u8 index, u8 value) { + if (index > 2) { return; } + gVertexColor[index] = value; +} + +/// + +u8 get_fog_color(u8 index) { + if (index > 2) { return 0; } + return gFogColor[index]; +} + +void set_fog_color(u8 index, u8 value) { + if (index > 2) { return; } + gFogColor[index] = value; +} + +f32 get_fog_intensity(void) { + return gFogIntensity; +} + +void set_fog_intensity(f32 intensity) { + gFogIntensity = intensity; +} + +/// + +s8 get_skybox(void) { + return gReadOnlyBackground; +} + +void set_override_skybox(s8 background) { + gOverrideBackground = background; +} + +u8 get_skybox_color(u8 index) { + if (index > 2) { return 0; } + return gSkyboxColor[index]; +} + +void set_skybox_color(u8 index, u8 value) { + if (index > 2) { return; } + gSkyboxColor[index] = value; +} diff --git a/src/pc/lua/utils/smlua_gfx_utils.h b/src/pc/lua/utils/smlua_gfx_utils.h new file mode 100644 index 00000000..c4804d44 --- /dev/null +++ b/src/pc/lua/utils/smlua_gfx_utils.h @@ -0,0 +1,29 @@ +#ifndef SMLUA_GFX_UTILS_H +#define SMLUA_GFX_UTILS_H + +#include "types.h" + +void set_override_fov(f32 fov); +void set_override_near(f32 near); +void set_override_far(f32 far); + +f32 get_lighting_dir(u8 index); +void set_lighting_dir(u8 index, f32 value); + +u8 get_lighting_color(u8 index); +void set_lighting_color(u8 index, u8 value); + +u8 get_vertex_color(u8 index); +void set_vertex_color(u8 index, u8 value); + +u8 get_fog_color(u8 index); +void set_fog_color(u8 index, u8 value); +f32 get_fog_intensity(void); +void set_fog_intensity(f32 intensity); + +s8 get_skybox(void); +void set_override_skybox(s8 background); +u8 get_skybox_color(u8 index); +void set_skybox_color(u8 index, u8 value); + +#endif diff --git a/src/pc/lua/utils/smlua_misc_utils.c b/src/pc/lua/utils/smlua_misc_utils.c index fa5326b3..baa0c9bc 100644 --- a/src/pc/lua/utils/smlua_misc_utils.c +++ b/src/pc/lua/utils/smlua_misc_utils.c @@ -253,160 +253,6 @@ void hud_set_flash(s8 value) { /// -static struct CameraOverride sOverrideCameraXSens = { 0 }; -static struct CameraOverride sOverrideCameraYSens = { 0 }; -static struct CameraOverride sOverrideCameraAggr = { 0 }; -static struct CameraOverride sOverrideCameraPan = { 0 }; -static struct CameraOverride sOverrideCameraDegrade = { 0 }; -static struct CameraOverride sOverrideCameraInvertX = { 0 }; -static struct CameraOverride sOverrideCameraInvertY = { 0 }; -struct CameraOverride gOverrideEnableCamera = { 0 }; -static struct CameraOverride sOverrideCameraAnalog = { 0 }; -static struct CameraOverride sOverrideCameraMouse = { 0 }; - -void camera_reset_overrides(void) { - sOverrideCameraXSens.override = false; - sOverrideCameraYSens.override = false; - sOverrideCameraAggr.override = false; - sOverrideCameraPan.override = false; - sOverrideCameraDegrade.override = false; - sOverrideCameraInvertX.override = false; - sOverrideCameraInvertY.override = false; - gOverrideEnableCamera.override = false; - sOverrideCameraAnalog.override = false; - sOverrideCameraMouse.override = false; -} - -void camera_freeze(void) { - gOverrideFreezeCamera = TRUE; -} - -void camera_unfreeze(void) { - gOverrideFreezeCamera = FALSE; -} - -bool camera_is_frozen(void) { - return gOverrideFreezeCamera; -} - -void camera_set_romhack_override(enum RomhackCameraOverride rco) { - gOverrideRomhackCamera = rco; -} - -void camera_romhack_allow_centering(u8 allow) { - gRomhackCameraAllowCentering = allow; -} - -void camera_allow_toxic_gas_camera(u8 allow) { - gOverrideAllowToxicGasCamera = allow; -} - -void camera_romhack_allow_dpad_usage(u8 allow) { - gRomhackCameraAllowDpad = allow; -} - -bool camera_config_is_free_cam_enabled(void) { - return gOverrideEnableCamera.override ? gOverrideEnableCamera.value : configEnableCamera; -} - -bool camera_config_is_analog_cam_enabled(void) { - return sOverrideCameraAnalog.override ? sOverrideCameraAnalog.value : configCameraAnalog; -} - -bool camera_config_is_mouse_look_enabled(void) { - return sOverrideCameraMouse.override ? sOverrideCameraMouse.value : configCameraMouse; -} - -bool camera_config_is_x_inverted(void) { - return sOverrideCameraInvertX.override ? sOverrideCameraInvertX.value : configCameraInvertX; -} - -bool camera_config_is_y_inverted(void) { - return sOverrideCameraInvertY.override ? sOverrideCameraInvertY.value : configCameraInvertY; -} - -u32 camera_config_get_x_sensitivity(void) { - return sOverrideCameraXSens.override ? sOverrideCameraXSens.value : configCameraXSens; -} - -u32 camera_config_get_y_sensitivity(void) { - return sOverrideCameraYSens.override ? sOverrideCameraYSens.value : configCameraYSens; -} - -u32 camera_config_get_aggression(void) { - return sOverrideCameraAggr.override ? sOverrideCameraAggr.value : configCameraAggr; -} - -u32 camera_config_get_pan_level(void) { - return sOverrideCameraPan.override ? sOverrideCameraPan.value : configCameraPan; -} - -u32 camera_config_get_deceleration(void) { - return sOverrideCameraDegrade.override ? sOverrideCameraDegrade.value : configCameraDegrade; -} - -void camera_config_enable_free_cam(bool enable) { - gOverrideEnableCamera.value = enable; - gOverrideEnableCamera.override = true; - newcam_init_settings(); -} - -void camera_config_enable_analog_cam(bool enable) { - sOverrideCameraAnalog.value = enable; - sOverrideCameraAnalog.override = true; - newcam_init_settings(); -} - -void camera_config_enable_mouse_look(bool enable) { - sOverrideCameraMouse.value = enable; - sOverrideCameraMouse.override = true; - newcam_init_settings(); -} - -void camera_config_invert_x(bool invert) { - sOverrideCameraInvertX.value = invert; - sOverrideCameraInvertX.override = true; - newcam_init_settings(); -} - -void camera_config_invert_y(bool invert) { - sOverrideCameraInvertY.value = invert; - sOverrideCameraInvertY.override = true; - newcam_init_settings(); -} - -void camera_config_set_x_sensitivity(u32 value) { - sOverrideCameraXSens.value = MIN(MAX(value, 1), 100); - sOverrideCameraXSens.override = true; - newcam_init_settings(); -} - -void camera_config_set_y_sensitivity(u32 value) { - sOverrideCameraYSens.value = MIN(MAX(value, 1), 100); - sOverrideCameraYSens.override = true; - newcam_init_settings(); -} - -void camera_config_set_aggression(u32 value) { - sOverrideCameraAggr.value = MIN(MAX(value, 0), 100); - sOverrideCameraAggr.override = true; - newcam_init_settings(); -} - -void camera_config_set_pan_level(u32 value) { - sOverrideCameraPan.value = MIN(MAX(value, 0), 100); - sOverrideCameraPan.override = true; - newcam_init_settings(); -} - -void camera_config_set_deceleration(u32 value) { - sOverrideCameraDegrade.value = MIN(MAX(value, 0), 100); - sOverrideCameraDegrade.override = true; - newcam_init_settings(); -} - -/// - extern s16 gMenuMode; bool is_game_paused(void) { return gMenuMode != -1; @@ -499,88 +345,6 @@ void set_water_level(u8 index, s16 height, bool sync) { /// -void set_override_fov(f32 fov) { - gOverrideFOV = fov; -} - -/// - -void set_override_near(f32 nearClip) { - gOverrideNear = nearClip; -} - -/// - -void set_override_far(f32 farClip) { - gOverrideFar = farClip; -} - -/// - -f32 get_lighting_dir(u8 index) { - if (index > 2) { return 0; } - return gLightingDir[index]; -} - -void set_lighting_dir(u8 index, f32 value) { - if (index > 2) { return; } - gLightingDir[index] = value; -} - -u8 get_lighting_color(u8 index) { - if (index > 2) { return 0; } - return gLightingColor[index]; -} - -void set_lighting_color(u8 index, u8 value) { - if (index > 2) { return; } - gLightingColor[index] = value; -} - -/// - -u8 get_vertex_color(u8 index) { - if (index > 2) { return 0; } - return gVertexColor[index]; -} - -void set_vertex_color(u8 index, u8 value) { - if (index > 2) { return; } - gVertexColor[index] = value; -} - -/// - -u8 get_fog_color(u8 index) { - if (index > 2) { return 0; } - return gFogColor[index]; -} - -void set_fog_color(u8 index, u8 value) { - if (index > 2) { return; } - gFogColor[index] = value; -} - -f32 get_fog_intensity(void) { - return gFogIntensity; -} - -void set_fog_intensity(f32 intensity) { - gFogIntensity = intensity; -} - -/// - -s8 get_skybox(void) { - return gReadOnlyBackground; -} - -void set_override_skybox(s8 background) { - gOverrideBackground = background; -} - -/// - bool course_is_main_course(u16 courseNum) { return COURSE_IS_MAIN_COURSE(courseNum); } diff --git a/src/pc/lua/utils/smlua_misc_utils.h b/src/pc/lua/utils/smlua_misc_utils.h index c490e9bf..be826a2e 100644 --- a/src/pc/lua/utils/smlua_misc_utils.h +++ b/src/pc/lua/utils/smlua_misc_utils.h @@ -38,12 +38,7 @@ struct DateTime { s32 second; }; -struct CameraOverride { - unsigned int value; - bool override; -}; -extern struct CameraOverride gOverrideEnableCamera; u32 get_network_area_timer(void); @@ -79,37 +74,6 @@ void hud_render_power_meter_interpolated(s32 health, f32 prevX, f32 prevY, f32 p s8 hud_get_flash(void); void hud_set_flash(s8 value); -void camera_reset_overrides(void); -void camera_freeze(void); -void camera_unfreeze(void); -bool camera_is_frozen(void); -void camera_set_romhack_override(enum RomhackCameraOverride rco); -void camera_romhack_allow_centering(u8 allow); -void camera_allow_toxic_gas_camera(u8 allow); -void camera_romhack_allow_dpad_usage(u8 allow); - -bool camera_config_is_free_cam_enabled(void); -bool camera_config_is_analog_cam_enabled(void); -bool camera_config_is_mouse_look_enabled(void); -bool camera_config_is_x_inverted(void); -bool camera_config_is_y_inverted(void); -u32 camera_config_get_x_sensitivity(void); -u32 camera_config_get_y_sensitivity(void); -u32 camera_config_get_aggression(void); -u32 camera_config_get_pan_level(void); -u32 camera_config_get_deceleration(void); - -void camera_config_enable_free_cam(bool enable); -void camera_config_enable_analog_cam(bool enable); -void camera_config_enable_mouse_look(bool enable); -void camera_config_invert_x(bool invert); -void camera_config_invert_y(bool invert); -void camera_config_set_x_sensitivity(u32 value); -void camera_config_set_y_sensitivity(u32 value); -void camera_config_set_aggression(u32 value); -void camera_config_set_pan_level(u32 value); -void camera_config_set_deceleration(u32 value); - bool is_game_paused(void); bool is_transition_playing(void); @@ -127,27 +91,6 @@ void movtexqc_register(const char* name, s16 level, s16 area, s16 type); s16 get_water_level(u8 index); void set_water_level(u8 index, s16 height, bool sync); -void set_override_fov(f32 fov); -void set_override_near(f32 near); -void set_override_far(f32 far); - -f32 get_lighting_dir(u8 index); -void set_lighting_dir(u8 index, f32 value); - -u8 get_lighting_color(u8 index); -void set_lighting_color(u8 index, u8 value); - -u8 get_vertex_color(u8 index); -void set_vertex_color(u8 index, u8 value); - -u8 get_fog_color(u8 index); -void set_fog_color(u8 index, u8 value); -f32 get_fog_intensity(void); -void set_fog_intensity(f32 intensity); - -s8 get_skybox(void); -void set_override_skybox(s8 background); - void play_transition(s16 transType, s16 time, u8 red, u8 green, u8 blue); bool course_is_main_course(u16 courseNum); diff --git a/src/pc/mods/mod.h b/src/pc/mods/mod.h index 0503f1ca..3340cd5c 100644 --- a/src/pc/mods/mod.h +++ b/src/pc/mods/mod.h @@ -2,7 +2,7 @@ #define MOD_H #include -#include +#include "types.h" #include "pc/platform.h" #define MOD_NAME_MAX_LENGTH 64 diff --git a/src/pc/mods/mod_import.c b/src/pc/mods/mod_import.c index 47a254b4..116893da 100644 --- a/src/pc/mods/mod_import.c +++ b/src/pc/mods/mod_import.c @@ -1,5 +1,5 @@ #include "PR/ultratypes.h" -#include +#include "types.h" #include "pc/platform.h" #include "pc/utils/miniz/miniz.h" #include "pc/debuglog.h" diff --git a/src/pc/mods/mods.h b/src/pc/mods/mods.h index 0f08cdcc..4f4a7de4 100644 --- a/src/pc/mods/mods.h +++ b/src/pc/mods/mods.h @@ -2,7 +2,7 @@ #define MODS_H #include -#include +#include "types.h" #include "pc/platform.h" #include "mod.h" diff --git a/src/pc/mods/mods_utils.h b/src/pc/mods/mods_utils.h index 1e97218b..062e77a6 100644 --- a/src/pc/mods/mods_utils.h +++ b/src/pc/mods/mods_utils.h @@ -2,7 +2,7 @@ #define MODS_UTILS_H #include -#include +#include "types.h" #include "pc/platform.h" void mods_size_enforce(struct Mods* mods); diff --git a/src/pc/network/network.c b/src/pc/network/network.c index 860fc1e0..46848e10 100644 --- a/src/pc/network/network.c +++ b/src/pc/network/network.c @@ -17,6 +17,7 @@ #include "pc/lua/smlua.h" #include "pc/lua/utils/smlua_model_utils.h" #include "pc/lua/utils/smlua_misc_utils.h" +#include "pc/lua/utils/smlua_camera_utils.h" #include "pc/mods/mods.h" #include "pc/crash_handler.h" #include "pc/debuglog.h" diff --git a/src/pc/network/network.h b/src/pc/network/network.h index f929d258..f4595060 100644 --- a/src/pc/network/network.h +++ b/src/pc/network/network.h @@ -3,7 +3,7 @@ #include #include -#include +#include "types.h" #include #include "network_player.h" #include "network_utils.h" diff --git a/src/pc/network/packets/packet.h b/src/pc/network/packets/packet.h index 3a607b3f..9ad19698 100644 --- a/src/pc/network/packets/packet.h +++ b/src/pc/network/packets/packet.h @@ -3,7 +3,7 @@ #include #include -#include +#include "types.h" #include #include