diff --git a/autogen/convert_functions.py b/autogen/convert_functions.py index 1f4486e1..8f90c70b 100644 --- a/autogen/convert_functions.py +++ b/autogen/convert_functions.py @@ -47,6 +47,7 @@ in_files = [ "src/pc/lua/utils/smlua_text_utils.h", "src/pc/lua/utils/smlua_audio_utils.h", "src/pc/lua/utils/smlua_level_utils.h", + "src/pc/lua/utils/smlua_anim_utils.h", "src/pc/lua/utils/smlua_deprecated.h", "src/game/object_helpers.c", "src/game/obj_behaviors.c", @@ -104,6 +105,7 @@ override_disallowed_functions = { "src/pc/lua/utils/smlua_audio_utils.h": [ "smlua_audio_utils_override", "audio_custom_shutdown"], "src/pc/djui/djui_hud_utils.h": [ "djui_hud_render_texture", "djui_hud_render_texture_raw", "djui_hud_render_texture_tile", "djui_hud_render_texture_tile_raw" ], "src/pc/lua/utils/smlua_level_utils.h": [ "smlua_level_util_reset" ], + "src/pc/lua/utils/smlua_anim_utils.h": [ "smlua_anim_util_reset", "smlua_anim_util_register_animation" ], "src/pc/network/lag_compensation.h": [ "lag_compensation_clear", "lag_compensation_store" ], } diff --git a/autogen/lua_definitions/functions.lua b/autogen/lua_definitions/functions.lua index bd3261e6..9fbcbfdc 100644 --- a/autogen/lua_definitions/functions.lua +++ b/autogen/lua_definitions/functions.lua @@ -7868,6 +7868,19 @@ function save_file_set_star_flags(fileIndex, courseIndex, starFlags) -- ... end +--- @param obj Object +--- @return string +function smlua_anim_util_get_current_animation_name(obj) + -- ... +end + +--- @param obj Object +--- @param name string +--- @return nil +function smlua_anim_util_set_animation(obj, name) + -- ... +end + --- @param audio BassAudio --- @return nil function audio_sample_destroy(audio) diff --git a/autogen/lua_definitions/manual.lua b/autogen/lua_definitions/manual.lua index 568a0cb7..309c3fe3 100644 --- a/autogen/lua_definitions/manual.lua +++ b/autogen/lua_definitions/manual.lua @@ -222,6 +222,19 @@ function djui_hud_render_texture_tile_interpolated(texInfo, prevX, prevY, prevSc -- ... end +--- @param name string +--- @param flags integer +--- @param animYTransDivisor integer +--- @param startFrame integer +--- @param loopStart integer +--- @param loopEnd integer +--- @param values table +--- @param index table +--- @return nil +function smlua_anim_util_register_animation(name, flags, animYTransDivisor, startFrame, loopStart, loopEnd, values, index) + -- ... +end + --- @param levelNum number --- @param func fun(areaIndex:number, bhvData:table, macroBhvIds:table, macroBhvArgs:table) --- @return nil diff --git a/data/dynos_mgr_anim.cpp b/data/dynos_mgr_anim.cpp index 19b42f46..983c88e0 100644 --- a/data/dynos_mgr_anim.cpp +++ b/data/dynos_mgr_anim.cpp @@ -4,6 +4,7 @@ extern "C" { #include "game/level_update.h" #include "game/object_list_processor.h" #include "pc/configfile.h" +#include "pc/lua/utils/smlua_anim_utils.h" } // @@ -25,7 +26,7 @@ static s32 RetrieveCurrentMarioAnimationIndex(u32 aPlayerIndex) { // Retrieve the current animation index // As we don't know the length of the table, let's hope that we'll always find the animation... static s32 RetrieveCurrentAnimationIndex(struct Object *aObject) { - if (!aObject->oAnimations || !aObject->header.gfx.animInfo.curAnim) { + if (!aObject->oAnimations || !aObject->header.gfx.animInfo.curAnim || smlua_anim_util_get_current_animation_name(aObject)) { return -1; } for (s32 i = 0; aObject->oAnimations[i] != NULL; ++i) { diff --git a/docs/lua/functions-4.md b/docs/lua/functions-4.md index 89c0b44f..4be078f6 100644 --- a/docs/lua/functions-4.md +++ b/docs/lua/functions-4.md @@ -6725,6 +6725,53 @@
+--- +# functions from smlua_anim_utils.h + +
+ + +## [smlua_anim_util_get_current_animation_name](#smlua_anim_util_get_current_animation_name) + +### Lua Example +`local stringValue = smlua_anim_util_get_current_animation_name(obj)` + +### Parameters +| Field | Type | +| ----- | ---- | +| obj | [Object](structs.md#Object) | + +### Returns +- `string` + +### C Prototype +`const char *smlua_anim_util_get_current_animation_name(struct Object *obj);` + +[:arrow_up_small:](#) + +
+ +## [smlua_anim_util_set_animation](#smlua_anim_util_set_animation) + +### Lua Example +`smlua_anim_util_set_animation(obj, name)` + +### Parameters +| Field | Type | +| ----- | ---- | +| obj | [Object](structs.md#Object) | +| name | `string` | + +### Returns +- None + +### C Prototype +`void smlua_anim_util_set_animation(struct Object *obj, const char *name);` + +[:arrow_up_small:](#) + +
+ --- # functions from smlua_audio_utils.h @@ -7665,1290 +7712,6 @@ [:arrow_up_small:](#) -
- ---- -# functions from smlua_misc_utils.h - -
- - -## [add_scroll_target](#add_scroll_target) - -### Lua Example -`add_scroll_target(index, name, offset, size)` - -### Parameters -| Field | Type | -| ----- | ---- | -| index | `integer` | -| name | `string` | -| offset | `integer` | -| size | `integer` | - -### Returns -- None - -### C Prototype -`void add_scroll_target(u32 index, const char* name, u32 offset, u32 size);` - -[:arrow_up_small:](#) - -
- -## [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_config_enable_analog_cam](#camera_config_enable_analog_cam) - -### Lua Example -`camera_config_enable_analog_cam(enable)` - -### Parameters -| Field | Type | -| ----- | ---- | -| enable | `boolean` | - -### Returns -- None - -### C Prototype -`void camera_config_enable_analog_cam(bool enable);` - -[:arrow_up_small:](#) - -
- -## [camera_config_enable_free_cam](#camera_config_enable_free_cam) - -### Lua Example -`camera_config_enable_free_cam(enable)` - -### Parameters -| Field | Type | -| ----- | ---- | -| enable | `boolean` | - -### Returns -- None - -### C Prototype -`void camera_config_enable_free_cam(bool enable);` - -[:arrow_up_small:](#) - -
- -## [camera_config_enable_mouse_look](#camera_config_enable_mouse_look) - -### Lua Example -`camera_config_enable_mouse_look(enable)` - -### Parameters -| Field | Type | -| ----- | ---- | -| enable | `boolean` | - -### Returns -- None - -### C Prototype -`void camera_config_enable_mouse_look(bool enable);` - -[:arrow_up_small:](#) - -
- -## [camera_config_get_aggression](#camera_config_get_aggression) - -### Lua Example -`local integerValue = camera_config_get_aggression()` - -### Parameters -- None - -### Returns -- `integer` - -### C Prototype -`u32 camera_config_get_aggression(void);` - -[:arrow_up_small:](#) - -
- -## [camera_config_get_deceleration](#camera_config_get_deceleration) - -### Lua Example -`local integerValue = camera_config_get_deceleration()` - -### Parameters -- None - -### Returns -- `integer` - -### C Prototype -`u32 camera_config_get_deceleration(void);` - -[:arrow_up_small:](#) - -
- -## [camera_config_get_pan_level](#camera_config_get_pan_level) - -### Lua Example -`local integerValue = camera_config_get_pan_level()` - -### Parameters -- None - -### Returns -- `integer` - -### C Prototype -`u32 camera_config_get_pan_level(void);` - -[:arrow_up_small:](#) - -
- -## [camera_config_get_x_sensitivity](#camera_config_get_x_sensitivity) - -### Lua Example -`local integerValue = camera_config_get_x_sensitivity()` - -### Parameters -- None - -### Returns -- `integer` - -### C Prototype -`u32 camera_config_get_x_sensitivity(void);` - -[:arrow_up_small:](#) - -
- -## [camera_config_get_y_sensitivity](#camera_config_get_y_sensitivity) - -### Lua Example -`local integerValue = camera_config_get_y_sensitivity()` - -### Parameters -- None - -### Returns -- `integer` - -### C Prototype -`u32 camera_config_get_y_sensitivity(void);` - -[:arrow_up_small:](#) - -
- -## [camera_config_invert_x](#camera_config_invert_x) - -### Lua Example -`camera_config_invert_x(invert)` - -### Parameters -| Field | Type | -| ----- | ---- | -| invert | `boolean` | - -### Returns -- None - -### C Prototype -`void camera_config_invert_x(bool invert);` - -[:arrow_up_small:](#) - -
- -## [camera_config_invert_y](#camera_config_invert_y) - -### Lua Example -`camera_config_invert_y(invert)` - -### Parameters -| Field | Type | -| ----- | ---- | -| invert | `boolean` | - -### Returns -- None - -### C Prototype -`void camera_config_invert_y(bool invert);` - -[:arrow_up_small:](#) - -
- -## [camera_config_is_analog_cam_enabled](#camera_config_is_analog_cam_enabled) - -### Lua Example -`local booleanValue = camera_config_is_analog_cam_enabled()` - -### Parameters -- None - -### Returns -- `boolean` - -### C Prototype -`bool camera_config_is_analog_cam_enabled(void);` - -[:arrow_up_small:](#) - -
- -## [camera_config_is_free_cam_enabled](#camera_config_is_free_cam_enabled) - -### Lua Example -`local booleanValue = camera_config_is_free_cam_enabled()` - -### Parameters -- None - -### Returns -- `boolean` - -### C Prototype -`bool camera_config_is_free_cam_enabled(void);` - -[:arrow_up_small:](#) - -
- -## [camera_config_is_mouse_look_enabled](#camera_config_is_mouse_look_enabled) - -### Lua Example -`local booleanValue = camera_config_is_mouse_look_enabled()` - -### Parameters -- None - -### Returns -- `boolean` - -### C Prototype -`bool camera_config_is_mouse_look_enabled(void);` - -[:arrow_up_small:](#) - -
- -## [camera_config_is_x_inverted](#camera_config_is_x_inverted) - -### Lua Example -`local booleanValue = camera_config_is_x_inverted()` - -### Parameters -- None - -### Returns -- `boolean` - -### C Prototype -`bool camera_config_is_x_inverted(void);` - -[:arrow_up_small:](#) - -
- -## [camera_config_is_y_inverted](#camera_config_is_y_inverted) - -### Lua Example -`local booleanValue = camera_config_is_y_inverted()` - -### Parameters -- None - -### Returns -- `boolean` - -### C Prototype -`bool camera_config_is_y_inverted(void);` - -[:arrow_up_small:](#) - -
- -## [camera_config_set_aggression](#camera_config_set_aggression) - -### Lua Example -`camera_config_set_aggression(value)` - -### Parameters -| Field | Type | -| ----- | ---- | -| value | `integer` | - -### Returns -- None - -### C Prototype -`void camera_config_set_aggression(u32 value);` - -[:arrow_up_small:](#) - -
- -## [camera_config_set_deceleration](#camera_config_set_deceleration) - -### Lua Example -`camera_config_set_deceleration(value)` - -### Parameters -| Field | Type | -| ----- | ---- | -| value | `integer` | - -### Returns -- None - -### C Prototype -`void camera_config_set_deceleration(u32 value);` - -[:arrow_up_small:](#) - -
- -## [camera_config_set_pan_level](#camera_config_set_pan_level) - -### Lua Example -`camera_config_set_pan_level(value)` - -### Parameters -| Field | Type | -| ----- | ---- | -| value | `integer` | - -### Returns -- None - -### C Prototype -`void camera_config_set_pan_level(u32 value);` - -[:arrow_up_small:](#) - -
- -## [camera_config_set_x_sensitivity](#camera_config_set_x_sensitivity) - -### Lua Example -`camera_config_set_x_sensitivity(value)` - -### Parameters -| Field | Type | -| ----- | ---- | -| value | `integer` | - -### Returns -- None - -### C Prototype -`void camera_config_set_x_sensitivity(u32 value);` - -[:arrow_up_small:](#) - -
- -## [camera_config_set_y_sensitivity](#camera_config_set_y_sensitivity) - -### Lua Example -`camera_config_set_y_sensitivity(value)` - -### Parameters -| Field | Type | -| ----- | ---- | -| value | `integer` | - -### Returns -- None - -### C Prototype -`void camera_config_set_y_sensitivity(u32 value);` - -[:arrow_up_small:](#) - -
- -## [camera_freeze](#camera_freeze) - -### Lua Example -`camera_freeze()` - -### Parameters -- None - -### Returns -- None - -### C Prototype -`void camera_freeze(void);` - -[:arrow_up_small:](#) - -
- -## [camera_is_frozen](#camera_is_frozen) - -### Lua Example -`local booleanValue = camera_is_frozen()` - -### Parameters -- None - -### Returns -- `boolean` - -### C Prototype -`bool camera_is_frozen(void);` - -[:arrow_up_small:](#) - -
- -## [camera_unfreeze](#camera_unfreeze) - -### Lua Example -`camera_unfreeze()` - -### Parameters -- None - -### Returns -- None - -### C Prototype -`void camera_unfreeze(void);` - -[:arrow_up_small:](#) - -
- -## [course_is_main_course](#course_is_main_course) - -### Lua Example -`local booleanValue = course_is_main_course(courseNum)` - -### Parameters -| Field | Type | -| ----- | ---- | -| courseNum | `integer` | - -### Returns -- `boolean` - -### C Prototype -`bool course_is_main_course(u16 courseNum);` - -[:arrow_up_small:](#) - -
- -## [deref_s32_pointer](#deref_s32_pointer) - -### Lua Example -`local integerValue = deref_s32_pointer(pointer)` - -### Parameters -| Field | Type | -| ----- | ---- | -| pointer | `Pointer` <`integer`> | - -### Returns -- `integer` - -### C Prototype -`s32 deref_s32_pointer(s32* pointer);` - -[:arrow_up_small:](#) - -
- -## [get_current_save_file_num](#get_current_save_file_num) - -### Lua Example -`local integerValue = get_current_save_file_num()` - -### Parameters -- None - -### Returns -- `integer` - -### C Prototype -`s16 get_current_save_file_num(void);` - -[:arrow_up_small:](#) - -
- -## [get_dialog_box_state](#get_dialog_box_state) - -### Lua Example -`local integerValue = get_dialog_box_state()` - -### Parameters -- None - -### Returns -- `integer` - -### C Prototype -`s8 get_dialog_box_state();` - -[:arrow_up_small:](#) - -
- -## [get_dialog_id](#get_dialog_id) - -### Lua Example -`local integerValue = get_dialog_id()` - -### Parameters -- None - -### Returns -- `integer` - -### C Prototype -`s16 get_dialog_id(void);` - -[:arrow_up_small:](#) - -
- -## [get_envfx](#get_envfx) - -### Lua Example -`local integerValue = get_envfx()` - -### Parameters -- None - -### Returns -- `integer` - -### C Prototype -`u16 get_envfx(void);` - -[:arrow_up_small:](#) - -
- -## [get_environment_region](#get_environment_region) - -### Lua Example -`local numberValue = get_environment_region(index)` - -### Parameters -| Field | Type | -| ----- | ---- | -| index | `integer` | - -### Returns -- `number` - -### C Prototype -`f32 get_environment_region(u8 index);` - -[:arrow_up_small:](#) - -
- -## [get_hand_foot_pos_x](#get_hand_foot_pos_x) - -### Lua Example -`local numberValue = get_hand_foot_pos_x(m, index)` - -### Parameters -| Field | Type | -| ----- | ---- | -| m | [MarioState](structs.md#MarioState) | -| index | `integer` | - -### Returns -- `number` - -### C Prototype -`f32 get_hand_foot_pos_x(struct MarioState* m, u8 index);` - -[:arrow_up_small:](#) - -
- -## [get_hand_foot_pos_y](#get_hand_foot_pos_y) - -### Lua Example -`local numberValue = get_hand_foot_pos_y(m, index)` - -### Parameters -| Field | Type | -| ----- | ---- | -| m | [MarioState](structs.md#MarioState) | -| index | `integer` | - -### Returns -- `number` - -### C Prototype -`f32 get_hand_foot_pos_y(struct MarioState* m, u8 index);` - -[:arrow_up_small:](#) - -
- -## [get_hand_foot_pos_z](#get_hand_foot_pos_z) - -### Lua Example -`local numberValue = get_hand_foot_pos_z(m, index)` - -### Parameters -| Field | Type | -| ----- | ---- | -| m | [MarioState](structs.md#MarioState) | -| index | `integer` | - -### Returns -- `number` - -### C Prototype -`f32 get_hand_foot_pos_z(struct MarioState* m, u8 index);` - -[:arrow_up_small:](#) - -
- -## [get_last_star_or_key](#get_last_star_or_key) - -### Lua Example -`local integerValue = get_last_star_or_key()` - -### Parameters -- None - -### Returns -- `integer` - -### C Prototype -`s32 get_last_star_or_key(void);` - -[: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_network_area_timer](#get_network_area_timer) - -### Lua Example -`local integerValue = get_network_area_timer()` - -### Parameters -- None - -### Returns -- `integer` - -### C Prototype -`u32 get_network_area_timer(void);` - -[:arrow_up_small:](#) - -
- -## [get_os_name](#get_os_name) - -### Lua Example -`local stringValue = get_os_name()` - -### Parameters -- None - -### Returns -- `string` - -### C Prototype -`char* get_os_name(void);` - -[:arrow_up_small:](#) - -
- -## [get_skybox](#get_skybox) - -### Lua Example -`local integerValue = get_skybox()` - -### Parameters -- None - -### Returns -- `integer` - -### C Prototype -`s8 get_skybox();` - -[:arrow_up_small:](#) - -
- -## [get_temp_s32_pointer](#get_temp_s32_pointer) - -### Lua Example -`local PointerValue = get_temp_s32_pointer(initialValue)` - -### Parameters -| Field | Type | -| ----- | ---- | -| initialValue | `integer` | - -### Returns -- `Pointer` <`integer`> - -### C Prototype -`s32* get_temp_s32_pointer(s32 initialValue);` - -[:arrow_up_small:](#) - -
- -## [get_time](#get_time) - -### Lua Example -`local integerValue = get_time()` - -### Parameters -- None - -### Returns -- `integer` - -### C Prototype -`u32 get_time(void);` - -[:arrow_up_small:](#) - -
- -## [get_ttc_speed_setting](#get_ttc_speed_setting) - -### Lua Example -`local integerValue = get_ttc_speed_setting()` - -### Parameters -- None - -### Returns -- `integer` - -### C Prototype -`s16 get_ttc_speed_setting();` - -[:arrow_up_small:](#) - -
- -## [hud_get_value](#hud_get_value) - -### Lua Example -`local integerValue = hud_get_value(type)` - -### Parameters -| Field | Type | -| ----- | ---- | -| type | [enum HudDisplayValue](constants.md#enum-HudDisplayValue) | - -### Returns -- `integer` - -### C Prototype -`s32 hud_get_value(enum HudDisplayValue type);` - -[:arrow_up_small:](#) - -
- -## [hud_hide](#hud_hide) - -### Lua Example -`hud_hide()` - -### Parameters -- None - -### Returns -- None - -### C Prototype -`void hud_hide(void);` - -[:arrow_up_small:](#) - -
- -## [hud_is_hidden](#hud_is_hidden) - -### Lua Example -`local booleanValue = hud_is_hidden()` - -### Parameters -- None - -### Returns -- `boolean` - -### C Prototype -`bool hud_is_hidden(void);` - -[:arrow_up_small:](#) - -
- -## [hud_render_power_meter](#hud_render_power_meter) - -### Lua Example -`hud_render_power_meter(health, x, y, width, height)` - -### Parameters -| Field | Type | -| ----- | ---- | -| health | `integer` | -| x | `number` | -| y | `number` | -| width | `number` | -| height | `number` | - -### Returns -- None - -### C Prototype -`void hud_render_power_meter(s32 health, f32 x, f32 y, f32 width, f32 height);` - -[:arrow_up_small:](#) - -
- -## [hud_render_power_meter_interpolated](#hud_render_power_meter_interpolated) - -### Lua Example -`hud_render_power_meter_interpolated(health, prevX, prevY, prevWidth, prevHeight, x, y, width, height)` - -### Parameters -| Field | Type | -| ----- | ---- | -| health | `integer` | -| prevX | `number` | -| prevY | `number` | -| prevWidth | `number` | -| prevHeight | `number` | -| x | `number` | -| y | `number` | -| width | `number` | -| height | `number` | - -### Returns -- None - -### C Prototype -`void hud_render_power_meter_interpolated(s32 health, f32 prevX, f32 prevY, f32 prevWidth, f32 prevHeight, f32 x, f32 y, f32 width, f32 height);` - -[:arrow_up_small:](#) - -
- -## [hud_set_value](#hud_set_value) - -### Lua Example -`hud_set_value(type, value)` - -### Parameters -| Field | Type | -| ----- | ---- | -| type | [enum HudDisplayValue](constants.md#enum-HudDisplayValue) | -| value | `integer` | - -### Returns -- None - -### C Prototype -`void hud_set_value(enum HudDisplayValue type, s32 value);` - -[:arrow_up_small:](#) - -
- -## [hud_show](#hud_show) - -### Lua Example -`hud_show()` - -### Parameters -- None - -### Returns -- None - -### C Prototype -`void hud_show(void);` - -[:arrow_up_small:](#) - -
- -## [is_game_paused](#is_game_paused) - -### Lua Example -`local booleanValue = is_game_paused()` - -### Parameters -- None - -### Returns -- `boolean` - -### C Prototype -`bool is_game_paused(void);` - -[:arrow_up_small:](#) - -
- -## [is_transition_playing](#is_transition_playing) - -### Lua Example -`local booleanValue = is_transition_playing()` - -### Parameters -- None - -### Returns -- `boolean` - -### C Prototype -`bool is_transition_playing(void);` - -[:arrow_up_small:](#) - -
- -## [movtexqc_register](#movtexqc_register) - -### Lua Example -`movtexqc_register(name, level, area, type)` - -### Parameters -| Field | Type | -| ----- | ---- | -| name | `string` | -| level | `integer` | -| area | `integer` | -| type | `integer` | - -### Returns -- None - -### C Prototype -`void movtexqc_register(const char* name, s16 level, s16 area, s16 type);` - -[:arrow_up_small:](#) - -
- -## [play_transition](#play_transition) - -### Lua Example -`play_transition(transType, time, red, green, blue)` - -### Parameters -| Field | Type | -| ----- | ---- | -| transType | `integer` | -| time | `integer` | -| red | `integer` | -| green | `integer` | -| blue | `integer` | - -### Returns -- None - -### C Prototype -`void play_transition(s16 transType, s16 time, u8 red, u8 green, u8 blue);` - -[:arrow_up_small:](#) - -
- -## [save_file_set_using_backup_slot](#save_file_set_using_backup_slot) - -### Lua Example -`save_file_set_using_backup_slot(usingBackupSlot)` - -### Parameters -| Field | Type | -| ----- | ---- | -| usingBackupSlot | `boolean` | - -### Returns -- None - -### C Prototype -`void save_file_set_using_backup_slot(bool usingBackupSlot);` - -[:arrow_up_small:](#) - -
- -## [set_environment_region](#set_environment_region) - -### Lua Example -`set_environment_region(index, value)` - -### Parameters -| Field | Type | -| ----- | ---- | -| index | `integer` | -| value | `integer` | - -### Returns -- None - -### C Prototype -`void set_environment_region(u8 index, s32 value);` - -[:arrow_up_small:](#) - -
- -## [set_last_star_or_key](#set_last_star_or_key) - -### Lua Example -`set_last_star_or_key(value)` - -### Parameters -| Field | Type | -| ----- | ---- | -| value | `integer` | - -### Returns -- None - -### C Prototype -`void set_last_star_or_key(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 -`set_override_envfx(envfx)` - -### Parameters -| Field | Type | -| ----- | ---- | -| envfx | `integer` | - -### Returns -- None - -### C Prototype -`void set_override_envfx(s32 envfx);` - -[: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_ttc_speed_setting](#set_ttc_speed_setting) - -### Lua Example -`set_ttc_speed_setting(speed)` - -### Parameters -| Field | Type | -| ----- | ---- | -| speed | `integer` | - -### Returns -- None - -### C Prototype -`void set_ttc_speed_setting(s16 speed);` - -[:arrow_up_small:](#) - -
- ---- -# functions from smlua_model_utils.h - -
- - -## [smlua_model_util_get_id](#smlua_model_util_get_id) - -### Lua Example -`local integerValue = smlua_model_util_get_id(name)` - -### Parameters -| Field | Type | -| ----- | ---- | -| name | `string` | - -### Returns -- `integer` - -### C Prototype -`u32 smlua_model_util_get_id(const char* name);` - -[:arrow_up_small:](#) -
--- diff --git a/docs/lua/functions-5.md b/docs/lua/functions-5.md index 787b3de6..6910d378 100644 --- a/docs/lua/functions-5.md +++ b/docs/lua/functions-5.md @@ -5,6 +5,1290 @@ [< prev](functions-4.md) | [1](functions.md) | [2](functions-2.md) | [3](functions-3.md) | [4](functions-4.md) | 5] +--- +# functions from smlua_misc_utils.h + +
+ + +## [add_scroll_target](#add_scroll_target) + +### Lua Example +`add_scroll_target(index, name, offset, size)` + +### Parameters +| Field | Type | +| ----- | ---- | +| index | `integer` | +| name | `string` | +| offset | `integer` | +| size | `integer` | + +### Returns +- None + +### C Prototype +`void add_scroll_target(u32 index, const char* name, u32 offset, u32 size);` + +[:arrow_up_small:](#) + +
+ +## [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_config_enable_analog_cam](#camera_config_enable_analog_cam) + +### Lua Example +`camera_config_enable_analog_cam(enable)` + +### Parameters +| Field | Type | +| ----- | ---- | +| enable | `boolean` | + +### Returns +- None + +### C Prototype +`void camera_config_enable_analog_cam(bool enable);` + +[:arrow_up_small:](#) + +
+ +## [camera_config_enable_free_cam](#camera_config_enable_free_cam) + +### Lua Example +`camera_config_enable_free_cam(enable)` + +### Parameters +| Field | Type | +| ----- | ---- | +| enable | `boolean` | + +### Returns +- None + +### C Prototype +`void camera_config_enable_free_cam(bool enable);` + +[:arrow_up_small:](#) + +
+ +## [camera_config_enable_mouse_look](#camera_config_enable_mouse_look) + +### Lua Example +`camera_config_enable_mouse_look(enable)` + +### Parameters +| Field | Type | +| ----- | ---- | +| enable | `boolean` | + +### Returns +- None + +### C Prototype +`void camera_config_enable_mouse_look(bool enable);` + +[:arrow_up_small:](#) + +
+ +## [camera_config_get_aggression](#camera_config_get_aggression) + +### Lua Example +`local integerValue = camera_config_get_aggression()` + +### Parameters +- None + +### Returns +- `integer` + +### C Prototype +`u32 camera_config_get_aggression(void);` + +[:arrow_up_small:](#) + +
+ +## [camera_config_get_deceleration](#camera_config_get_deceleration) + +### Lua Example +`local integerValue = camera_config_get_deceleration()` + +### Parameters +- None + +### Returns +- `integer` + +### C Prototype +`u32 camera_config_get_deceleration(void);` + +[:arrow_up_small:](#) + +
+ +## [camera_config_get_pan_level](#camera_config_get_pan_level) + +### Lua Example +`local integerValue = camera_config_get_pan_level()` + +### Parameters +- None + +### Returns +- `integer` + +### C Prototype +`u32 camera_config_get_pan_level(void);` + +[:arrow_up_small:](#) + +
+ +## [camera_config_get_x_sensitivity](#camera_config_get_x_sensitivity) + +### Lua Example +`local integerValue = camera_config_get_x_sensitivity()` + +### Parameters +- None + +### Returns +- `integer` + +### C Prototype +`u32 camera_config_get_x_sensitivity(void);` + +[:arrow_up_small:](#) + +
+ +## [camera_config_get_y_sensitivity](#camera_config_get_y_sensitivity) + +### Lua Example +`local integerValue = camera_config_get_y_sensitivity()` + +### Parameters +- None + +### Returns +- `integer` + +### C Prototype +`u32 camera_config_get_y_sensitivity(void);` + +[:arrow_up_small:](#) + +
+ +## [camera_config_invert_x](#camera_config_invert_x) + +### Lua Example +`camera_config_invert_x(invert)` + +### Parameters +| Field | Type | +| ----- | ---- | +| invert | `boolean` | + +### Returns +- None + +### C Prototype +`void camera_config_invert_x(bool invert);` + +[:arrow_up_small:](#) + +
+ +## [camera_config_invert_y](#camera_config_invert_y) + +### Lua Example +`camera_config_invert_y(invert)` + +### Parameters +| Field | Type | +| ----- | ---- | +| invert | `boolean` | + +### Returns +- None + +### C Prototype +`void camera_config_invert_y(bool invert);` + +[:arrow_up_small:](#) + +
+ +## [camera_config_is_analog_cam_enabled](#camera_config_is_analog_cam_enabled) + +### Lua Example +`local booleanValue = camera_config_is_analog_cam_enabled()` + +### Parameters +- None + +### Returns +- `boolean` + +### C Prototype +`bool camera_config_is_analog_cam_enabled(void);` + +[:arrow_up_small:](#) + +
+ +## [camera_config_is_free_cam_enabled](#camera_config_is_free_cam_enabled) + +### Lua Example +`local booleanValue = camera_config_is_free_cam_enabled()` + +### Parameters +- None + +### Returns +- `boolean` + +### C Prototype +`bool camera_config_is_free_cam_enabled(void);` + +[:arrow_up_small:](#) + +
+ +## [camera_config_is_mouse_look_enabled](#camera_config_is_mouse_look_enabled) + +### Lua Example +`local booleanValue = camera_config_is_mouse_look_enabled()` + +### Parameters +- None + +### Returns +- `boolean` + +### C Prototype +`bool camera_config_is_mouse_look_enabled(void);` + +[:arrow_up_small:](#) + +
+ +## [camera_config_is_x_inverted](#camera_config_is_x_inverted) + +### Lua Example +`local booleanValue = camera_config_is_x_inverted()` + +### Parameters +- None + +### Returns +- `boolean` + +### C Prototype +`bool camera_config_is_x_inverted(void);` + +[:arrow_up_small:](#) + +
+ +## [camera_config_is_y_inverted](#camera_config_is_y_inverted) + +### Lua Example +`local booleanValue = camera_config_is_y_inverted()` + +### Parameters +- None + +### Returns +- `boolean` + +### C Prototype +`bool camera_config_is_y_inverted(void);` + +[:arrow_up_small:](#) + +
+ +## [camera_config_set_aggression](#camera_config_set_aggression) + +### Lua Example +`camera_config_set_aggression(value)` + +### Parameters +| Field | Type | +| ----- | ---- | +| value | `integer` | + +### Returns +- None + +### C Prototype +`void camera_config_set_aggression(u32 value);` + +[:arrow_up_small:](#) + +
+ +## [camera_config_set_deceleration](#camera_config_set_deceleration) + +### Lua Example +`camera_config_set_deceleration(value)` + +### Parameters +| Field | Type | +| ----- | ---- | +| value | `integer` | + +### Returns +- None + +### C Prototype +`void camera_config_set_deceleration(u32 value);` + +[:arrow_up_small:](#) + +
+ +## [camera_config_set_pan_level](#camera_config_set_pan_level) + +### Lua Example +`camera_config_set_pan_level(value)` + +### Parameters +| Field | Type | +| ----- | ---- | +| value | `integer` | + +### Returns +- None + +### C Prototype +`void camera_config_set_pan_level(u32 value);` + +[:arrow_up_small:](#) + +
+ +## [camera_config_set_x_sensitivity](#camera_config_set_x_sensitivity) + +### Lua Example +`camera_config_set_x_sensitivity(value)` + +### Parameters +| Field | Type | +| ----- | ---- | +| value | `integer` | + +### Returns +- None + +### C Prototype +`void camera_config_set_x_sensitivity(u32 value);` + +[:arrow_up_small:](#) + +
+ +## [camera_config_set_y_sensitivity](#camera_config_set_y_sensitivity) + +### Lua Example +`camera_config_set_y_sensitivity(value)` + +### Parameters +| Field | Type | +| ----- | ---- | +| value | `integer` | + +### Returns +- None + +### C Prototype +`void camera_config_set_y_sensitivity(u32 value);` + +[:arrow_up_small:](#) + +
+ +## [camera_freeze](#camera_freeze) + +### Lua Example +`camera_freeze()` + +### Parameters +- None + +### Returns +- None + +### C Prototype +`void camera_freeze(void);` + +[:arrow_up_small:](#) + +
+ +## [camera_is_frozen](#camera_is_frozen) + +### Lua Example +`local booleanValue = camera_is_frozen()` + +### Parameters +- None + +### Returns +- `boolean` + +### C Prototype +`bool camera_is_frozen(void);` + +[:arrow_up_small:](#) + +
+ +## [camera_unfreeze](#camera_unfreeze) + +### Lua Example +`camera_unfreeze()` + +### Parameters +- None + +### Returns +- None + +### C Prototype +`void camera_unfreeze(void);` + +[:arrow_up_small:](#) + +
+ +## [course_is_main_course](#course_is_main_course) + +### Lua Example +`local booleanValue = course_is_main_course(courseNum)` + +### Parameters +| Field | Type | +| ----- | ---- | +| courseNum | `integer` | + +### Returns +- `boolean` + +### C Prototype +`bool course_is_main_course(u16 courseNum);` + +[:arrow_up_small:](#) + +
+ +## [deref_s32_pointer](#deref_s32_pointer) + +### Lua Example +`local integerValue = deref_s32_pointer(pointer)` + +### Parameters +| Field | Type | +| ----- | ---- | +| pointer | `Pointer` <`integer`> | + +### Returns +- `integer` + +### C Prototype +`s32 deref_s32_pointer(s32* pointer);` + +[:arrow_up_small:](#) + +
+ +## [get_current_save_file_num](#get_current_save_file_num) + +### Lua Example +`local integerValue = get_current_save_file_num()` + +### Parameters +- None + +### Returns +- `integer` + +### C Prototype +`s16 get_current_save_file_num(void);` + +[:arrow_up_small:](#) + +
+ +## [get_dialog_box_state](#get_dialog_box_state) + +### Lua Example +`local integerValue = get_dialog_box_state()` + +### Parameters +- None + +### Returns +- `integer` + +### C Prototype +`s8 get_dialog_box_state();` + +[:arrow_up_small:](#) + +
+ +## [get_dialog_id](#get_dialog_id) + +### Lua Example +`local integerValue = get_dialog_id()` + +### Parameters +- None + +### Returns +- `integer` + +### C Prototype +`s16 get_dialog_id(void);` + +[:arrow_up_small:](#) + +
+ +## [get_envfx](#get_envfx) + +### Lua Example +`local integerValue = get_envfx()` + +### Parameters +- None + +### Returns +- `integer` + +### C Prototype +`u16 get_envfx(void);` + +[:arrow_up_small:](#) + +
+ +## [get_environment_region](#get_environment_region) + +### Lua Example +`local numberValue = get_environment_region(index)` + +### Parameters +| Field | Type | +| ----- | ---- | +| index | `integer` | + +### Returns +- `number` + +### C Prototype +`f32 get_environment_region(u8 index);` + +[:arrow_up_small:](#) + +
+ +## [get_hand_foot_pos_x](#get_hand_foot_pos_x) + +### Lua Example +`local numberValue = get_hand_foot_pos_x(m, index)` + +### Parameters +| Field | Type | +| ----- | ---- | +| m | [MarioState](structs.md#MarioState) | +| index | `integer` | + +### Returns +- `number` + +### C Prototype +`f32 get_hand_foot_pos_x(struct MarioState* m, u8 index);` + +[:arrow_up_small:](#) + +
+ +## [get_hand_foot_pos_y](#get_hand_foot_pos_y) + +### Lua Example +`local numberValue = get_hand_foot_pos_y(m, index)` + +### Parameters +| Field | Type | +| ----- | ---- | +| m | [MarioState](structs.md#MarioState) | +| index | `integer` | + +### Returns +- `number` + +### C Prototype +`f32 get_hand_foot_pos_y(struct MarioState* m, u8 index);` + +[:arrow_up_small:](#) + +
+ +## [get_hand_foot_pos_z](#get_hand_foot_pos_z) + +### Lua Example +`local numberValue = get_hand_foot_pos_z(m, index)` + +### Parameters +| Field | Type | +| ----- | ---- | +| m | [MarioState](structs.md#MarioState) | +| index | `integer` | + +### Returns +- `number` + +### C Prototype +`f32 get_hand_foot_pos_z(struct MarioState* m, u8 index);` + +[:arrow_up_small:](#) + +
+ +## [get_last_star_or_key](#get_last_star_or_key) + +### Lua Example +`local integerValue = get_last_star_or_key()` + +### Parameters +- None + +### Returns +- `integer` + +### C Prototype +`s32 get_last_star_or_key(void);` + +[: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_network_area_timer](#get_network_area_timer) + +### Lua Example +`local integerValue = get_network_area_timer()` + +### Parameters +- None + +### Returns +- `integer` + +### C Prototype +`u32 get_network_area_timer(void);` + +[:arrow_up_small:](#) + +
+ +## [get_os_name](#get_os_name) + +### Lua Example +`local stringValue = get_os_name()` + +### Parameters +- None + +### Returns +- `string` + +### C Prototype +`char* get_os_name(void);` + +[:arrow_up_small:](#) + +
+ +## [get_skybox](#get_skybox) + +### Lua Example +`local integerValue = get_skybox()` + +### Parameters +- None + +### Returns +- `integer` + +### C Prototype +`s8 get_skybox();` + +[:arrow_up_small:](#) + +
+ +## [get_temp_s32_pointer](#get_temp_s32_pointer) + +### Lua Example +`local PointerValue = get_temp_s32_pointer(initialValue)` + +### Parameters +| Field | Type | +| ----- | ---- | +| initialValue | `integer` | + +### Returns +- `Pointer` <`integer`> + +### C Prototype +`s32* get_temp_s32_pointer(s32 initialValue);` + +[:arrow_up_small:](#) + +
+ +## [get_time](#get_time) + +### Lua Example +`local integerValue = get_time()` + +### Parameters +- None + +### Returns +- `integer` + +### C Prototype +`u32 get_time(void);` + +[:arrow_up_small:](#) + +
+ +## [get_ttc_speed_setting](#get_ttc_speed_setting) + +### Lua Example +`local integerValue = get_ttc_speed_setting()` + +### Parameters +- None + +### Returns +- `integer` + +### C Prototype +`s16 get_ttc_speed_setting();` + +[:arrow_up_small:](#) + +
+ +## [hud_get_value](#hud_get_value) + +### Lua Example +`local integerValue = hud_get_value(type)` + +### Parameters +| Field | Type | +| ----- | ---- | +| type | [enum HudDisplayValue](constants.md#enum-HudDisplayValue) | + +### Returns +- `integer` + +### C Prototype +`s32 hud_get_value(enum HudDisplayValue type);` + +[:arrow_up_small:](#) + +
+ +## [hud_hide](#hud_hide) + +### Lua Example +`hud_hide()` + +### Parameters +- None + +### Returns +- None + +### C Prototype +`void hud_hide(void);` + +[:arrow_up_small:](#) + +
+ +## [hud_is_hidden](#hud_is_hidden) + +### Lua Example +`local booleanValue = hud_is_hidden()` + +### Parameters +- None + +### Returns +- `boolean` + +### C Prototype +`bool hud_is_hidden(void);` + +[:arrow_up_small:](#) + +
+ +## [hud_render_power_meter](#hud_render_power_meter) + +### Lua Example +`hud_render_power_meter(health, x, y, width, height)` + +### Parameters +| Field | Type | +| ----- | ---- | +| health | `integer` | +| x | `number` | +| y | `number` | +| width | `number` | +| height | `number` | + +### Returns +- None + +### C Prototype +`void hud_render_power_meter(s32 health, f32 x, f32 y, f32 width, f32 height);` + +[:arrow_up_small:](#) + +
+ +## [hud_render_power_meter_interpolated](#hud_render_power_meter_interpolated) + +### Lua Example +`hud_render_power_meter_interpolated(health, prevX, prevY, prevWidth, prevHeight, x, y, width, height)` + +### Parameters +| Field | Type | +| ----- | ---- | +| health | `integer` | +| prevX | `number` | +| prevY | `number` | +| prevWidth | `number` | +| prevHeight | `number` | +| x | `number` | +| y | `number` | +| width | `number` | +| height | `number` | + +### Returns +- None + +### C Prototype +`void hud_render_power_meter_interpolated(s32 health, f32 prevX, f32 prevY, f32 prevWidth, f32 prevHeight, f32 x, f32 y, f32 width, f32 height);` + +[:arrow_up_small:](#) + +
+ +## [hud_set_value](#hud_set_value) + +### Lua Example +`hud_set_value(type, value)` + +### Parameters +| Field | Type | +| ----- | ---- | +| type | [enum HudDisplayValue](constants.md#enum-HudDisplayValue) | +| value | `integer` | + +### Returns +- None + +### C Prototype +`void hud_set_value(enum HudDisplayValue type, s32 value);` + +[:arrow_up_small:](#) + +
+ +## [hud_show](#hud_show) + +### Lua Example +`hud_show()` + +### Parameters +- None + +### Returns +- None + +### C Prototype +`void hud_show(void);` + +[:arrow_up_small:](#) + +
+ +## [is_game_paused](#is_game_paused) + +### Lua Example +`local booleanValue = is_game_paused()` + +### Parameters +- None + +### Returns +- `boolean` + +### C Prototype +`bool is_game_paused(void);` + +[:arrow_up_small:](#) + +
+ +## [is_transition_playing](#is_transition_playing) + +### Lua Example +`local booleanValue = is_transition_playing()` + +### Parameters +- None + +### Returns +- `boolean` + +### C Prototype +`bool is_transition_playing(void);` + +[:arrow_up_small:](#) + +
+ +## [movtexqc_register](#movtexqc_register) + +### Lua Example +`movtexqc_register(name, level, area, type)` + +### Parameters +| Field | Type | +| ----- | ---- | +| name | `string` | +| level | `integer` | +| area | `integer` | +| type | `integer` | + +### Returns +- None + +### C Prototype +`void movtexqc_register(const char* name, s16 level, s16 area, s16 type);` + +[:arrow_up_small:](#) + +
+ +## [play_transition](#play_transition) + +### Lua Example +`play_transition(transType, time, red, green, blue)` + +### Parameters +| Field | Type | +| ----- | ---- | +| transType | `integer` | +| time | `integer` | +| red | `integer` | +| green | `integer` | +| blue | `integer` | + +### Returns +- None + +### C Prototype +`void play_transition(s16 transType, s16 time, u8 red, u8 green, u8 blue);` + +[:arrow_up_small:](#) + +
+ +## [save_file_set_using_backup_slot](#save_file_set_using_backup_slot) + +### Lua Example +`save_file_set_using_backup_slot(usingBackupSlot)` + +### Parameters +| Field | Type | +| ----- | ---- | +| usingBackupSlot | `boolean` | + +### Returns +- None + +### C Prototype +`void save_file_set_using_backup_slot(bool usingBackupSlot);` + +[:arrow_up_small:](#) + +
+ +## [set_environment_region](#set_environment_region) + +### Lua Example +`set_environment_region(index, value)` + +### Parameters +| Field | Type | +| ----- | ---- | +| index | `integer` | +| value | `integer` | + +### Returns +- None + +### C Prototype +`void set_environment_region(u8 index, s32 value);` + +[:arrow_up_small:](#) + +
+ +## [set_last_star_or_key](#set_last_star_or_key) + +### Lua Example +`set_last_star_or_key(value)` + +### Parameters +| Field | Type | +| ----- | ---- | +| value | `integer` | + +### Returns +- None + +### C Prototype +`void set_last_star_or_key(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 +`set_override_envfx(envfx)` + +### Parameters +| Field | Type | +| ----- | ---- | +| envfx | `integer` | + +### Returns +- None + +### C Prototype +`void set_override_envfx(s32 envfx);` + +[: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_ttc_speed_setting](#set_ttc_speed_setting) + +### Lua Example +`set_ttc_speed_setting(speed)` + +### Parameters +| Field | Type | +| ----- | ---- | +| speed | `integer` | + +### Returns +- None + +### C Prototype +`void set_ttc_speed_setting(s16 speed);` + +[:arrow_up_small:](#) + +
+ +--- +# functions from smlua_model_utils.h + +
+ + +## [smlua_model_util_get_id](#smlua_model_util_get_id) + +### Lua Example +`local integerValue = smlua_model_util_get_id(name)` + +### Parameters +| Field | Type | +| ----- | ---- | +| name | `string` | + +### Returns +- `integer` + +### C Prototype +`u32 smlua_model_util_get_id(const char* name);` + +[:arrow_up_small:](#) + +
+ --- # functions from smlua_obj_utils.h diff --git a/docs/lua/functions.md b/docs/lua/functions.md index fbfaef7a..2c79d0ca 100644 --- a/docs/lua/functions.md +++ b/docs/lua/functions.md @@ -1459,6 +1459,12 @@
+- smlua_anim_utils.h + - [smlua_anim_util_get_current_animation_name](functions-4.md#smlua_anim_util_get_current_animation_name) + - [smlua_anim_util_set_animation](functions-4.md#smlua_anim_util_set_animation) + +
+ - smlua_audio_utils.h - [audio_sample_destroy](functions-4.md#audio_sample_destroy) - [audio_sample_load](functions-4.md#audio_sample_load) @@ -1524,75 +1530,75 @@
- smlua_misc_utils.h - - [add_scroll_target](functions-4.md#add_scroll_target) - - [allocate_mario_action](functions-4.md#allocate_mario_action) - - [camera_config_enable_analog_cam](functions-4.md#camera_config_enable_analog_cam) - - [camera_config_enable_free_cam](functions-4.md#camera_config_enable_free_cam) - - [camera_config_enable_mouse_look](functions-4.md#camera_config_enable_mouse_look) - - [camera_config_get_aggression](functions-4.md#camera_config_get_aggression) - - [camera_config_get_deceleration](functions-4.md#camera_config_get_deceleration) - - [camera_config_get_pan_level](functions-4.md#camera_config_get_pan_level) - - [camera_config_get_x_sensitivity](functions-4.md#camera_config_get_x_sensitivity) - - [camera_config_get_y_sensitivity](functions-4.md#camera_config_get_y_sensitivity) - - [camera_config_invert_x](functions-4.md#camera_config_invert_x) - - [camera_config_invert_y](functions-4.md#camera_config_invert_y) - - [camera_config_is_analog_cam_enabled](functions-4.md#camera_config_is_analog_cam_enabled) - - [camera_config_is_free_cam_enabled](functions-4.md#camera_config_is_free_cam_enabled) - - [camera_config_is_mouse_look_enabled](functions-4.md#camera_config_is_mouse_look_enabled) - - [camera_config_is_x_inverted](functions-4.md#camera_config_is_x_inverted) - - [camera_config_is_y_inverted](functions-4.md#camera_config_is_y_inverted) - - [camera_config_set_aggression](functions-4.md#camera_config_set_aggression) - - [camera_config_set_deceleration](functions-4.md#camera_config_set_deceleration) - - [camera_config_set_pan_level](functions-4.md#camera_config_set_pan_level) - - [camera_config_set_x_sensitivity](functions-4.md#camera_config_set_x_sensitivity) - - [camera_config_set_y_sensitivity](functions-4.md#camera_config_set_y_sensitivity) - - [camera_freeze](functions-4.md#camera_freeze) - - [camera_is_frozen](functions-4.md#camera_is_frozen) - - [camera_unfreeze](functions-4.md#camera_unfreeze) - - [course_is_main_course](functions-4.md#course_is_main_course) - - [deref_s32_pointer](functions-4.md#deref_s32_pointer) - - [get_current_save_file_num](functions-4.md#get_current_save_file_num) - - [get_dialog_box_state](functions-4.md#get_dialog_box_state) - - [get_dialog_id](functions-4.md#get_dialog_id) - - [get_envfx](functions-4.md#get_envfx) - - [get_environment_region](functions-4.md#get_environment_region) - - [get_hand_foot_pos_x](functions-4.md#get_hand_foot_pos_x) - - [get_hand_foot_pos_y](functions-4.md#get_hand_foot_pos_y) - - [get_hand_foot_pos_z](functions-4.md#get_hand_foot_pos_z) - - [get_last_star_or_key](functions-4.md#get_last_star_or_key) - - [get_lighting_dir](functions-4.md#get_lighting_dir) - - [get_network_area_timer](functions-4.md#get_network_area_timer) - - [get_os_name](functions-4.md#get_os_name) - - [get_skybox](functions-4.md#get_skybox) - - [get_temp_s32_pointer](functions-4.md#get_temp_s32_pointer) - - [get_time](functions-4.md#get_time) - - [get_ttc_speed_setting](functions-4.md#get_ttc_speed_setting) - - [hud_get_value](functions-4.md#hud_get_value) - - [hud_hide](functions-4.md#hud_hide) - - [hud_is_hidden](functions-4.md#hud_is_hidden) - - [hud_render_power_meter](functions-4.md#hud_render_power_meter) - - [hud_render_power_meter_interpolated](functions-4.md#hud_render_power_meter_interpolated) - - [hud_set_value](functions-4.md#hud_set_value) - - [hud_show](functions-4.md#hud_show) - - [is_game_paused](functions-4.md#is_game_paused) - - [is_transition_playing](functions-4.md#is_transition_playing) - - [movtexqc_register](functions-4.md#movtexqc_register) - - [play_transition](functions-4.md#play_transition) - - [save_file_set_using_backup_slot](functions-4.md#save_file_set_using_backup_slot) - - [set_environment_region](functions-4.md#set_environment_region) - - [set_last_star_or_key](functions-4.md#set_last_star_or_key) - - [set_lighting_dir](functions-4.md#set_lighting_dir) - - [set_override_envfx](functions-4.md#set_override_envfx) - - [set_override_far](functions-4.md#set_override_far) - - [set_override_fov](functions-4.md#set_override_fov) - - [set_override_near](functions-4.md#set_override_near) - - [set_override_skybox](functions-4.md#set_override_skybox) - - [set_ttc_speed_setting](functions-4.md#set_ttc_speed_setting) + - [add_scroll_target](functions-5.md#add_scroll_target) + - [allocate_mario_action](functions-5.md#allocate_mario_action) + - [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_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) + - [get_current_save_file_num](functions-5.md#get_current_save_file_num) + - [get_dialog_box_state](functions-5.md#get_dialog_box_state) + - [get_dialog_id](functions-5.md#get_dialog_id) + - [get_envfx](functions-5.md#get_envfx) + - [get_environment_region](functions-5.md#get_environment_region) + - [get_hand_foot_pos_x](functions-5.md#get_hand_foot_pos_x) + - [get_hand_foot_pos_y](functions-5.md#get_hand_foot_pos_y) + - [get_hand_foot_pos_z](functions-5.md#get_hand_foot_pos_z) + - [get_last_star_or_key](functions-5.md#get_last_star_or_key) + - [get_lighting_dir](functions-5.md#get_lighting_dir) + - [get_network_area_timer](functions-5.md#get_network_area_timer) + - [get_os_name](functions-5.md#get_os_name) + - [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) + - [hud_get_value](functions-5.md#hud_get_value) + - [hud_hide](functions-5.md#hud_hide) + - [hud_is_hidden](functions-5.md#hud_is_hidden) + - [hud_render_power_meter](functions-5.md#hud_render_power_meter) + - [hud_render_power_meter_interpolated](functions-5.md#hud_render_power_meter_interpolated) + - [hud_set_value](functions-5.md#hud_set_value) + - [hud_show](functions-5.md#hud_show) + - [is_game_paused](functions-5.md#is_game_paused) + - [is_transition_playing](functions-5.md#is_transition_playing) + - [movtexqc_register](functions-5.md#movtexqc_register) + - [play_transition](functions-5.md#play_transition) + - [save_file_set_using_backup_slot](functions-5.md#save_file_set_using_backup_slot) + - [set_environment_region](functions-5.md#set_environment_region) + - [set_last_star_or_key](functions-5.md#set_last_star_or_key) + - [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_ttc_speed_setting](functions-5.md#set_ttc_speed_setting)
- smlua_model_utils.h - - [smlua_model_util_get_id](functions-4.md#smlua_model_util_get_id) + - [smlua_model_util_get_id](functions-5.md#smlua_model_util_get_id)
diff --git a/src/pc/lua/smlua.c b/src/pc/lua/smlua.c index 9c9c27d5..2e0bd462 100644 --- a/src/pc/lua/smlua.c +++ b/src/pc/lua/smlua.c @@ -7,6 +7,7 @@ #include "pc/lua/utils/smlua_audio_utils.h" #include "pc/lua/utils/smlua_model_utils.h" #include "pc/lua/utils/smlua_level_utils.h" +#include "pc/lua/utils/smlua_anim_utils.h" #include "pc/djui/djui.h" lua_State* gLuaState = NULL; @@ -198,6 +199,7 @@ void smlua_shutdown(void) { smlua_clear_hooks(); smlua_model_util_reset(); smlua_level_util_reset(); + smlua_anim_util_reset(); lua_State* L = gLuaState; if (L != NULL) { lua_close(L); diff --git a/src/pc/lua/smlua_functions.c b/src/pc/lua/smlua_functions.c index 2cc491c4..3af72eb4 100644 --- a/src/pc/lua/smlua_functions.c +++ b/src/pc/lua/smlua_functions.c @@ -13,6 +13,7 @@ #include "pc/djui/djui_hud_utils.h" #include "include/level_misc_macros.h" #include "include/macro_presets.h" +#include "utils/smlua_anim_utils.h" bool smlua_functions_valid_param_count(lua_State* L, int expected) { int top = lua_gettop(L); @@ -647,6 +648,69 @@ void smlua_func_level_script_parse(lua_State* L) { gLevelScriptModIndex = currModIndex; } + /////////////////////// + // custom animations // +/////////////////////// + +static u16 *smlua_to_u16_list(lua_State* L, int index) { + + // Get number of values + s32 length = lua_rawlen(L, index); + if (!length) { LOG_LUA("smlua_to_u16_list: Table must not be empty"); return NULL; } + u16 *values = calloc(length, sizeof(u16)); + + // Retrieve values + lua_pushnil(L); + s32 top = lua_gettop(L); + while (lua_next(L, index) != 0) { + int indexKey = lua_gettop(L) - 1; + int indexValue = lua_gettop(L) - 0; + + s32 key = smlua_to_integer(L, indexKey); + if (!gSmLuaConvertSuccess) { LOG_LUA("smlua_to_u16_list: Failed to convert table key"); return 0; } + + u16 value = smlua_to_integer(L, indexValue); + if (!gSmLuaConvertSuccess) { LOG_LUA("smlua_to_u16_list: Failed to convert table value"); return 0; } + + values[key - 1] = value; + lua_settop(L, top); + } + lua_settop(L, top); + return values; +} + +int smlua_func_smlua_anim_util_register_animation(lua_State* L) { + if (!smlua_functions_valid_param_count(L, 8)) { return 0; } + + const char *name = smlua_to_string(L, 1); + if (!gSmLuaConvertSuccess) { LOG_LUA("smlua_anim_util_register_animation: Failed to convert parameter 'name'"); return 0; } + + s16 flags = smlua_to_integer(L, 2); + if (!gSmLuaConvertSuccess) { LOG_LUA("smlua_anim_util_register_animation: Failed to convert parameter 'flags'"); return 0; } + + s16 animYTransDivisor = smlua_to_integer(L, 3); + if (!gSmLuaConvertSuccess) { LOG_LUA("smlua_anim_util_register_animation: Failed to convert parameter 'animYTransDivisor'"); return 0; } + + s16 startFrame = smlua_to_integer(L, 4); + if (!gSmLuaConvertSuccess) { LOG_LUA("smlua_anim_util_register_animation: Failed to convert parameter 'startFrame'"); return 0; } + + s16 loopStart = smlua_to_integer(L, 5); + if (!gSmLuaConvertSuccess) { LOG_LUA("smlua_anim_util_register_animation: Failed to convert parameter 'loopStart'"); return 0; } + + s16 loopEnd = smlua_to_integer(L, 6); + if (!gSmLuaConvertSuccess) { LOG_LUA("smlua_anim_util_register_animation: Failed to convert parameter 'loopEnd'"); return 0; } + + s16 *values = (s16 *) smlua_to_u16_list(L, 7); + if (!values) { LOG_LUA("smlua_anim_util_register_animation: Failed to convert parameter 'values'"); return 0; } + + u16 *index = (u16 *) smlua_to_u16_list(L, 8); + if (!index) { LOG_LUA("smlua_anim_util_register_animation: Failed to convert parameter 'index'"); return 0; } + + smlua_anim_util_register_animation(name, flags, animYTransDivisor, startFrame, loopStart, loopEnd, values, index); + + return 1; +} + ////////// // bind // ////////// @@ -671,4 +735,5 @@ void smlua_bind_functions(void) { smlua_bind_function(L, "djui_hud_render_texture_interpolated", smlua_func_djui_hud_render_texture_interpolated); smlua_bind_function(L, "djui_hud_render_texture_tile_interpolated", smlua_func_djui_hud_render_texture_tile_interpolated); smlua_bind_function(L, "level_script_parse", smlua_func_level_script_parse); + smlua_bind_function(L, "smlua_anim_util_register_animation", smlua_func_smlua_anim_util_register_animation); } diff --git a/src/pc/lua/smlua_functions_autogen.c b/src/pc/lua/smlua_functions_autogen.c index af1517a1..ac697a1f 100644 --- a/src/pc/lua/smlua_functions_autogen.c +++ b/src/pc/lua/smlua_functions_autogen.c @@ -30,6 +30,7 @@ #include "src/pc/lua/utils/smlua_text_utils.h" #include "src/pc/lua/utils/smlua_audio_utils.h" #include "src/pc/lua/utils/smlua_level_utils.h" +#include "src/pc/lua/utils/smlua_anim_utils.h" #include "src/pc/lua/utils/smlua_deprecated.h" #include "src/game/object_list_processor.h" #include "src/game/behavior_actions.h" @@ -25850,6 +25851,46 @@ int smlua_func_save_file_set_star_flags(lua_State* L) { return 1; } + //////////////////////// + // smlua_anim_utils.h // +//////////////////////// + +int smlua_func_smlua_anim_util_get_current_animation_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_anim_util_get_current_animation_name", 1, top); + return 0; + } + + struct Object* obj = (struct Object*)smlua_to_cobject(L, 1, LOT_OBJECT); + if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "smlua_anim_util_get_current_animation_name"); return 0; } + + lua_pushstring(L, smlua_anim_util_get_current_animation_name(obj)); + + return 1; +} + +int smlua_func_smlua_anim_util_set_animation(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", "smlua_anim_util_set_animation", 2, top); + return 0; + } + + struct Object* obj = (struct Object*)smlua_to_cobject(L, 1, LOT_OBJECT); + if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "smlua_anim_util_set_animation"); return 0; } + const char* name = smlua_to_string(L, 2); + if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 2, "smlua_anim_util_set_animation"); return 0; } + + smlua_anim_util_set_animation(obj, name); + + return 1; +} + ///////////////////////// // smlua_audio_utils.h // ///////////////////////// @@ -30705,6 +30746,10 @@ void smlua_bind_functions_autogen(void) { smlua_bind_function(L, "save_file_set_flags", smlua_func_save_file_set_flags); smlua_bind_function(L, "save_file_set_star_flags", smlua_func_save_file_set_star_flags); + // smlua_anim_utils.h + smlua_bind_function(L, "smlua_anim_util_get_current_animation_name", smlua_func_smlua_anim_util_get_current_animation_name); + smlua_bind_function(L, "smlua_anim_util_set_animation", smlua_func_smlua_anim_util_set_animation); + // smlua_audio_utils.h smlua_bind_function(L, "audio_sample_destroy", smlua_func_audio_sample_destroy); smlua_bind_function(L, "audio_sample_load", smlua_func_audio_sample_load); diff --git a/src/pc/lua/utils/smlua_anim_utils.c b/src/pc/lua/utils/smlua_anim_utils.c index 851ad49f..271a2f2e 100644 --- a/src/pc/lua/utils/smlua_anim_utils.c +++ b/src/pc/lua/utils/smlua_anim_utils.c @@ -87,3 +87,116 @@ struct GlobalObjectAnimations gGlobalObjectAnimations = { .wiggler_seg5_anims_0500EC8C = (struct Animation**) wiggler_seg5_anims_0500EC8C, .yoshi_seg5_anims_05024100 = (struct Animation**) yoshi_seg5_anims_05024100, }; + + /////////////////////// + // custom animations // +/////////////////////// + +struct CustomAnimation { + const char *name; + struct Animation *anim; + struct CustomAnimation *next; +}; + +struct CustomAnimation* sCustomAnimationHead = NULL; + +static struct CustomAnimation *get_custom_animation_node(const char *name) { + for (struct CustomAnimation *node = sCustomAnimationHead; node; node = node->next) { + if (node->name && strcmp(node->name, name) == 0) { + return node; + } + } + return NULL; +} + +void smlua_anim_util_reset() { + for (struct CustomAnimation *node = sCustomAnimationHead; node;) { + struct CustomAnimation *next = node->next; + if (node->name) { + free((void *) node->name); + } + if (node->anim) { + if (node->anim->index) { + free((void *) node->anim->index); + } + if (node->anim->values) { + free((void *) node->anim->values); + } + } + free(node); + node = next; + } + sCustomAnimationHead = NULL; +} + +void smlua_anim_util_register_animation(const char *name, s16 flags, s16 animYTransDivisor, s16 startFrame, s16 loopStart, s16 loopEnd, const s16 *values, const u16 *index) { + + // NULL-checks + if (!name) { + LOG_LUA_LINE("smlua_anim_util_register_animation: Parameter 'name' is NULL"); + return; + } + + // Check if the name is not already taken + if (get_custom_animation_node(name)) { + LOG_LUA_LINE("smlua_anim_util_register_animation: An animation named '%s' already exists", name); + return; + } + + // Create a new node + struct CustomAnimation *node = calloc(1, sizeof(struct CustomAnimation)); + node->name = strdup(name); + node->anim = calloc(1, sizeof(struct Animation)); + node->anim->flags = flags; + node->anim->animYTransDivisor = animYTransDivisor; + node->anim->startFrame = startFrame; + node->anim->loopStart = loopStart; + node->anim->loopEnd = loopEnd; + node->anim->unusedBoneCount = 0; + node->anim->values = values; + node->anim->index = index; + node->anim->length = 0; + node->next = sCustomAnimationHead; + sCustomAnimationHead = node; + LOG_INFO("Registered custom animation: %s", name); +} + +void smlua_anim_util_set_animation(struct Object *obj, const char *name) { + + // NULL-checks + if (!obj) { + LOG_LUA_LINE("smlua_anim_util_set_animation: Parameter 'obj' is NULL"); + return; + } + if (!name) { + LOG_LUA_LINE("smlua_anim_util_set_animation: Parameter 'name' is NULL"); + return; + } + + // Check if the animation exists + struct CustomAnimation *node = get_custom_animation_node(name); + if (!node) { + LOG_LUA_LINE("smlua_anim_util_set_animation: Animation '%s' doesn't exist", name); + return; + } + + // Set animation + obj->header.gfx.animInfo.curAnim = node->anim; +} + +const char *smlua_anim_util_get_current_animation_name(struct Object *obj) { + + // NULL-checks + if (!obj) { + LOG_LUA_LINE("smlua_anim_util_set_animation: Parameter 'obj' is NULL"); + return NULL; + } + + // Check the animations + for (struct CustomAnimation *node = sCustomAnimationHead; node; node = node->next) { + if (node->anim == obj->header.gfx.animInfo.curAnim) { + return node->name; + } + } + return NULL; +} diff --git a/src/pc/lua/utils/smlua_anim_utils.h b/src/pc/lua/utils/smlua_anim_utils.h index 6991a7f5..f21006a6 100644 --- a/src/pc/lua/utils/smlua_anim_utils.h +++ b/src/pc/lua/utils/smlua_anim_utils.h @@ -1,6 +1,8 @@ #ifndef SMLUA_ANIM_UTILS_H #define SMLUA_ANIM_UTILS_H +#include "types.h" + typedef struct Animation* ObjectAnimPointer; struct GlobalObjectAnimations { @@ -64,4 +66,9 @@ struct GlobalObjectAnimations { extern struct GlobalObjectAnimations gGlobalObjectAnimations; +void smlua_anim_util_reset(); +void smlua_anim_util_register_animation(const char *name, s16 flags, s16 animYTransDivisor, s16 startFrame, s16 loopStart, s16 loopEnd, const s16 *values, const u16 *index); +void smlua_anim_util_set_animation(struct Object *obj, const char *name); +const char *smlua_anim_util_get_current_animation_name(struct Object *obj); + #endif