From 5d5147cb0ec0b29dd423c3dc3a86d24a28d517e3 Mon Sep 17 00:00:00 2001 From: Agent X <44549182+AgentXLP@users.noreply.github.com> Date: Fri, 25 Apr 2025 17:02:46 -0400 Subject: [PATCH] Document more functions! (83%) --- autogen/convert_functions.py | 9 +- autogen/lua_definitions/functions.lua | 154 +- autogen/lua_definitions/structs.lua | 8 - docs/lua/functions-3.md | 24 + docs/lua/functions-4.md | 848 +------- docs/lua/functions-5.md | 2241 +++++++++------------- docs/lua/functions-6.md | 1449 +++++++++++++- docs/lua/functions.md | 302 ++- docs/lua/guides/hooks.md | 2 +- docs/lua/structs.md | 24 - src/audio/external.h | 6 +- src/engine/math_util.h | 2 +- src/engine/surface_load.h | 2 +- src/game/area.c | 10 +- src/game/area.h | 6 +- src/game/camera.h | 1 + src/game/characters.h | 1 + src/game/level_info.h | 4 +- src/game/level_update.c | 2 +- src/game/mario_actions_cutscene.c | 3 +- src/game/mario_step.h | 4 +- src/game/obj_behaviors.c | 162 +- src/game/object_helpers.c | 3 + src/game/object_helpers.h | 10 - src/pc/lua/smlua_cobject_autogen.c | 16 - src/pc/lua/smlua_cobject_autogen.h | 2 - src/pc/lua/smlua_functions_autogen.c | 213 +- src/pc/lua/utils/smlua_audio_utils.h | 10 +- src/pc/lua/utils/smlua_camera_utils.h | 10 +- src/pc/lua/utils/smlua_collision_utils.h | 1 + src/pc/lua/utils/smlua_misc_utils.c | 8 +- src/pc/lua/utils/smlua_misc_utils.h | 9 +- src/pc/network/network_player.h | 12 + 33 files changed, 2847 insertions(+), 2711 deletions(-) diff --git a/autogen/convert_functions.py b/autogen/convert_functions.py index ab836c52e..f4d7a534d 100644 --- a/autogen/convert_functions.py +++ b/autogen/convert_functions.py @@ -87,7 +87,7 @@ override_allowed_functions = { "src/game/platform_displacement.h": [ "apply_platform_displacement" ], "src/game/mario_misc.h": [ "bhv_toad.*", "bhv_unlock_door.*", "geo_get_.*_state" ], "src/game/level_update.h": [ "level_trigger_warp", "get_painting_warp_node", "initiate_painting_warp", "warp_special", "lvl_set_current_level", "level_control_timer_running", "fade_into_special_warp", "get_instant_warp" ], - "src/game/area.h": [ "area_get_warp_node" ], + "src/game/area.h": [ "get_mario_spawn_type", "area_get_warp_node", "area_get_any_warp_node", "play_transition" ], "src/engine/level_script.h": [ "area_create_warp_node" ], "src/game/ingame_menu.h": [ "set_min_dialog_width", "set_dialog_override_pos", "reset_dialog_override_pos", "set_dialog_override_color", "reset_dialog_override_color", "set_menu_mode", "create_dialog_box", "create_dialog_box_with_var", "create_dialog_inverted_box", "create_dialog_box_with_response", "reset_dialog_render_state", "set_dialog_box_state", ], "src/audio/seqplayer.h": [ "sequence_player_set_tempo", "sequence_player_set_tempo_acc", "sequence_player_set_transposition", "sequence_player_get_tempo", "sequence_player_get_tempo_acc", "sequence_player_get_transposition", "sequence_player_get_volume", "sequence_player_get_fade_volume", "sequence_player_get_mute_volume_scale" ] @@ -96,7 +96,7 @@ override_allowed_functions = { override_disallowed_functions = { "src/audio/external.h": [ " func_" ], "src/engine/math_util.h": [ "atan2f", "vec3s_sub" ], - "src/engine/surface_load.h": [ "alloc_surface_pools", "clear_dynamic_surfaces" ], + "src/engine/surface_load.h": [ "load_area_terrain", "alloc_surface_pools", "clear_dynamic_surfaces", "get_area_terrain_size" ], "src/engine/surface_collision.h": [ " debug_", "f32_find_wall_collision" ], "src/game/mario_actions_airborne.c": [ "^[us]32 act_.*" ], "src/game/mario_actions_automatic.c": [ "^[us]32 act_.*" ], @@ -114,8 +114,9 @@ override_disallowed_functions = { "src/pc/network/network_utils.h": [ "network_get_player_text_color[^_]" ], "src/pc/network/network_player.h": [ "_init", "_connected[^_]", "_shutdown", "_disconnected", "_update", "construct_player_popup", "network_player_name_valid" ], "src/game/object_helpers.c": [ "spawn_obj", "^bhv_", "abs[fi]", "^bit_shift", "_debug$", "^stub_", "_set_model", "cur_obj_set_direction_table", "cur_obj_progress_direction_table" ], - "src/game/obj_behaviors.c": [ "debug_" ], + "src/game/obj_behaviors.c": [ "debug_", "turn_obj_away_from_surface" ], "src/game/obj_behaviors_2.c": [ "wiggler_jumped_on_attack_handler", "huge_goomba_weakly_attacked" ], + "src/game/spawn_sound.h": [ "exec_anim_sound_state" ], "src/game/level_info.h": [ "_name_table" ], "src/pc/lua/utils/smlua_obj_utils.h": [ "spawn_object_remember_field" ], "src/game/camera.h": [ "update_camera", "init_camera", "stub_camera", "^reset_camera", "move_point_along_spline", "romhack_camera_init_settings", "romhack_camera_reset_settings" ], @@ -1003,6 +1004,8 @@ def build_function(function, do_extern): if function['description'] != "": global total_doc_functions total_doc_functions += 1 + else: + print(function['filename'] + ": " + function['line']) return s + "\n" diff --git a/autogen/lua_definitions/functions.lua b/autogen/lua_definitions/functions.lua index 29625d6c3..2a95f7906 100644 --- a/autogen/lua_definitions/functions.lua +++ b/autogen/lua_definitions/functions.lua @@ -1,5 +1,12 @@ -- AUTOGENERATED FOR CODE EDITORS -- +--- @param o Object +--- @return MarioSpawnType +--- Derives a `MARIO_SPAWN_*` constant from `o` +function get_mario_spawn_type(o) + -- ... +end + --- @param id integer --- @return ObjectWarpNode --- Finds a warp node in the current area by its ID. The warp node must exist in the list of warp nodes for the current area. Useful for locating a specific warp point in the level, such as teleportation zones or connections to other areas @@ -7,6 +14,12 @@ function area_get_warp_node(id) -- ... end +--- @return ObjectWarpNode +--- Gets the first warp node found in the area, otherwise returns nil +function area_get_any_warp_node() + -- ... +end + --- @param o Object --- @return ObjectWarpNode --- Finds a warp node in the current area using parameters from the provided object. The object's behavior parameters are used to determine the warp node ID. Useful for associating an object (like a door or warp pipe) with its corresponding warp node in the area @@ -14,6 +27,27 @@ function area_get_warp_node_from_params(o) -- ... end +--- @param transType integer +--- @param time integer +--- @param red integer +--- @param green integer +--- @param blue integer +--- Plays a screen transition +function play_transition(transType, time, red, green, blue) + -- ... +end + +--- @param transType integer +--- @param time integer +--- @param red integer +--- @param green integer +--- @param blue integer +--- @param delay integer +--- Plays a screen transition after a `delay` in frames +function play_transition_after_delay(transType, time, red, green, blue, delay) + -- ... +end + --- @param count integer --- @param offsetY integer --- @param size number @@ -3563,6 +3597,7 @@ function next_lakitu_state(newPos, newFoc, curPos, curFoc, oldPos, oldFoc, yaw) end --- @param preset integer +--- Set the fixed camera base pos depending on the current level area function set_fixed_cam_axis_sa_lobby(preset) -- ... end @@ -3713,6 +3748,7 @@ end --- @param m MarioState --- @return Character +--- Gets a Character struct from `m` function get_character(m) -- ... end @@ -4238,12 +4274,14 @@ function play_toads_jingle() end --- @param seqId integer +--- Resets a sequence's (`seqId`) volume back to the default volume function sound_reset_background_music_default_volume(seqId) -- ... end --- @param seqId integer --- @param volume integer +--- Sets a sequence's (`seqId`) volume to `volume` function sound_set_background_music_default_volume(seqId, volume) -- ... end @@ -4251,12 +4289,14 @@ end --- @param x number --- @param z number --- @return number +--- Gets a sound left/right pan using `x` and `z` function get_sound_pan(x, z) -- ... end --- @param distance number --- @return number +--- Gets a sound level intensity based on `distance` function sound_get_level_intensity(distance) -- ... end @@ -4787,6 +4827,7 @@ end --- @param areaIndex integer --- @param charCase integer --- @return Pointer_integer +--- Returns the name of the level corresponding to `courseNum`, `levelNum` and `areaIndex` as an SM64 encoded string. This function should not be used in Lua mods. Set `charCase` to 1 to capitalize or -1 to decapitalize the returned string function get_level_name_sm64(courseNum, levelNum, areaIndex, charCase) -- ... end @@ -4813,6 +4854,7 @@ end --- @param starNum integer --- @param charCase integer --- @return Pointer_integer +--- Returns the name of the star corresponding to `courseNum` and `starNum` as an SM64 encoded string. This function should not be used in Lua mods. Set `charCase` to 1 to capitalize or -1 to decapitalize the returned string function get_star_name_sm64(courseNum, starNum, charCase) -- ... end @@ -5683,6 +5725,7 @@ end --- @param target2 integer --- @param target3 integer --- @param endAction integer +--- Handles the cutscene and animation sequence for when Mario is stuck in the ground (head, butt, or feet). Plays a designated `animation`, checks specific frames (`unstuckFrame`, `target2`, `target3`) for sound effects or transitions, and frees Mario to the `endAction` once the animation completes function stuck_in_ground_handler(m, animation, unstuckFrame, target2, target3, endAction) -- ... end @@ -6506,6 +6549,7 @@ end --- @param dist number --- @param pitch integer --- @param yaw integer +--- Positions the point `to` at a given `dist`, `pitch`, and `yaw` relative to the point `from`. This can be used to place objects around a reference point at specific angles and distances function vec3f_set_dist_and_angle(from, to, dist, pitch, yaw) -- ... end @@ -6728,6 +6772,7 @@ function mod_storage_clear() end --- @return integer +--- Gets the amount of players connected function network_player_connected_count() -- ... end @@ -6738,18 +6783,21 @@ end --- @param g integer --- @param b integer --- @param a integer +--- Sets the description field of `np` function network_player_set_description(np, description, r, g, b, a) -- ... end --- @param np NetworkPlayer --- @param location string +--- Overrides the location of `np` function network_player_set_override_location(np, location) -- ... end --- @param globalIndex integer --- @return NetworkPlayer +--- Gets a network player from `globalIndex` function network_player_from_global_index(globalIndex) -- ... end @@ -6758,6 +6806,7 @@ end --- @param actNum integer --- @param levelNum integer --- @return NetworkPlayer +--- Gets the first network player whose information matches `courseNum`, `actNum`, and `levelNum` function get_network_player_from_level(courseNum, actNum, levelNum) -- ... end @@ -6767,11 +6816,13 @@ end --- @param levelNum integer --- @param areaIndex integer --- @return NetworkPlayer +--- Gets the first network player whose information matches `courseNum`, `actNum`, `levelNum`, and `areaIndex` function get_network_player_from_area(courseNum, actNum, levelNum, areaIndex) -- ... end --- @return NetworkPlayer +--- Gets the active network player with the smallest global index. Useful for assigning one player to "own" some kind of functionality or object function get_network_player_smallest_global() -- ... end @@ -6780,6 +6831,7 @@ end --- @param part PlayerPart --- @param index integer --- @return integer +--- Gets a red, green, or blue value from a part in `np`'s color palette function network_player_get_palette_color_channel(np, part, index) -- ... end @@ -6788,6 +6840,7 @@ end --- @param part PlayerPart --- @param index integer --- @return integer +--- Gets a red, green, or blue value from a part in `np`'s override color palette function network_player_get_override_palette_color_channel(np, part, index) -- ... end @@ -6795,17 +6848,20 @@ end --- @param np NetworkPlayer --- @param part PlayerPart --- @param color Color +--- Sets the `part in `np`'s override color palette` function network_player_set_override_palette_color(np, part, color) -- ... end --- @param np NetworkPlayer +--- Resets `np`'s override color palette function network_player_reset_override_palette(np) -- ... end --- @param np NetworkPlayer --- @return boolean +--- Checks if `np`'s override color palette is identical to the regular color palette function network_player_is_override_palette_same(np) -- ... end @@ -6856,33 +6912,25 @@ function network_discord_id_from_local_index(localIndex) -- ... end +--- Resets Yoshi as being alive function set_yoshi_as_not_dead() -- ... end --- @param f number --- @return number +--- An absolute value (always positive) function. function absf_2(f) -- ... end ---- @param velX number ---- @param velZ number ---- @param nX number ---- @param nY number ---- @param nZ number ---- @param objYawX Pointer_number ---- @param objYawZ Pointer_number -function turn_obj_away_from_surface(velX, velZ, nX, nY, nZ, objYawX, objYawZ) - -- ... -end - --- @param objNewX number --- @param objY number --- @param objNewZ number --- @param objVelX number --- @param objVelZ number --- @return integer +--- Finds any wall collisions, applies them, and turns away from the surface. function obj_find_wall(objNewX, objY, objNewZ, objVelX, objVelZ) -- ... end @@ -6892,6 +6940,7 @@ end --- @param objVelX number --- @param objVelZ number --- @return integer +--- Turns an object away from steep floors, similarly to walls. function turn_obj_away_from_steep_floor(objFloor, floorY, objVelX, objVelZ) -- ... end @@ -6900,12 +6949,14 @@ end --- @param normalX number --- @param normalY number --- @param normalZ number +--- Orients an object with the given normals, typically the surface under the object. function obj_orient_graph(obj, normalX, normalY, normalZ) -- ... end --- @param objFriction Pointer_number --- @param floor_nY number +--- Orients an object with the given normals, typically the surface under the object. function calc_obj_friction(objFriction, floor_nY) -- ... end @@ -6914,6 +6965,7 @@ end --- @param objFloorY number --- @param objVelX number --- @param objVelZ number +--- Updates an objects speed for gravity and updates Y position. function calc_new_obj_vel_and_pos_y(objFloor, objFloorY, objVelX, objVelZ) -- ... end @@ -6923,31 +6975,37 @@ end --- @param objVelX number --- @param objVelZ number --- @param waterY number +--- Adjusts the current object's veloicty and y position for being underwater function calc_new_obj_vel_and_pos_y_underwater(objFloor, floorY, objVelX, objVelZ, waterY) -- ... end +--- Updates an objects position from oForwardVel and oMoveAngleYaw. function obj_update_pos_vel_xz() -- ... end --- @param waterY integer --- @param objY integer +--- Generates splashes if at surface of water, entering water, or bubbles if underwater function obj_splash(waterY, objY) -- ... end --- @return integer +--- Generic object move function. Handles walls, water, floors, and gravity. Returns flags for certain interactions function object_step() -- ... end --- @return integer +--- Takes an object step but does not orient with the object's floor. Used for boulders, falling pillars, and the rolling snowman body function object_step_without_floor_orient() -- ... end --- @param obj Object +--- Don't use this function outside of of a context where the current object and `obj` are the same. Moves `obj` based on a seemingly random mix of using either the current obj or `obj`'s fields function obj_move_xyz_using_fvel_and_yaw(obj) -- ... end @@ -6957,6 +7015,7 @@ end --- @param z number --- @param dist integer --- @return integer +--- Checks if a point is within distance from any active Mario visible to enemies' graphical position function is_point_within_radius_of_mario(x, y, z, dist) -- ... end @@ -6966,53 +7025,62 @@ end --- @param z number --- @param dist integer --- @return integer +--- Checks if a point is within distance from any active Mario's graphical position function is_point_within_radius_of_any_player(x, y, z, dist) -- ... end --- @param m MarioState --- @return integer +--- Checks if `m` is in the current course/act/level/area and isn't bubbled function is_player_active(m) -- ... end --- @return integer +--- Checks if any player besides the local player is in the current course/act/level/area function is_other_player_active() -- ... end --- @param m MarioState --- @return integer +--- Checks if `m` is in the current course/act/level/area function is_player_in_local_area(m) -- ... end --- @param obj Object --- @return MarioState +--- Gets the nearest active Mario who isn't bubbled to `obj` function nearest_mario_state_to_object(obj) -- ... end --- @param obj Object --- @return MarioState +--- Gets the nearest possible Mario to `obj` despite anything like bubbled state or enemy visibility function nearest_possible_mario_state_to_object(obj) -- ... end --- @param obj Object --- @return Object +--- Gets the nearest player (Mario Object) to `obj` function nearest_player_to_object(obj) -- ... end --- @param obj Object --- @return MarioState +--- Gets the nearest interacting Mario to `obj` function nearest_interacting_mario_state_to_object(obj) -- ... end --- @param obj Object --- @return Object +--- Gets the nearest interacting player (Mario Object) to `obj` function nearest_interacting_player_to_object(obj) -- ... end @@ -7020,6 +7088,7 @@ end --- @param m MarioState --- @param obj Object --- @return integer +--- Checks if `m` is the nearest Mario to `obj` function is_nearest_mario_state_to_object(m, obj) -- ... end @@ -7027,6 +7096,7 @@ end --- @param m Object --- @param obj Object --- @return integer +--- Checks if `m` is the nearest player (Mario Object) to `obj` function is_nearest_player_to_object(m, obj) -- ... end @@ -7037,12 +7107,14 @@ end --- @param z number --- @param dist integer --- @return integer +--- Checks if a point is within `dist` of `obj` function is_point_close_to_object(obj, x, y, z, dist) -- ... end --- @param obj Object --- @param dist integer +--- Sets an object as visible if within a certain distance of Mario's graphical position function set_object_visibility(obj, dist) -- ... end @@ -7053,6 +7125,7 @@ end --- @param homeZ number --- @param dist integer --- @return integer +--- Turns an object towards home if Mario is not near to it function obj_return_home_if_safe(obj, homeX, y, homeZ, dist) -- ... end @@ -7062,6 +7135,7 @@ end --- @param homeY number --- @param homeZ number --- @param baseDisp integer +--- Randomly displaces an objects home if RNG says to, and turns the object towards its home function obj_return_and_displace_home(obj, homeX, homeY, homeZ, baseDisp) -- ... end @@ -7070,6 +7144,7 @@ end --- @param goal integer --- @param range integer --- @return integer +--- A series of checks using sin and cos to see if a given angle is facing in the same direction of a given angle, within a certain range function obj_check_if_facing_toward_angle(base, goal, range) -- ... end @@ -7080,12 +7155,14 @@ end --- @param z number --- @param radius number --- @return integer +--- Finds any wall collisions and returns what the displacement vector would be. function obj_find_wall_displacement(dist, x, y, z, radius) -- ... end --- @param obj Object --- @param nCoins integer +--- Spawns a number of coins at the location of an object with a random forward velocity, y velocity, and direction function obj_spawn_yellow_coins(obj, nCoins) -- ... end @@ -7093,23 +7170,27 @@ end --- @param obj Object --- @param lifeSpan integer --- @return integer +--- Controls whether certain objects should flicker/when to despawn function obj_flicker_and_disappear(obj, lifeSpan) -- ... end --- @param room integer --- @return integer +--- Checks if a given room is Mario's current room, even if on an object function current_mario_room_check(room) -- ... end --- @param collisionFlags integer --- @param floor Surface +--- Checks if `floor`'s type is burning or death plane and if so change the current object's action accordingly function obj_check_floor_death(collisionFlags, floor) -- ... end --- @return integer +--- Controls an object dying in lava by creating smoke, sinking the object, playing audio, and eventually despawning it. Returns TRUE when the obj is dead function obj_lava_death() -- ... end @@ -7118,6 +7199,7 @@ end --- @param relX integer --- @param relY integer --- @param relZ integer +--- Spawns an orange number object relatively, such as those that count up for secrets. function spawn_orange_number(behParam, relX, relY, relZ) -- ... end @@ -8724,12 +8806,14 @@ function cur_obj_spawn_star_at_y_offset(targetX, targetY, targetZ, offsetY) -- ... end +--- Sets the current object's home only the first time it's called function cur_obj_set_home_once() -- ... end --- @param trajectory Pointer_Trajectory --- @return integer +--- Gets a trajectory's length function get_trajectory_length(trajectory) -- ... end @@ -9016,6 +9100,7 @@ function smlua_anim_util_get_current_animation_name(obj) -- ... end +--- Resets all custom sequences back to vanilla function smlua_audio_utils_reset_all() -- ... end @@ -9024,6 +9109,7 @@ end --- @param bankId integer --- @param defaultVolume integer --- @param m64Name string +--- Replaces the sequence corresponding to `sequenceId` with one called `m64Name`.m64 with `bankId` and `defaultVolume` function smlua_audio_utils_replace_sequence(sequenceId, bankId, defaultVolume, m64Name) -- ... end @@ -9063,14 +9149,14 @@ end --- @param audio ModAudio --- @return number ---- Gets the position of an `audio` stream +--- Gets the position of an `audio` stream in seconds function audio_stream_get_position(audio) -- ... end --- @param audio ModAudio --- @param pos number ---- Sets the position of an `audio` stream +--- Sets the position of an `audio` stream in seconds function audio_stream_set_position(audio, pos) -- ... end @@ -9092,7 +9178,7 @@ end --- @param audio ModAudio --- @param loopStart integer --- @param loopEnd integer ---- Sets an `audio` stream's loop points (samples) +--- Sets an `audio` stream's loop points in samples function audio_stream_set_loop_points(audio, loopStart, loopEnd) -- ... end @@ -9330,26 +9416,31 @@ function camera_config_is_y_inverted() end --- @return integer +--- Gets camera X sensitivity function camera_config_get_x_sensitivity() -- ... end --- @return integer +--- Gets camera Y sensitivity function camera_config_get_y_sensitivity() -- ... end --- @return integer +--- Gets camera aggression function camera_config_get_aggression() -- ... end --- @return integer +--- Gets camera pan level function camera_config_get_pan_level() -- ... end --- @return integer +--- Gets camera deceleration function camera_config_get_deceleration() -- ... end @@ -9469,6 +9560,7 @@ function collision_find_ceil(x, y, z) end --- @return Surface +--- Gets the generated water floor surface used when riding a shell function get_water_surface_pseudo_floor() -- ... end @@ -10187,6 +10279,7 @@ end --- @param type HudDisplayValue --- @return integer +--- Gets a HUD display value function hud_get_value(type) -- ... end @@ -10319,16 +10412,6 @@ function set_water_level(index, height, sync) -- ... end ---- @param transType integer ---- @param time integer ---- @param red integer ---- @param green integer ---- @param blue integer ---- Plays a screen transition -function play_transition(transType, time, red, green, blue) - -- ... -end - --- @param courseNum integer --- @return boolean --- Checks if a course is a main course and not the castle or secret levels @@ -10446,7 +10529,7 @@ function set_volume_env(volume) end --- @param index integer ---- @return number +--- @return integer --- Gets an environment region (gas/water boxes) height value function get_environment_region(index) -- ... @@ -11088,12 +11171,6 @@ function stop_cap_music() -- ... end ---- @param soundStates SoundState ---- @param maxSoundStates integer -function exec_anim_sound_state(soundStates, maxSoundStates) - -- ... -end - --- @param soundMagic integer --- Plays a sound if the current object is visible function cur_obj_play_sound_1(soundMagic) @@ -11175,20 +11252,6 @@ function set_find_wall_direction(dir, active, airborne) -- ... end ---- @param data Pointer_integer ---- @return integer -function get_area_terrain_size(data) - -- ... -end - ---- @param index integer ---- @param data Pointer_integer ---- @param surfaceRooms Pointer_integer ---- @param macroObjects Pointer_integer -function load_area_terrain(index, data, surfaceRooms, macroObjects) - -- ... -end - --- Loads the object's collision data into dynamic collision. You must run this every frame in your object's behavior loop for it to have collision function load_object_collision_model() -- ... @@ -11204,6 +11267,7 @@ end --- @param surfaceType integer --- @return boolean +--- Checks if a surface has force function surface_has_force(surfaceType) -- ... end diff --git a/autogen/lua_definitions/structs.lua b/autogen/lua_definitions/structs.lua index bcf290e43..e42150ac5 100644 --- a/autogen/lua_definitions/structs.lua +++ b/autogen/lua_definitions/structs.lua @@ -2292,10 +2292,6 @@ --- @field public dialog5 integer --- @field public dialog6 integer ---- @class Struct802A272C ---- @field public vecF Vec3f ---- @field public vecS Vec3s - --- @class Surface --- @field public flags integer --- @field public force integer @@ -2409,10 +2405,6 @@ --- @field public pos Vec3s --- @field public strength integer ---- @class struct802A1230 ---- @field public unk00 integer ---- @field public unk02 integer - --- @class Vec2f --- @field public x number --- @field public y number diff --git a/docs/lua/functions-3.md b/docs/lua/functions-3.md index 998ab69c5..1301e245d 100644 --- a/docs/lua/functions-3.md +++ b/docs/lua/functions-3.md @@ -1955,6 +1955,9 @@ Transitions the camera to the next Lakitu state, updating position and focus. Th ## [set_fixed_cam_axis_sa_lobby](#set_fixed_cam_axis_sa_lobby) +### Description +Set the fixed camera base pos depending on the current level area + ### Lua Example `set_fixed_cam_axis_sa_lobby(preset)` @@ -2438,6 +2441,9 @@ Centers the ROM hack camera. This function is designed for non-standard level la ## [get_character](#get_character) +### Description +Gets a Character struct from `m` + ### Lua Example `local CharacterValue = get_character(m)` @@ -4281,6 +4287,9 @@ Plays Toad's jingle ## [sound_reset_background_music_default_volume](#sound_reset_background_music_default_volume) +### Description +Resets a sequence's (`seqId`) volume back to the default volume + ### Lua Example `sound_reset_background_music_default_volume(seqId)` @@ -4301,6 +4310,9 @@ Plays Toad's jingle ## [sound_set_background_music_default_volume](#sound_set_background_music_default_volume) +### Description +Sets a sequence's (`seqId`) volume to `volume` + ### Lua Example `sound_set_background_music_default_volume(seqId, volume)` @@ -4322,6 +4334,9 @@ Plays Toad's jingle ## [get_sound_pan](#get_sound_pan) +### Description +Gets a sound left/right pan using `x` and `z` + ### Lua Example `local numberValue = get_sound_pan(x, z)` @@ -4343,6 +4358,9 @@ Plays Toad's jingle ## [sound_get_level_intensity](#sound_get_level_intensity) +### Description +Gets a sound level intensity based on `distance` + ### Lua Example `local numberValue = sound_get_level_intensity(distance)` @@ -6008,6 +6026,9 @@ Returns the name of the level corresponding to `courseNum`, `levelNum` and `area ## [get_level_name_sm64](#get_level_name_sm64) +### Description +Returns the name of the level corresponding to `courseNum`, `levelNum` and `areaIndex` as an SM64 encoded string. This function should not be used in Lua mods. Set `charCase` to 1 to capitalize or -1 to decapitalize the returned string + ### Lua Example `local PointerValue = get_level_name_sm64(courseNum, levelNum, areaIndex, charCase)` @@ -6081,6 +6102,9 @@ Returns the name of the star corresponding to `courseNum` and `starNum` as an AS ## [get_star_name_sm64](#get_star_name_sm64) +### Description +Returns the name of the star corresponding to `courseNum` and `starNum` as an SM64 encoded string. This function should not be used in Lua mods. Set `charCase` to 1 to capitalize or -1 to decapitalize the returned string + ### Lua Example `local PointerValue = get_star_name_sm64(courseNum, starNum, charCase)` diff --git a/docs/lua/functions-4.md b/docs/lua/functions-4.md index b3feb0373..437360288 100644 --- a/docs/lua/functions-4.md +++ b/docs/lua/functions-4.md @@ -2328,6 +2328,9 @@ Launches Mario forward with a given velocity (`forwardVel`) and sets his animati ## [stuck_in_ground_handler](#stuck_in_ground_handler) +### Description +Handles the cutscene and animation sequence for when Mario is stuck in the ground (head, butt, or feet). Plays a designated `animation`, checks specific frames (`unstuckFrame`, `target2`, `target3`) for sound effects or transitions, and frees Mario to the `endAction` once the animation completes + ### Lua Example `stuck_in_ground_handler(m, animation, unstuckFrame, target2, target3, endAction)` @@ -4952,6 +4955,9 @@ Calculates the distance between two points in 3D space (`from` and `to`), as wel ## [vec3f_set_dist_and_angle](#vec3f_set_dist_and_angle) +### Description +Positions the point `to` at a given `dist`, `pitch`, and `yaw` relative to the point `from`. This can be used to place objects around a reference point at specific angles and distances + ### Lua Example `vec3f_set_dist_and_angle(from, to, dist, pitch, yaw)` @@ -5660,6 +5666,9 @@ Clears the mod's data from mod storage ## [network_player_connected_count](#network_player_connected_count) +### Description +Gets the amount of players connected + ### Lua Example `local integerValue = network_player_connected_count()` @@ -5678,6 +5687,9 @@ Clears the mod's data from mod storage ## [network_player_set_description](#network_player_set_description) +### Description +Sets the description field of `np` + ### Lua Example `network_player_set_description(np, description, r, g, b, a)` @@ -5703,6 +5715,9 @@ Clears the mod's data from mod storage ## [network_player_set_override_location](#network_player_set_override_location) +### Description +Overrides the location of `np` + ### Lua Example `network_player_set_override_location(np, location)` @@ -5724,6 +5739,9 @@ Clears the mod's data from mod storage ## [network_player_from_global_index](#network_player_from_global_index) +### Description +Gets a network player from `globalIndex` + ### Lua Example `local NetworkPlayerValue = network_player_from_global_index(globalIndex)` @@ -5744,6 +5762,9 @@ Clears the mod's data from mod storage ## [get_network_player_from_level](#get_network_player_from_level) +### Description +Gets the first network player whose information matches `courseNum`, `actNum`, and `levelNum` + ### Lua Example `local NetworkPlayerValue = get_network_player_from_level(courseNum, actNum, levelNum)` @@ -5766,6 +5787,9 @@ Clears the mod's data from mod storage ## [get_network_player_from_area](#get_network_player_from_area) +### Description +Gets the first network player whose information matches `courseNum`, `actNum`, `levelNum`, and `areaIndex` + ### Lua Example `local NetworkPlayerValue = get_network_player_from_area(courseNum, actNum, levelNum, areaIndex)` @@ -5789,6 +5813,9 @@ Clears the mod's data from mod storage ## [get_network_player_smallest_global](#get_network_player_smallest_global) +### Description +Gets the active network player with the smallest global index. Useful for assigning one player to "own" some kind of functionality or object + ### Lua Example `local NetworkPlayerValue = get_network_player_smallest_global()` @@ -5807,6 +5834,9 @@ Clears the mod's data from mod storage ## [network_player_set_override_palette_color](#network_player_set_override_palette_color) +### Description +Sets the `part in `np`'s override color palette` + ### Lua Example `network_player_set_override_palette_color(np, part, color)` @@ -5829,6 +5859,9 @@ Clears the mod's data from mod storage ## [network_player_reset_override_palette](#network_player_reset_override_palette) +### Description +Resets `np`'s override color palette + ### Lua Example `network_player_reset_override_palette(np)` @@ -5849,6 +5882,9 @@ Clears the mod's data from mod storage ## [network_player_is_override_palette_same](#network_player_is_override_palette_same) +### Description +Checks if `np`'s override color palette is identical to the regular color palette + ### Lua Example `local booleanValue = network_player_is_override_palette_same(np)` @@ -6026,818 +6062,6 @@ Gets a Discord ID corresponding to the network player with `localIndex` [:arrow_up_small:](#) -
- ---- -# functions from obj_behaviors.c - -
- - -## [set_yoshi_as_not_dead](#set_yoshi_as_not_dead) - -### Lua Example -`set_yoshi_as_not_dead()` - -### Parameters -- None - -### Returns -- None - -### C Prototype -`void set_yoshi_as_not_dead(void);` - -[:arrow_up_small:](#) - -
- -## [absf_2](#absf_2) - -### Lua Example -`local numberValue = absf_2(f)` - -### Parameters -| Field | Type | -| ----- | ---- | -| f | `number` | - -### Returns -- `number` - -### C Prototype -`f32 absf_2(f32 f);` - -[:arrow_up_small:](#) - -
- -## [turn_obj_away_from_surface](#turn_obj_away_from_surface) - -### Lua Example -`turn_obj_away_from_surface(velX, velZ, nX, nY, nZ, objYawX, objYawZ)` - -### Parameters -| Field | Type | -| ----- | ---- | -| velX | `number` | -| velZ | `number` | -| nX | `number` | -| nY | `number` | -| nZ | `number` | -| objYawX | `Pointer` <`number`> | -| objYawZ | `Pointer` <`number`> | - -### Returns -- None - -### C Prototype -`void turn_obj_away_from_surface(f32 velX, f32 velZ, f32 nX, UNUSED f32 nY, f32 nZ, f32 *objYawX, f32 *objYawZ);` - -[:arrow_up_small:](#) - -
- -## [obj_find_wall](#obj_find_wall) - -### Lua Example -`local integerValue = obj_find_wall(objNewX, objY, objNewZ, objVelX, objVelZ)` - -### Parameters -| Field | Type | -| ----- | ---- | -| objNewX | `number` | -| objY | `number` | -| objNewZ | `number` | -| objVelX | `number` | -| objVelZ | `number` | - -### Returns -- `integer` - -### C Prototype -`s8 obj_find_wall(f32 objNewX, f32 objY, f32 objNewZ, f32 objVelX, f32 objVelZ);` - -[:arrow_up_small:](#) - -
- -## [turn_obj_away_from_steep_floor](#turn_obj_away_from_steep_floor) - -### Lua Example -`local integerValue = turn_obj_away_from_steep_floor(objFloor, floorY, objVelX, objVelZ)` - -### Parameters -| Field | Type | -| ----- | ---- | -| objFloor | [Surface](structs.md#Surface) | -| floorY | `number` | -| objVelX | `number` | -| objVelZ | `number` | - -### Returns -- `integer` - -### C Prototype -`s8 turn_obj_away_from_steep_floor(struct Surface *objFloor, f32 floorY, f32 objVelX, f32 objVelZ);` - -[:arrow_up_small:](#) - -
- -## [obj_orient_graph](#obj_orient_graph) - -### Lua Example -`obj_orient_graph(obj, normalX, normalY, normalZ)` - -### Parameters -| Field | Type | -| ----- | ---- | -| obj | [Object](structs.md#Object) | -| normalX | `number` | -| normalY | `number` | -| normalZ | `number` | - -### Returns -- None - -### C Prototype -`void obj_orient_graph(struct Object *obj, f32 normalX, f32 normalY, f32 normalZ);` - -[:arrow_up_small:](#) - -
- -## [calc_obj_friction](#calc_obj_friction) - -### Lua Example -`calc_obj_friction(objFriction, floor_nY)` - -### Parameters -| Field | Type | -| ----- | ---- | -| objFriction | `Pointer` <`number`> | -| floor_nY | `number` | - -### Returns -- None - -### C Prototype -`void calc_obj_friction(f32 *objFriction, f32 floor_nY);` - -[:arrow_up_small:](#) - -
- -## [calc_new_obj_vel_and_pos_y](#calc_new_obj_vel_and_pos_y) - -### Lua Example -`calc_new_obj_vel_and_pos_y(objFloor, objFloorY, objVelX, objVelZ)` - -### Parameters -| Field | Type | -| ----- | ---- | -| objFloor | [Surface](structs.md#Surface) | -| objFloorY | `number` | -| objVelX | `number` | -| objVelZ | `number` | - -### Returns -- None - -### C Prototype -`void calc_new_obj_vel_and_pos_y(struct Surface *objFloor, f32 objFloorY, f32 objVelX, f32 objVelZ);` - -[:arrow_up_small:](#) - -
- -## [calc_new_obj_vel_and_pos_y_underwater](#calc_new_obj_vel_and_pos_y_underwater) - -### Lua Example -`calc_new_obj_vel_and_pos_y_underwater(objFloor, floorY, objVelX, objVelZ, waterY)` - -### Parameters -| Field | Type | -| ----- | ---- | -| objFloor | [Surface](structs.md#Surface) | -| floorY | `number` | -| objVelX | `number` | -| objVelZ | `number` | -| waterY | `number` | - -### Returns -- None - -### C Prototype -`void calc_new_obj_vel_and_pos_y_underwater(struct Surface *objFloor, f32 floorY, f32 objVelX, f32 objVelZ, f32 waterY);` - -[:arrow_up_small:](#) - -
- -## [obj_update_pos_vel_xz](#obj_update_pos_vel_xz) - -### Lua Example -`obj_update_pos_vel_xz()` - -### Parameters -- None - -### Returns -- None - -### C Prototype -`void obj_update_pos_vel_xz(void);` - -[:arrow_up_small:](#) - -
- -## [obj_splash](#obj_splash) - -### Lua Example -`obj_splash(waterY, objY)` - -### Parameters -| Field | Type | -| ----- | ---- | -| waterY | `integer` | -| objY | `integer` | - -### Returns -- None - -### C Prototype -`void obj_splash(s32 waterY, s32 objY);` - -[:arrow_up_small:](#) - -
- -## [object_step](#object_step) - -### Lua Example -`local integerValue = object_step()` - -### Parameters -- None - -### Returns -- `integer` - -### C Prototype -`s16 object_step(void);` - -[:arrow_up_small:](#) - -
- -## [object_step_without_floor_orient](#object_step_without_floor_orient) - -### Lua Example -`local integerValue = object_step_without_floor_orient()` - -### Parameters -- None - -### Returns -- `integer` - -### C Prototype -`s16 object_step_without_floor_orient(void);` - -[:arrow_up_small:](#) - -
- -## [obj_move_xyz_using_fvel_and_yaw](#obj_move_xyz_using_fvel_and_yaw) - -### Lua Example -`obj_move_xyz_using_fvel_and_yaw(obj)` - -### Parameters -| Field | Type | -| ----- | ---- | -| obj | [Object](structs.md#Object) | - -### Returns -- None - -### C Prototype -`void obj_move_xyz_using_fvel_and_yaw(struct Object *obj);` - -[:arrow_up_small:](#) - -
- -## [is_point_within_radius_of_mario](#is_point_within_radius_of_mario) - -### Lua Example -`local integerValue = is_point_within_radius_of_mario(x, y, z, dist)` - -### Parameters -| Field | Type | -| ----- | ---- | -| x | `number` | -| y | `number` | -| z | `number` | -| dist | `integer` | - -### Returns -- `integer` - -### C Prototype -`s8 is_point_within_radius_of_mario(f32 x, f32 y, f32 z, s32 dist);` - -[:arrow_up_small:](#) - -
- -## [is_point_within_radius_of_any_player](#is_point_within_radius_of_any_player) - -### Lua Example -`local integerValue = is_point_within_radius_of_any_player(x, y, z, dist)` - -### Parameters -| Field | Type | -| ----- | ---- | -| x | `number` | -| y | `number` | -| z | `number` | -| dist | `integer` | - -### Returns -- `integer` - -### C Prototype -`s8 is_point_within_radius_of_any_player(f32 x, f32 y, f32 z, s32 dist);` - -[:arrow_up_small:](#) - -
- -## [is_player_active](#is_player_active) - -### Lua Example -`local integerValue = is_player_active(m)` - -### Parameters -| Field | Type | -| ----- | ---- | -| m | [MarioState](structs.md#MarioState) | - -### Returns -- `integer` - -### C Prototype -`u8 is_player_active(struct MarioState* m);` - -[:arrow_up_small:](#) - -
- -## [is_other_player_active](#is_other_player_active) - -### Lua Example -`local integerValue = is_other_player_active()` - -### Parameters -- None - -### Returns -- `integer` - -### C Prototype -`u8 is_other_player_active(void);` - -[:arrow_up_small:](#) - -
- -## [is_player_in_local_area](#is_player_in_local_area) - -### Lua Example -`local integerValue = is_player_in_local_area(m)` - -### Parameters -| Field | Type | -| ----- | ---- | -| m | [MarioState](structs.md#MarioState) | - -### Returns -- `integer` - -### C Prototype -`u8 is_player_in_local_area(struct MarioState* m);` - -[:arrow_up_small:](#) - -
- -## [nearest_mario_state_to_object](#nearest_mario_state_to_object) - -### Lua Example -`local MarioStateValue = nearest_mario_state_to_object(obj)` - -### Parameters -| Field | Type | -| ----- | ---- | -| obj | [Object](structs.md#Object) | - -### Returns -[MarioState](structs.md#MarioState) - -### C Prototype -`struct MarioState* nearest_mario_state_to_object(struct Object *obj);` - -[:arrow_up_small:](#) - -
- -## [nearest_possible_mario_state_to_object](#nearest_possible_mario_state_to_object) - -### Lua Example -`local MarioStateValue = nearest_possible_mario_state_to_object(obj)` - -### Parameters -| Field | Type | -| ----- | ---- | -| obj | [Object](structs.md#Object) | - -### Returns -[MarioState](structs.md#MarioState) - -### C Prototype -`struct MarioState* nearest_possible_mario_state_to_object(struct Object *obj);` - -[:arrow_up_small:](#) - -
- -## [nearest_player_to_object](#nearest_player_to_object) - -### Lua Example -`local ObjectValue = nearest_player_to_object(obj)` - -### Parameters -| Field | Type | -| ----- | ---- | -| obj | [Object](structs.md#Object) | - -### Returns -[Object](structs.md#Object) - -### C Prototype -`struct Object* nearest_player_to_object(struct Object *obj);` - -[:arrow_up_small:](#) - -
- -## [nearest_interacting_mario_state_to_object](#nearest_interacting_mario_state_to_object) - -### Lua Example -`local MarioStateValue = nearest_interacting_mario_state_to_object(obj)` - -### Parameters -| Field | Type | -| ----- | ---- | -| obj | [Object](structs.md#Object) | - -### Returns -[MarioState](structs.md#MarioState) - -### C Prototype -`struct MarioState *nearest_interacting_mario_state_to_object(struct Object *obj);` - -[:arrow_up_small:](#) - -
- -## [nearest_interacting_player_to_object](#nearest_interacting_player_to_object) - -### Lua Example -`local ObjectValue = nearest_interacting_player_to_object(obj)` - -### Parameters -| Field | Type | -| ----- | ---- | -| obj | [Object](structs.md#Object) | - -### Returns -[Object](structs.md#Object) - -### C Prototype -`struct Object *nearest_interacting_player_to_object(struct Object *obj);` - -[:arrow_up_small:](#) - -
- -## [is_nearest_mario_state_to_object](#is_nearest_mario_state_to_object) - -### Lua Example -`local integerValue = is_nearest_mario_state_to_object(m, obj)` - -### Parameters -| Field | Type | -| ----- | ---- | -| m | [MarioState](structs.md#MarioState) | -| obj | [Object](structs.md#Object) | - -### Returns -- `integer` - -### C Prototype -`u8 is_nearest_mario_state_to_object(struct MarioState *m, struct Object *obj);` - -[:arrow_up_small:](#) - -
- -## [is_nearest_player_to_object](#is_nearest_player_to_object) - -### Lua Example -`local integerValue = is_nearest_player_to_object(m, obj)` - -### Parameters -| Field | Type | -| ----- | ---- | -| m | [Object](structs.md#Object) | -| obj | [Object](structs.md#Object) | - -### Returns -- `integer` - -### C Prototype -`u8 is_nearest_player_to_object(struct Object *m, struct Object *obj);` - -[:arrow_up_small:](#) - -
- -## [is_point_close_to_object](#is_point_close_to_object) - -### Lua Example -`local integerValue = is_point_close_to_object(obj, x, y, z, dist)` - -### Parameters -| Field | Type | -| ----- | ---- | -| obj | [Object](structs.md#Object) | -| x | `number` | -| y | `number` | -| z | `number` | -| dist | `integer` | - -### Returns -- `integer` - -### C Prototype -`s8 is_point_close_to_object(struct Object *obj, f32 x, f32 y, f32 z, s32 dist);` - -[:arrow_up_small:](#) - -
- -## [set_object_visibility](#set_object_visibility) - -### Lua Example -`set_object_visibility(obj, dist)` - -### Parameters -| Field | Type | -| ----- | ---- | -| obj | [Object](structs.md#Object) | -| dist | `integer` | - -### Returns -- None - -### C Prototype -`void set_object_visibility(struct Object *obj, s32 dist);` - -[:arrow_up_small:](#) - -
- -## [obj_return_home_if_safe](#obj_return_home_if_safe) - -### Lua Example -`local integerValue = obj_return_home_if_safe(obj, homeX, y, homeZ, dist)` - -### Parameters -| Field | Type | -| ----- | ---- | -| obj | [Object](structs.md#Object) | -| homeX | `number` | -| y | `number` | -| homeZ | `number` | -| dist | `integer` | - -### Returns -- `integer` - -### C Prototype -`s8 obj_return_home_if_safe(struct Object *obj, f32 homeX, f32 y, f32 homeZ, s32 dist);` - -[:arrow_up_small:](#) - -
- -## [obj_return_and_displace_home](#obj_return_and_displace_home) - -### Lua Example -`obj_return_and_displace_home(obj, homeX, homeY, homeZ, baseDisp)` - -### Parameters -| Field | Type | -| ----- | ---- | -| obj | [Object](structs.md#Object) | -| homeX | `number` | -| homeY | `number` | -| homeZ | `number` | -| baseDisp | `integer` | - -### Returns -- None - -### C Prototype -`void obj_return_and_displace_home(struct Object *obj, f32 homeX, UNUSED f32 homeY, f32 homeZ, s32 baseDisp);` - -[:arrow_up_small:](#) - -
- -## [obj_check_if_facing_toward_angle](#obj_check_if_facing_toward_angle) - -### Lua Example -`local integerValue = obj_check_if_facing_toward_angle(base, goal, range)` - -### Parameters -| Field | Type | -| ----- | ---- | -| base | `integer` | -| goal | `integer` | -| range | `integer` | - -### Returns -- `integer` - -### C Prototype -`s8 obj_check_if_facing_toward_angle(u32 base, u32 goal, s16 range);` - -[:arrow_up_small:](#) - -
- -## [obj_find_wall_displacement](#obj_find_wall_displacement) - -### Lua Example -`local integerValue = obj_find_wall_displacement(dist, x, y, z, radius)` - -### Parameters -| Field | Type | -| ----- | ---- | -| dist | [Vec3f](structs.md#Vec3f) | -| x | `number` | -| y | `number` | -| z | `number` | -| radius | `number` | - -### Returns -- `integer` - -### C Prototype -`s8 obj_find_wall_displacement(Vec3f dist, f32 x, f32 y, f32 z, f32 radius);` - -[:arrow_up_small:](#) - -
- -## [obj_spawn_yellow_coins](#obj_spawn_yellow_coins) - -### Lua Example -`obj_spawn_yellow_coins(obj, nCoins)` - -### Parameters -| Field | Type | -| ----- | ---- | -| obj | [Object](structs.md#Object) | -| nCoins | `integer` | - -### Returns -- None - -### C Prototype -`void obj_spawn_yellow_coins(struct Object *obj, s8 nCoins);` - -[:arrow_up_small:](#) - -
- -## [obj_flicker_and_disappear](#obj_flicker_and_disappear) - -### Lua Example -`local integerValue = obj_flicker_and_disappear(obj, lifeSpan)` - -### Parameters -| Field | Type | -| ----- | ---- | -| obj | [Object](structs.md#Object) | -| lifeSpan | `integer` | - -### Returns -- `integer` - -### C Prototype -`s8 obj_flicker_and_disappear(struct Object *obj, s16 lifeSpan);` - -[:arrow_up_small:](#) - -
- -## [current_mario_room_check](#current_mario_room_check) - -### Lua Example -`local integerValue = current_mario_room_check(room)` - -### Parameters -| Field | Type | -| ----- | ---- | -| room | `integer` | - -### Returns -- `integer` - -### C Prototype -`s8 current_mario_room_check(s16 room);` - -[:arrow_up_small:](#) - -
- -## [obj_check_floor_death](#obj_check_floor_death) - -### Lua Example -`obj_check_floor_death(collisionFlags, floor)` - -### Parameters -| Field | Type | -| ----- | ---- | -| collisionFlags | `integer` | -| floor | [Surface](structs.md#Surface) | - -### Returns -- None - -### C Prototype -`void obj_check_floor_death(s16 collisionFlags, struct Surface *floor);` - -[:arrow_up_small:](#) - -
- -## [obj_lava_death](#obj_lava_death) - -### Lua Example -`local integerValue = obj_lava_death()` - -### Parameters -- None - -### Returns -- `integer` - -### C Prototype -`s8 obj_lava_death(void);` - -[:arrow_up_small:](#) - -
- -## [spawn_orange_number](#spawn_orange_number) - -### Lua Example -`spawn_orange_number(behParam, relX, relY, relZ)` - -### Parameters -| Field | Type | -| ----- | ---- | -| behParam | `integer` | -| relX | `integer` | -| relY | `integer` | -| relZ | `integer` | - -### Returns -- None - -### C Prototype -`void spawn_orange_number(s8 behParam, s16 relX, s16 relY, s16 relZ);` - -[:arrow_up_small:](#) -
--- diff --git a/docs/lua/functions-5.md b/docs/lua/functions-5.md index b5984d849..dfa54f2d3 100644 --- a/docs/lua/functions-5.md +++ b/docs/lua/functions-5.md @@ -5,6 +5,903 @@ [< prev](functions-4.md) | [1](functions.md) | [2](functions-2.md) | [3](functions-3.md) | [4](functions-4.md) | 5 | [6](functions-6.md) | [next >](functions-6.md)] +--- +# functions from obj_behaviors.c + +
+ + +## [set_yoshi_as_not_dead](#set_yoshi_as_not_dead) + +### Description +Resets Yoshi as being alive + +### Lua Example +`set_yoshi_as_not_dead()` + +### Parameters +- None + +### Returns +- None + +### C Prototype +`void set_yoshi_as_not_dead(void);` + +[:arrow_up_small:](#) + +
+ +## [absf_2](#absf_2) + +### Description +An absolute value (always positive) function. + +### Lua Example +`local numberValue = absf_2(f)` + +### Parameters +| Field | Type | +| ----- | ---- | +| f | `number` | + +### Returns +- `number` + +### C Prototype +`f32 absf_2(f32 f);` + +[:arrow_up_small:](#) + +
+ +## [obj_find_wall](#obj_find_wall) + +### Description +Finds any wall collisions, applies them, and turns away from the surface. + +### Lua Example +`local integerValue = obj_find_wall(objNewX, objY, objNewZ, objVelX, objVelZ)` + +### Parameters +| Field | Type | +| ----- | ---- | +| objNewX | `number` | +| objY | `number` | +| objNewZ | `number` | +| objVelX | `number` | +| objVelZ | `number` | + +### Returns +- `integer` + +### C Prototype +`s8 obj_find_wall(f32 objNewX, f32 objY, f32 objNewZ, f32 objVelX, f32 objVelZ);` + +[:arrow_up_small:](#) + +
+ +## [turn_obj_away_from_steep_floor](#turn_obj_away_from_steep_floor) + +### Description +Turns an object away from steep floors, similarly to walls. + +### Lua Example +`local integerValue = turn_obj_away_from_steep_floor(objFloor, floorY, objVelX, objVelZ)` + +### Parameters +| Field | Type | +| ----- | ---- | +| objFloor | [Surface](structs.md#Surface) | +| floorY | `number` | +| objVelX | `number` | +| objVelZ | `number` | + +### Returns +- `integer` + +### C Prototype +`s8 turn_obj_away_from_steep_floor(struct Surface *objFloor, f32 floorY, f32 objVelX, f32 objVelZ);` + +[:arrow_up_small:](#) + +
+ +## [obj_orient_graph](#obj_orient_graph) + +### Description +Orients an object with the given normals, typically the surface under the object. + +### Lua Example +`obj_orient_graph(obj, normalX, normalY, normalZ)` + +### Parameters +| Field | Type | +| ----- | ---- | +| obj | [Object](structs.md#Object) | +| normalX | `number` | +| normalY | `number` | +| normalZ | `number` | + +### Returns +- None + +### C Prototype +`void obj_orient_graph(struct Object *obj, f32 normalX, f32 normalY, f32 normalZ);` + +[:arrow_up_small:](#) + +
+ +## [calc_obj_friction](#calc_obj_friction) + +### Description +Orients an object with the given normals, typically the surface under the object. + +### Lua Example +`calc_obj_friction(objFriction, floor_nY)` + +### Parameters +| Field | Type | +| ----- | ---- | +| objFriction | `Pointer` <`number`> | +| floor_nY | `number` | + +### Returns +- None + +### C Prototype +`void calc_obj_friction(f32 *objFriction, f32 floor_nY);` + +[:arrow_up_small:](#) + +
+ +## [calc_new_obj_vel_and_pos_y](#calc_new_obj_vel_and_pos_y) + +### Description +Updates an objects speed for gravity and updates Y position. + +### Lua Example +`calc_new_obj_vel_and_pos_y(objFloor, objFloorY, objVelX, objVelZ)` + +### Parameters +| Field | Type | +| ----- | ---- | +| objFloor | [Surface](structs.md#Surface) | +| objFloorY | `number` | +| objVelX | `number` | +| objVelZ | `number` | + +### Returns +- None + +### C Prototype +`void calc_new_obj_vel_and_pos_y(struct Surface *objFloor, f32 objFloorY, f32 objVelX, f32 objVelZ);` + +[:arrow_up_small:](#) + +
+ +## [calc_new_obj_vel_and_pos_y_underwater](#calc_new_obj_vel_and_pos_y_underwater) + +### Description +Adjusts the current object's veloicty and y position for being underwater + +### Lua Example +`calc_new_obj_vel_and_pos_y_underwater(objFloor, floorY, objVelX, objVelZ, waterY)` + +### Parameters +| Field | Type | +| ----- | ---- | +| objFloor | [Surface](structs.md#Surface) | +| floorY | `number` | +| objVelX | `number` | +| objVelZ | `number` | +| waterY | `number` | + +### Returns +- None + +### C Prototype +`void calc_new_obj_vel_and_pos_y_underwater(struct Surface *objFloor, f32 floorY, f32 objVelX, f32 objVelZ, f32 waterY);` + +[:arrow_up_small:](#) + +
+ +## [obj_update_pos_vel_xz](#obj_update_pos_vel_xz) + +### Description +Updates an objects position from oForwardVel and oMoveAngleYaw. + +### Lua Example +`obj_update_pos_vel_xz()` + +### Parameters +- None + +### Returns +- None + +### C Prototype +`void obj_update_pos_vel_xz(void);` + +[:arrow_up_small:](#) + +
+ +## [obj_splash](#obj_splash) + +### Description +Generates splashes if at surface of water, entering water, or bubbles if underwater + +### Lua Example +`obj_splash(waterY, objY)` + +### Parameters +| Field | Type | +| ----- | ---- | +| waterY | `integer` | +| objY | `integer` | + +### Returns +- None + +### C Prototype +`void obj_splash(s32 waterY, s32 objY);` + +[:arrow_up_small:](#) + +
+ +## [object_step](#object_step) + +### Description +Generic object move function. Handles walls, water, floors, and gravity. Returns flags for certain interactions + +### Lua Example +`local integerValue = object_step()` + +### Parameters +- None + +### Returns +- `integer` + +### C Prototype +`s16 object_step(void);` + +[:arrow_up_small:](#) + +
+ +## [object_step_without_floor_orient](#object_step_without_floor_orient) + +### Description +Takes an object step but does not orient with the object's floor. Used for boulders, falling pillars, and the rolling snowman body + +### Lua Example +`local integerValue = object_step_without_floor_orient()` + +### Parameters +- None + +### Returns +- `integer` + +### C Prototype +`s16 object_step_without_floor_orient(void);` + +[:arrow_up_small:](#) + +
+ +## [obj_move_xyz_using_fvel_and_yaw](#obj_move_xyz_using_fvel_and_yaw) + +### Description +Don't use this function outside of of a context where the current object and `obj` are the same. Moves `obj` based on a seemingly random mix of using either the current obj or `obj`'s fields + +### Lua Example +`obj_move_xyz_using_fvel_and_yaw(obj)` + +### Parameters +| Field | Type | +| ----- | ---- | +| obj | [Object](structs.md#Object) | + +### Returns +- None + +### C Prototype +`void obj_move_xyz_using_fvel_and_yaw(struct Object *obj);` + +[:arrow_up_small:](#) + +
+ +## [is_point_within_radius_of_mario](#is_point_within_radius_of_mario) + +### Description +Checks if a point is within distance from any active Mario visible to enemies' graphical position + +### Lua Example +`local integerValue = is_point_within_radius_of_mario(x, y, z, dist)` + +### Parameters +| Field | Type | +| ----- | ---- | +| x | `number` | +| y | `number` | +| z | `number` | +| dist | `integer` | + +### Returns +- `integer` + +### C Prototype +`s8 is_point_within_radius_of_mario(f32 x, f32 y, f32 z, s32 dist);` + +[:arrow_up_small:](#) + +
+ +## [is_point_within_radius_of_any_player](#is_point_within_radius_of_any_player) + +### Description +Checks if a point is within distance from any active Mario's graphical position + +### Lua Example +`local integerValue = is_point_within_radius_of_any_player(x, y, z, dist)` + +### Parameters +| Field | Type | +| ----- | ---- | +| x | `number` | +| y | `number` | +| z | `number` | +| dist | `integer` | + +### Returns +- `integer` + +### C Prototype +`s8 is_point_within_radius_of_any_player(f32 x, f32 y, f32 z, s32 dist);` + +[:arrow_up_small:](#) + +
+ +## [is_player_active](#is_player_active) + +### Description +Checks if `m` is in the current course/act/level/area and isn't bubbled + +### Lua Example +`local integerValue = is_player_active(m)` + +### Parameters +| Field | Type | +| ----- | ---- | +| m | [MarioState](structs.md#MarioState) | + +### Returns +- `integer` + +### C Prototype +`u8 is_player_active(struct MarioState* m);` + +[:arrow_up_small:](#) + +
+ +## [is_other_player_active](#is_other_player_active) + +### Description +Checks if any player besides the local player is in the current course/act/level/area + +### Lua Example +`local integerValue = is_other_player_active()` + +### Parameters +- None + +### Returns +- `integer` + +### C Prototype +`u8 is_other_player_active(void);` + +[:arrow_up_small:](#) + +
+ +## [is_player_in_local_area](#is_player_in_local_area) + +### Description +Checks if `m` is in the current course/act/level/area + +### Lua Example +`local integerValue = is_player_in_local_area(m)` + +### Parameters +| Field | Type | +| ----- | ---- | +| m | [MarioState](structs.md#MarioState) | + +### Returns +- `integer` + +### C Prototype +`u8 is_player_in_local_area(struct MarioState* m);` + +[:arrow_up_small:](#) + +
+ +## [nearest_mario_state_to_object](#nearest_mario_state_to_object) + +### Description +Gets the nearest active Mario who isn't bubbled to `obj` + +### Lua Example +`local MarioStateValue = nearest_mario_state_to_object(obj)` + +### Parameters +| Field | Type | +| ----- | ---- | +| obj | [Object](structs.md#Object) | + +### Returns +[MarioState](structs.md#MarioState) + +### C Prototype +`struct MarioState* nearest_mario_state_to_object(struct Object *obj);` + +[:arrow_up_small:](#) + +
+ +## [nearest_possible_mario_state_to_object](#nearest_possible_mario_state_to_object) + +### Description +Gets the nearest possible Mario to `obj` despite anything like bubbled state or enemy visibility + +### Lua Example +`local MarioStateValue = nearest_possible_mario_state_to_object(obj)` + +### Parameters +| Field | Type | +| ----- | ---- | +| obj | [Object](structs.md#Object) | + +### Returns +[MarioState](structs.md#MarioState) + +### C Prototype +`struct MarioState* nearest_possible_mario_state_to_object(struct Object *obj);` + +[:arrow_up_small:](#) + +
+ +## [nearest_player_to_object](#nearest_player_to_object) + +### Description +Gets the nearest player (Mario Object) to `obj` + +### Lua Example +`local ObjectValue = nearest_player_to_object(obj)` + +### Parameters +| Field | Type | +| ----- | ---- | +| obj | [Object](structs.md#Object) | + +### Returns +[Object](structs.md#Object) + +### C Prototype +`struct Object* nearest_player_to_object(struct Object *obj);` + +[:arrow_up_small:](#) + +
+ +## [nearest_interacting_mario_state_to_object](#nearest_interacting_mario_state_to_object) + +### Description +Gets the nearest interacting Mario to `obj` + +### Lua Example +`local MarioStateValue = nearest_interacting_mario_state_to_object(obj)` + +### Parameters +| Field | Type | +| ----- | ---- | +| obj | [Object](structs.md#Object) | + +### Returns +[MarioState](structs.md#MarioState) + +### C Prototype +`struct MarioState *nearest_interacting_mario_state_to_object(struct Object *obj);` + +[:arrow_up_small:](#) + +
+ +## [nearest_interacting_player_to_object](#nearest_interacting_player_to_object) + +### Description +Gets the nearest interacting player (Mario Object) to `obj` + +### Lua Example +`local ObjectValue = nearest_interacting_player_to_object(obj)` + +### Parameters +| Field | Type | +| ----- | ---- | +| obj | [Object](structs.md#Object) | + +### Returns +[Object](structs.md#Object) + +### C Prototype +`struct Object *nearest_interacting_player_to_object(struct Object *obj);` + +[:arrow_up_small:](#) + +
+ +## [is_nearest_mario_state_to_object](#is_nearest_mario_state_to_object) + +### Description +Checks if `m` is the nearest Mario to `obj` + +### Lua Example +`local integerValue = is_nearest_mario_state_to_object(m, obj)` + +### Parameters +| Field | Type | +| ----- | ---- | +| m | [MarioState](structs.md#MarioState) | +| obj | [Object](structs.md#Object) | + +### Returns +- `integer` + +### C Prototype +`u8 is_nearest_mario_state_to_object(struct MarioState *m, struct Object *obj);` + +[:arrow_up_small:](#) + +
+ +## [is_nearest_player_to_object](#is_nearest_player_to_object) + +### Description +Checks if `m` is the nearest player (Mario Object) to `obj` + +### Lua Example +`local integerValue = is_nearest_player_to_object(m, obj)` + +### Parameters +| Field | Type | +| ----- | ---- | +| m | [Object](structs.md#Object) | +| obj | [Object](structs.md#Object) | + +### Returns +- `integer` + +### C Prototype +`u8 is_nearest_player_to_object(struct Object *m, struct Object *obj);` + +[:arrow_up_small:](#) + +
+ +## [is_point_close_to_object](#is_point_close_to_object) + +### Description +Checks if a point is within `dist` of `obj` + +### Lua Example +`local integerValue = is_point_close_to_object(obj, x, y, z, dist)` + +### Parameters +| Field | Type | +| ----- | ---- | +| obj | [Object](structs.md#Object) | +| x | `number` | +| y | `number` | +| z | `number` | +| dist | `integer` | + +### Returns +- `integer` + +### C Prototype +`s8 is_point_close_to_object(struct Object *obj, f32 x, f32 y, f32 z, s32 dist);` + +[:arrow_up_small:](#) + +
+ +## [set_object_visibility](#set_object_visibility) + +### Description +Sets an object as visible if within a certain distance of Mario's graphical position + +### Lua Example +`set_object_visibility(obj, dist)` + +### Parameters +| Field | Type | +| ----- | ---- | +| obj | [Object](structs.md#Object) | +| dist | `integer` | + +### Returns +- None + +### C Prototype +`void set_object_visibility(struct Object *obj, s32 dist);` + +[:arrow_up_small:](#) + +
+ +## [obj_return_home_if_safe](#obj_return_home_if_safe) + +### Description +Turns an object towards home if Mario is not near to it + +### Lua Example +`local integerValue = obj_return_home_if_safe(obj, homeX, y, homeZ, dist)` + +### Parameters +| Field | Type | +| ----- | ---- | +| obj | [Object](structs.md#Object) | +| homeX | `number` | +| y | `number` | +| homeZ | `number` | +| dist | `integer` | + +### Returns +- `integer` + +### C Prototype +`s8 obj_return_home_if_safe(struct Object *obj, f32 homeX, f32 y, f32 homeZ, s32 dist);` + +[:arrow_up_small:](#) + +
+ +## [obj_return_and_displace_home](#obj_return_and_displace_home) + +### Description +Randomly displaces an objects home if RNG says to, and turns the object towards its home + +### Lua Example +`obj_return_and_displace_home(obj, homeX, homeY, homeZ, baseDisp)` + +### Parameters +| Field | Type | +| ----- | ---- | +| obj | [Object](structs.md#Object) | +| homeX | `number` | +| homeY | `number` | +| homeZ | `number` | +| baseDisp | `integer` | + +### Returns +- None + +### C Prototype +`void obj_return_and_displace_home(struct Object *obj, f32 homeX, UNUSED f32 homeY, f32 homeZ, s32 baseDisp);` + +[:arrow_up_small:](#) + +
+ +## [obj_check_if_facing_toward_angle](#obj_check_if_facing_toward_angle) + +### Description +A series of checks using sin and cos to see if a given angle is facing in the same direction of a given angle, within a certain range + +### Lua Example +`local integerValue = obj_check_if_facing_toward_angle(base, goal, range)` + +### Parameters +| Field | Type | +| ----- | ---- | +| base | `integer` | +| goal | `integer` | +| range | `integer` | + +### Returns +- `integer` + +### C Prototype +`s8 obj_check_if_facing_toward_angle(u32 base, u32 goal, s16 range);` + +[:arrow_up_small:](#) + +
+ +## [obj_find_wall_displacement](#obj_find_wall_displacement) + +### Description +Finds any wall collisions and returns what the displacement vector would be. + +### Lua Example +`local integerValue = obj_find_wall_displacement(dist, x, y, z, radius)` + +### Parameters +| Field | Type | +| ----- | ---- | +| dist | [Vec3f](structs.md#Vec3f) | +| x | `number` | +| y | `number` | +| z | `number` | +| radius | `number` | + +### Returns +- `integer` + +### C Prototype +`s8 obj_find_wall_displacement(Vec3f dist, f32 x, f32 y, f32 z, f32 radius);` + +[:arrow_up_small:](#) + +
+ +## [obj_spawn_yellow_coins](#obj_spawn_yellow_coins) + +### Description +Spawns a number of coins at the location of an object with a random forward velocity, y velocity, and direction + +### Lua Example +`obj_spawn_yellow_coins(obj, nCoins)` + +### Parameters +| Field | Type | +| ----- | ---- | +| obj | [Object](structs.md#Object) | +| nCoins | `integer` | + +### Returns +- None + +### C Prototype +`void obj_spawn_yellow_coins(struct Object *obj, s8 nCoins);` + +[:arrow_up_small:](#) + +
+ +## [obj_flicker_and_disappear](#obj_flicker_and_disappear) + +### Description +Controls whether certain objects should flicker/when to despawn + +### Lua Example +`local integerValue = obj_flicker_and_disappear(obj, lifeSpan)` + +### Parameters +| Field | Type | +| ----- | ---- | +| obj | [Object](structs.md#Object) | +| lifeSpan | `integer` | + +### Returns +- `integer` + +### C Prototype +`s8 obj_flicker_and_disappear(struct Object *obj, s16 lifeSpan);` + +[:arrow_up_small:](#) + +
+ +## [current_mario_room_check](#current_mario_room_check) + +### Description +Checks if a given room is Mario's current room, even if on an object + +### Lua Example +`local integerValue = current_mario_room_check(room)` + +### Parameters +| Field | Type | +| ----- | ---- | +| room | `integer` | + +### Returns +- `integer` + +### C Prototype +`s8 current_mario_room_check(s16 room);` + +[:arrow_up_small:](#) + +
+ +## [obj_check_floor_death](#obj_check_floor_death) + +### Description +Checks if `floor`'s type is burning or death plane and if so change the current object's action accordingly + +### Lua Example +`obj_check_floor_death(collisionFlags, floor)` + +### Parameters +| Field | Type | +| ----- | ---- | +| collisionFlags | `integer` | +| floor | [Surface](structs.md#Surface) | + +### Returns +- None + +### C Prototype +`void obj_check_floor_death(s16 collisionFlags, struct Surface *floor);` + +[:arrow_up_small:](#) + +
+ +## [obj_lava_death](#obj_lava_death) + +### Description +Controls an object dying in lava by creating smoke, sinking the object, playing audio, and eventually despawning it. Returns TRUE when the obj is dead + +### Lua Example +`local integerValue = obj_lava_death()` + +### Parameters +- None + +### Returns +- `integer` + +### C Prototype +`s8 obj_lava_death(void);` + +[:arrow_up_small:](#) + +
+ +## [spawn_orange_number](#spawn_orange_number) + +### Description +Spawns an orange number object relatively, such as those that count up for secrets. + +### Lua Example +`spawn_orange_number(behParam, relX, relY, relZ)` + +### Parameters +| Field | Type | +| ----- | ---- | +| behParam | `integer` | +| relX | `integer` | +| relY | `integer` | +| relZ | `integer` | + +### Returns +- None + +### C Prototype +`void spawn_orange_number(s8 behParam, s16 relX, s16 relY, s16 relZ);` + +[:arrow_up_small:](#) + +
+ --- # functions from obj_behaviors_2.c @@ -5473,6 +6370,9 @@ ## [cur_obj_set_home_once](#cur_obj_set_home_once) +### Description +Sets the current object's home only the first time it's called + ### Lua Example `cur_obj_set_home_once()` @@ -5491,6 +6391,9 @@ ## [get_trajectory_length](#get_trajectory_length) +### Description +Gets a trajectory's length + ### Lua Example `local integerValue = get_trajectory_length(trajectory)` @@ -6493,6 +7396,9 @@ Gets the name of the current animation playing on `obj`, returns `nil` if there' ## [smlua_audio_utils_reset_all](#smlua_audio_utils_reset_all) +### Description +Resets all custom sequences back to vanilla + ### Lua Example `smlua_audio_utils_reset_all()` @@ -6511,6 +7417,9 @@ Gets the name of the current animation playing on `obj`, returns `nil` if there' ## [smlua_audio_utils_replace_sequence](#smlua_audio_utils_replace_sequence) +### Description +Replaces the sequence corresponding to `sequenceId` with one called `m64Name`.m64 with `bankId` and `defaultVolume` + ### Lua Example `smlua_audio_utils_replace_sequence(sequenceId, bankId, defaultVolume, m64Name)` @@ -6652,7 +7561,7 @@ Stops an `audio` stream ## [audio_stream_get_position](#audio_stream_get_position) ### Description -Gets the position of an `audio` stream +Gets the position of an `audio` stream in seconds ### Lua Example `local numberValue = audio_stream_get_position(audio)` @@ -6675,7 +7584,7 @@ Gets the position of an `audio` stream ## [audio_stream_set_position](#audio_stream_set_position) ### Description -Sets the position of an `audio` stream +Sets the position of an `audio` stream in seconds ### Lua Example `audio_stream_set_position(audio, pos)` @@ -6746,7 +7655,7 @@ Sets if an `audio` stream is looping or not ## [audio_stream_set_loop_points](#audio_stream_set_loop_points) ### Description -Sets an `audio` stream's loop points (samples) +Sets an `audio` stream's loop points in samples ### Lua Example `audio_stream_set_loop_points(audio, loopStart, loopEnd)` @@ -6955,1332 +7864,6 @@ Plays an `audio` sample at `position` with `volume` [:arrow_up_small:](#)
- ---- -# functions from smlua_camera_utils.h - -
- - -## [camera_reset_overrides](#camera_reset_overrides) - -### Description -Resets camera config overrides - -### Lua Example -`camera_reset_overrides()` - -### Parameters -- None - -### Returns -- None - -### C Prototype -`void camera_reset_overrides(void);` - -[:arrow_up_small:](#) - -
- -## [camera_freeze](#camera_freeze) - -### Description -Freezes the camera by not updating it - -### Lua Example -`camera_freeze()` - -### Parameters -- None - -### Returns -- None - -### C Prototype -`void camera_freeze(void);` - -[:arrow_up_small:](#) - -
- -## [camera_unfreeze](#camera_unfreeze) - -### Description -Unfreezes the camera - -### Lua Example -`camera_unfreeze()` - -### Parameters -- None - -### Returns -- None - -### C Prototype -`void camera_unfreeze(void);` - -[:arrow_up_small:](#) - -
- -## [camera_is_frozen](#camera_is_frozen) - -### Description -Checks if the 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_romhack_allow_only_mods](#camera_romhack_allow_only_mods) - -### Description -Sets if only mods are allowed to modify the camera (Enabling prevents the player from modifying the camera through the settings) - -### Lua Example -`camera_romhack_allow_only_mods(allow)` - -### Parameters -| Field | Type | -| ----- | ---- | -| allow | `integer` | - -### Returns -- None - -### C Prototype -`void camera_romhack_allow_only_mods(u8 allow);` - -[:arrow_up_small:](#) - -
- -## [camera_set_romhack_override](#camera_set_romhack_override) - -### Description -Sets the romhack camera override status - -### Lua Example -`camera_set_romhack_override(rco)` - -### Parameters -| Field | Type | -| ----- | ---- | -| rco | [enum RomhackCameraOverride](constants.md#enum-RomhackCameraOverride) | - -### Returns -- None - -### C Prototype -`void camera_set_romhack_override(enum RomhackCameraOverride rco);` - -[:arrow_up_small:](#) - -
- -## [camera_romhack_allow_centering](#camera_romhack_allow_centering) - -### Description -Sets if the romhack camera should allow centering, triggered with the L button - -### Lua Example -`camera_romhack_allow_centering(allow)` - -### Parameters -| Field | Type | -| ----- | ---- | -| allow | `integer` | - -### Returns -- None - -### C Prototype -`void camera_romhack_allow_centering(u8 allow);` - -[:arrow_up_small:](#) - -
- -## [camera_allow_toxic_gas_camera](#camera_allow_toxic_gas_camera) - -### Description -Sets if the romhack camera should fly above poison gas - -### Lua Example -`camera_allow_toxic_gas_camera(allow)` - -### Parameters -| Field | Type | -| ----- | ---- | -| allow | `integer` | - -### Returns -- None - -### C Prototype -`void camera_allow_toxic_gas_camera(u8 allow);` - -[:arrow_up_small:](#) - -
- -## [camera_romhack_allow_dpad_usage](#camera_romhack_allow_dpad_usage) - -### Description -Sets if the romhack camera should allow D-Pad movement - -### Lua Example -`camera_romhack_allow_dpad_usage(allow)` - -### Parameters -| Field | Type | -| ----- | ---- | -| allow | `integer` | - -### Returns -- None - -### C Prototype -`void camera_romhack_allow_dpad_usage(u8 allow);` - -[:arrow_up_small:](#) - -
- -## [rom_hack_cam_set_collisions](#rom_hack_cam_set_collisions) - -### Description -Toggles collision settings for the ROM hack camera. This enables or disables specific collision behaviors in modded levels - -### Lua Example -`rom_hack_cam_set_collisions(enable)` - -### Parameters -| Field | Type | -| ----- | ---- | -| enable | `integer` | - -### Returns -- None - -### C Prototype -`void rom_hack_cam_set_collisions(u8 enable);` - -[:arrow_up_small:](#) - -
- -## [camera_romhack_set_zoomed_in_dist](#camera_romhack_set_zoomed_in_dist) - -### Description -Sets the romhack camera's zoomed in distance (Default: 900) - -### Lua Example -`camera_romhack_set_zoomed_in_dist(val)` - -### Parameters -| Field | Type | -| ----- | ---- | -| val | `integer` | - -### Returns -- None - -### C Prototype -`void camera_romhack_set_zoomed_in_dist(u32 val);` - -[:arrow_up_small:](#) - -
- -## [camera_romhack_set_zoomed_out_dist](#camera_romhack_set_zoomed_out_dist) - -### Description -Sets the romhack camera's zoomed out additional distance (Default: 500) - -### Lua Example -`camera_romhack_set_zoomed_out_dist(val)` - -### Parameters -| Field | Type | -| ----- | ---- | -| val | `integer` | - -### Returns -- None - -### C Prototype -`void camera_romhack_set_zoomed_out_dist(u32 val);` - -[:arrow_up_small:](#) - -
- -## [camera_romhack_set_zoomed_in_height](#camera_romhack_set_zoomed_in_height) - -### Description -Sets the romhack camera's zoomed in height (Default: 300) - -### Lua Example -`camera_romhack_set_zoomed_in_height(val)` - -### Parameters -| Field | Type | -| ----- | ---- | -| val | `integer` | - -### Returns -- None - -### C Prototype -`void camera_romhack_set_zoomed_in_height(u32 val);` - -[:arrow_up_small:](#) - -
- -## [camera_romhack_set_zoomed_out_height](#camera_romhack_set_zoomed_out_height) - -### Description -Sets the romhack camera's zoomed out additional height (Default: 150) - -### Lua Example -`camera_romhack_set_zoomed_out_height(val)` - -### Parameters -| Field | Type | -| ----- | ---- | -| val | `integer` | - -### Returns -- None - -### C Prototype -`void camera_romhack_set_zoomed_out_height(u32 val);` - -[:arrow_up_small:](#) - -
- -## [camera_romhack_get_zoomed_in_dist](#camera_romhack_get_zoomed_in_dist) - -### Description -Gets the romhack camera's zoomed in distance - -### Lua Example -`local integerValue = camera_romhack_get_zoomed_in_dist()` - -### Parameters -- None - -### Returns -- `integer` - -### C Prototype -`u32 camera_romhack_get_zoomed_in_dist(void);` - -[:arrow_up_small:](#) - -
- -## [camera_romhack_get_zoomed_out_dist](#camera_romhack_get_zoomed_out_dist) - -### Description -Gets the romhack camera's additional zoomed out distance - -### Lua Example -`local integerValue = camera_romhack_get_zoomed_out_dist()` - -### Parameters -- None - -### Returns -- `integer` - -### C Prototype -`u32 camera_romhack_get_zoomed_out_dist(void);` - -[:arrow_up_small:](#) - -
- -## [camera_romhack_get_zoomed_in_height](#camera_romhack_get_zoomed_in_height) - -### Description -Gets the romhack camera's zoomed in height - -### Lua Example -`local integerValue = camera_romhack_get_zoomed_in_height()` - -### Parameters -- None - -### Returns -- `integer` - -### C Prototype -`u32 camera_romhack_get_zoomed_in_height(void);` - -[:arrow_up_small:](#) - -
- -## [camera_romhack_get_zoomed_out_height](#camera_romhack_get_zoomed_out_height) - -### Description -Gets the romhack camera's additional zoomed out height - -### Lua Example -`local integerValue = camera_romhack_get_zoomed_out_height()` - -### Parameters -- None - -### Returns -- `integer` - -### C Prototype -`u32 camera_romhack_get_zoomed_out_height(void);` - -[:arrow_up_small:](#) - -
- -## [camera_get_romhack_override](#camera_get_romhack_override) - -### Description -Gets the current romhack camera override status - -### Lua Example -`local enumValue = camera_get_romhack_override()` - -### Parameters -- None - -### Returns -[enum RomhackCameraOverride](constants.md#enum-RomhackCameraOverride) - -### C Prototype -`enum RomhackCameraOverride camera_get_romhack_override(void);` - -[:arrow_up_small:](#) - -
- -## [camera_romhack_get_allow_centering](#camera_romhack_get_allow_centering) - -### Description -Gets if the romhack camera should allow centering - -### Lua Example -`local integerValue = camera_romhack_get_allow_centering()` - -### Parameters -- None - -### Returns -- `integer` - -### C Prototype -`u8 camera_romhack_get_allow_centering(void);` - -[:arrow_up_small:](#) - -
- -## [camera_get_allow_toxic_gas_camera](#camera_get_allow_toxic_gas_camera) - -### Description -Gets if the romhack camera should fly above poison gas - -### Lua Example -`local integerValue = camera_get_allow_toxic_gas_camera()` - -### Parameters -- None - -### Returns -- `integer` - -### C Prototype -`u8 camera_get_allow_toxic_gas_camera(void);` - -[:arrow_up_small:](#) - -
- -## [camera_romhack_get_allow_dpad_usage](#camera_romhack_get_allow_dpad_usage) - -### Description -Gets if the romhack camera should allow D-Pad movement - -### Lua Example -`local integerValue = camera_romhack_get_allow_dpad_usage()` - -### Parameters -- None - -### Returns -- `integer` - -### C Prototype -`u8 camera_romhack_get_allow_dpad_usage(void);` - -[:arrow_up_small:](#) - -
- -## [camera_romhack_get_collisions](#camera_romhack_get_collisions) - -### Description -Gets if the romhack camera has surface collisions - -### Lua Example -`local integerValue = camera_romhack_get_collisions()` - -### Parameters -- None - -### Returns -- `integer` - -### C Prototype -`u8 camera_romhack_get_collisions(void);` - -[:arrow_up_small:](#) - -
- -## [camera_config_is_free_cam_enabled](#camera_config_is_free_cam_enabled) - -### Description -Checks if Free Camera is 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_analog_cam_enabled](#camera_config_is_analog_cam_enabled) - -### Description -Checks if Analog Camera is 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_dpad_enabled](#camera_config_is_dpad_enabled) - -### Description -Checks if Freecam DPad Behavior is enabled - -### Lua Example -`local booleanValue = camera_config_is_dpad_enabled()` - -### Parameters -- None - -### Returns -- `boolean` - -### C Prototype -`bool camera_config_is_dpad_enabled(void);` - -[:arrow_up_small:](#) - -
- -## [camera_config_is_collision_enabled](#camera_config_is_collision_enabled) - -### Description -Checks if Camera Collision is enabled - -### Lua Example -`local booleanValue = camera_config_is_collision_enabled()` - -### Parameters -- None - -### Returns -- `boolean` - -### C Prototype -`bool camera_config_is_collision_enabled(void);` - -[:arrow_up_small:](#) - -
- -## [camera_config_is_mouse_look_enabled](#camera_config_is_mouse_look_enabled) - -### Description -Checks if Mouse Look is 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) - -### Description -Checks if camera X is 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) - -### Description -Checks if camera Y is 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_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_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_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_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_centering](#camera_config_get_centering) - -### Description -Gets if the L button will center the camera - -### Lua Example -`local booleanValue = camera_config_get_centering()` - -### Parameters -- None - -### Returns -- `boolean` - -### C Prototype -`bool camera_config_get_centering(void);` - -[:arrow_up_small:](#) - -
- -## [camera_config_enable_free_cam](#camera_config_enable_free_cam) - -### Description -Overrides if Free Camera is enabled - -### 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_analog_cam](#camera_config_enable_analog_cam) - -### Description -Overrides if Analog Camera is enabled - -### 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_centering](#camera_config_enable_centering) - -### Description -Overrides if the L button will center the camera - -### Lua Example -`camera_config_enable_centering(enable)` - -### Parameters -| Field | Type | -| ----- | ---- | -| enable | `boolean` | - -### Returns -- None - -### C Prototype -`void camera_config_enable_centering(bool enable);` - -[:arrow_up_small:](#) - -
- -## [camera_config_enable_dpad](#camera_config_enable_dpad) - -### Description -Overrides if Freecam DPad Behavior is enabled - -### Lua Example -`camera_config_enable_dpad(enable)` - -### Parameters -| Field | Type | -| ----- | ---- | -| enable | `boolean` | - -### Returns -- None - -### C Prototype -`void camera_config_enable_dpad(bool enable);` - -[:arrow_up_small:](#) - -
- -## [camera_config_enable_collisions](#camera_config_enable_collisions) - -### Description -Overrides if Camera Collision is enabled - -### Lua Example -`camera_config_enable_collisions(enable)` - -### Parameters -| Field | Type | -| ----- | ---- | -| enable | `boolean` | - -### Returns -- None - -### C Prototype -`void camera_config_enable_collisions(bool enable);` - -[:arrow_up_small:](#) - -
- -## [camera_config_enable_mouse_look](#camera_config_enable_mouse_look) - -### Description -Overrides if camera mouse look is enabled - -### 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_invert_x](#camera_config_invert_x) - -### Description -Overrides if camera X is inverted - -### 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) - -### Description -Overrides if camera Y is inverted - -### 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_set_x_sensitivity](#camera_config_set_x_sensitivity) - -### Description -Overrides camera 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) - -### Description -Overrides camera 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_config_set_aggression](#camera_config_set_aggression) - -### Description -Overrides camera 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_pan_level](#camera_config_set_pan_level) - -### Description -Overrides camera 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_deceleration](#camera_config_set_deceleration) - -### Description -Overrides camera 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_get_checking_surfaces](#camera_get_checking_surfaces) - -### Description -Checks if the camera should account for surfaces - -### Lua Example -`local booleanValue = camera_get_checking_surfaces()` - -### Parameters -- None - -### Returns -- `boolean` - -### C Prototype -`bool camera_get_checking_surfaces(void);` - -[:arrow_up_small:](#) - -
- -## [camera_set_checking_surfaces](#camera_set_checking_surfaces) - -### Description -Sets if the camera should account for surfaces - -### Lua Example -`camera_set_checking_surfaces(value)` - -### Parameters -| Field | Type | -| ----- | ---- | -| value | `boolean` | - -### Returns -- None - -### C Prototype -`void camera_set_checking_surfaces(bool value);` - -[:arrow_up_small:](#) - -
- ---- -# functions from smlua_collision_utils.h - -
- - -## [collision_find_floor](#collision_find_floor) - -### Description -Finds a potential floor at the given `x`, `y`, and `z` values - -### 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_find_ceil](#collision_find_ceil) - -### Description -Finds a potential ceiling at the given `x`, `y`, and `z` values - -### 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:](#) - -
- -## [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) - -### Description -Gets the `Collision` with `name` - -### 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:](#) - -
- -## [collision_get_temp_wall_collision_data](#collision_get_temp_wall_collision_data) - -### Description -Returns a temporary wall collision data pointer - -### 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) - -### Description -Gets the surface corresponding to `index` from `wcd` - -### 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:](#) - -
- -## [smlua_collision_util_get_current_terrain_collision](#smlua_collision_util_get_current_terrain_collision) - -### Description -Gets the current level terrain collision - -### Lua Example -`local PointerValue = smlua_collision_util_get_current_terrain_collision()` - -### Parameters -- None - -### Returns -- `Pointer` <`Collision`> - -### C Prototype -`Collision* smlua_collision_util_get_current_terrain_collision(void);` - -[:arrow_up_small:](#) - -
- -## [smlua_collision_util_get_level_collision](#smlua_collision_util_get_level_collision) - -### Description -Gets the `level` terrain collision from `area` - -### Lua Example -`local PointerValue = smlua_collision_util_get_level_collision(level, area)` - -### Parameters -| Field | Type | -| ----- | ---- | -| level | `integer` | -| area | `integer` | - -### Returns -- `Pointer` <`Collision`> - -### C Prototype -`Collision *smlua_collision_util_get_level_collision(u32 level, u16 area);` - -[:arrow_up_small:](#) - -
- -## [smlua_collision_util_find_surface_types](#smlua_collision_util_find_surface_types) - -### Description -Gets a table of the surface types from `data` - -### Lua Example -`smlua_collision_util_find_surface_types(data)` - -### Parameters -| Field | Type | -| ----- | ---- | -| data | `Pointer` <`Collision`> | - -### Returns -- None - -### C Prototype -`void smlua_collision_util_find_surface_types(Collision* data);` - -[:arrow_up_small:](#) - -
- ---- -# functions from smlua_deprecated.h - -
- --- [< prev](functions-4.md) | [1](functions.md) | [2](functions-2.md) | [3](functions-3.md) | [4](functions-4.md) | 5 | [6](functions-6.md) | [next >](functions-6.md)] diff --git a/docs/lua/functions-6.md b/docs/lua/functions-6.md index 4fde0782f..ad3622094 100644 --- a/docs/lua/functions-6.md +++ b/docs/lua/functions-6.md @@ -5,6 +5,1350 @@ [< prev](functions-5.md) | [1](functions.md) | [2](functions-2.md) | [3](functions-3.md) | [4](functions-4.md) | [5](functions-5.md) | 6] +--- +# functions from smlua_camera_utils.h + +
+ + +## [camera_reset_overrides](#camera_reset_overrides) + +### Description +Resets camera config overrides + +### Lua Example +`camera_reset_overrides()` + +### Parameters +- None + +### Returns +- None + +### C Prototype +`void camera_reset_overrides(void);` + +[:arrow_up_small:](#) + +
+ +## [camera_freeze](#camera_freeze) + +### Description +Freezes the camera by not updating it + +### Lua Example +`camera_freeze()` + +### Parameters +- None + +### Returns +- None + +### C Prototype +`void camera_freeze(void);` + +[:arrow_up_small:](#) + +
+ +## [camera_unfreeze](#camera_unfreeze) + +### Description +Unfreezes the camera + +### Lua Example +`camera_unfreeze()` + +### Parameters +- None + +### Returns +- None + +### C Prototype +`void camera_unfreeze(void);` + +[:arrow_up_small:](#) + +
+ +## [camera_is_frozen](#camera_is_frozen) + +### Description +Checks if the 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_romhack_allow_only_mods](#camera_romhack_allow_only_mods) + +### Description +Sets if only mods are allowed to modify the camera (Enabling prevents the player from modifying the camera through the settings) + +### Lua Example +`camera_romhack_allow_only_mods(allow)` + +### Parameters +| Field | Type | +| ----- | ---- | +| allow | `integer` | + +### Returns +- None + +### C Prototype +`void camera_romhack_allow_only_mods(u8 allow);` + +[:arrow_up_small:](#) + +
+ +## [camera_set_romhack_override](#camera_set_romhack_override) + +### Description +Sets the romhack camera override status + +### Lua Example +`camera_set_romhack_override(rco)` + +### Parameters +| Field | Type | +| ----- | ---- | +| rco | [enum RomhackCameraOverride](constants.md#enum-RomhackCameraOverride) | + +### Returns +- None + +### C Prototype +`void camera_set_romhack_override(enum RomhackCameraOverride rco);` + +[:arrow_up_small:](#) + +
+ +## [camera_romhack_allow_centering](#camera_romhack_allow_centering) + +### Description +Sets if the romhack camera should allow centering, triggered with the L button + +### Lua Example +`camera_romhack_allow_centering(allow)` + +### Parameters +| Field | Type | +| ----- | ---- | +| allow | `integer` | + +### Returns +- None + +### C Prototype +`void camera_romhack_allow_centering(u8 allow);` + +[:arrow_up_small:](#) + +
+ +## [camera_allow_toxic_gas_camera](#camera_allow_toxic_gas_camera) + +### Description +Sets if the romhack camera should fly above poison gas + +### Lua Example +`camera_allow_toxic_gas_camera(allow)` + +### Parameters +| Field | Type | +| ----- | ---- | +| allow | `integer` | + +### Returns +- None + +### C Prototype +`void camera_allow_toxic_gas_camera(u8 allow);` + +[:arrow_up_small:](#) + +
+ +## [camera_romhack_allow_dpad_usage](#camera_romhack_allow_dpad_usage) + +### Description +Sets if the romhack camera should allow D-Pad movement + +### Lua Example +`camera_romhack_allow_dpad_usage(allow)` + +### Parameters +| Field | Type | +| ----- | ---- | +| allow | `integer` | + +### Returns +- None + +### C Prototype +`void camera_romhack_allow_dpad_usage(u8 allow);` + +[:arrow_up_small:](#) + +
+ +## [rom_hack_cam_set_collisions](#rom_hack_cam_set_collisions) + +### Description +Toggles collision settings for the ROM hack camera. This enables or disables specific collision behaviors in modded levels + +### Lua Example +`rom_hack_cam_set_collisions(enable)` + +### Parameters +| Field | Type | +| ----- | ---- | +| enable | `integer` | + +### Returns +- None + +### C Prototype +`void rom_hack_cam_set_collisions(u8 enable);` + +[:arrow_up_small:](#) + +
+ +## [camera_romhack_set_zoomed_in_dist](#camera_romhack_set_zoomed_in_dist) + +### Description +Sets the romhack camera's zoomed in distance (Default: 900) + +### Lua Example +`camera_romhack_set_zoomed_in_dist(val)` + +### Parameters +| Field | Type | +| ----- | ---- | +| val | `integer` | + +### Returns +- None + +### C Prototype +`void camera_romhack_set_zoomed_in_dist(u32 val);` + +[:arrow_up_small:](#) + +
+ +## [camera_romhack_set_zoomed_out_dist](#camera_romhack_set_zoomed_out_dist) + +### Description +Sets the romhack camera's zoomed out additional distance (Default: 500) + +### Lua Example +`camera_romhack_set_zoomed_out_dist(val)` + +### Parameters +| Field | Type | +| ----- | ---- | +| val | `integer` | + +### Returns +- None + +### C Prototype +`void camera_romhack_set_zoomed_out_dist(u32 val);` + +[:arrow_up_small:](#) + +
+ +## [camera_romhack_set_zoomed_in_height](#camera_romhack_set_zoomed_in_height) + +### Description +Sets the romhack camera's zoomed in height (Default: 300) + +### Lua Example +`camera_romhack_set_zoomed_in_height(val)` + +### Parameters +| Field | Type | +| ----- | ---- | +| val | `integer` | + +### Returns +- None + +### C Prototype +`void camera_romhack_set_zoomed_in_height(u32 val);` + +[:arrow_up_small:](#) + +
+ +## [camera_romhack_set_zoomed_out_height](#camera_romhack_set_zoomed_out_height) + +### Description +Sets the romhack camera's zoomed out additional height (Default: 150) + +### Lua Example +`camera_romhack_set_zoomed_out_height(val)` + +### Parameters +| Field | Type | +| ----- | ---- | +| val | `integer` | + +### Returns +- None + +### C Prototype +`void camera_romhack_set_zoomed_out_height(u32 val);` + +[:arrow_up_small:](#) + +
+ +## [camera_romhack_get_zoomed_in_dist](#camera_romhack_get_zoomed_in_dist) + +### Description +Gets the romhack camera's zoomed in distance + +### Lua Example +`local integerValue = camera_romhack_get_zoomed_in_dist()` + +### Parameters +- None + +### Returns +- `integer` + +### C Prototype +`u32 camera_romhack_get_zoomed_in_dist(void);` + +[:arrow_up_small:](#) + +
+ +## [camera_romhack_get_zoomed_out_dist](#camera_romhack_get_zoomed_out_dist) + +### Description +Gets the romhack camera's additional zoomed out distance + +### Lua Example +`local integerValue = camera_romhack_get_zoomed_out_dist()` + +### Parameters +- None + +### Returns +- `integer` + +### C Prototype +`u32 camera_romhack_get_zoomed_out_dist(void);` + +[:arrow_up_small:](#) + +
+ +## [camera_romhack_get_zoomed_in_height](#camera_romhack_get_zoomed_in_height) + +### Description +Gets the romhack camera's zoomed in height + +### Lua Example +`local integerValue = camera_romhack_get_zoomed_in_height()` + +### Parameters +- None + +### Returns +- `integer` + +### C Prototype +`u32 camera_romhack_get_zoomed_in_height(void);` + +[:arrow_up_small:](#) + +
+ +## [camera_romhack_get_zoomed_out_height](#camera_romhack_get_zoomed_out_height) + +### Description +Gets the romhack camera's additional zoomed out height + +### Lua Example +`local integerValue = camera_romhack_get_zoomed_out_height()` + +### Parameters +- None + +### Returns +- `integer` + +### C Prototype +`u32 camera_romhack_get_zoomed_out_height(void);` + +[:arrow_up_small:](#) + +
+ +## [camera_get_romhack_override](#camera_get_romhack_override) + +### Description +Gets the current romhack camera override status + +### Lua Example +`local enumValue = camera_get_romhack_override()` + +### Parameters +- None + +### Returns +[enum RomhackCameraOverride](constants.md#enum-RomhackCameraOverride) + +### C Prototype +`enum RomhackCameraOverride camera_get_romhack_override(void);` + +[:arrow_up_small:](#) + +
+ +## [camera_romhack_get_allow_centering](#camera_romhack_get_allow_centering) + +### Description +Gets if the romhack camera should allow centering + +### Lua Example +`local integerValue = camera_romhack_get_allow_centering()` + +### Parameters +- None + +### Returns +- `integer` + +### C Prototype +`u8 camera_romhack_get_allow_centering(void);` + +[:arrow_up_small:](#) + +
+ +## [camera_get_allow_toxic_gas_camera](#camera_get_allow_toxic_gas_camera) + +### Description +Gets if the romhack camera should fly above poison gas + +### Lua Example +`local integerValue = camera_get_allow_toxic_gas_camera()` + +### Parameters +- None + +### Returns +- `integer` + +### C Prototype +`u8 camera_get_allow_toxic_gas_camera(void);` + +[:arrow_up_small:](#) + +
+ +## [camera_romhack_get_allow_dpad_usage](#camera_romhack_get_allow_dpad_usage) + +### Description +Gets if the romhack camera should allow D-Pad movement + +### Lua Example +`local integerValue = camera_romhack_get_allow_dpad_usage()` + +### Parameters +- None + +### Returns +- `integer` + +### C Prototype +`u8 camera_romhack_get_allow_dpad_usage(void);` + +[:arrow_up_small:](#) + +
+ +## [camera_romhack_get_collisions](#camera_romhack_get_collisions) + +### Description +Gets if the romhack camera has surface collisions + +### Lua Example +`local integerValue = camera_romhack_get_collisions()` + +### Parameters +- None + +### Returns +- `integer` + +### C Prototype +`u8 camera_romhack_get_collisions(void);` + +[:arrow_up_small:](#) + +
+ +## [camera_config_is_free_cam_enabled](#camera_config_is_free_cam_enabled) + +### Description +Checks if Free Camera is 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_analog_cam_enabled](#camera_config_is_analog_cam_enabled) + +### Description +Checks if Analog Camera is 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_dpad_enabled](#camera_config_is_dpad_enabled) + +### Description +Checks if Freecam DPad Behavior is enabled + +### Lua Example +`local booleanValue = camera_config_is_dpad_enabled()` + +### Parameters +- None + +### Returns +- `boolean` + +### C Prototype +`bool camera_config_is_dpad_enabled(void);` + +[:arrow_up_small:](#) + +
+ +## [camera_config_is_collision_enabled](#camera_config_is_collision_enabled) + +### Description +Checks if Camera Collision is enabled + +### Lua Example +`local booleanValue = camera_config_is_collision_enabled()` + +### Parameters +- None + +### Returns +- `boolean` + +### C Prototype +`bool camera_config_is_collision_enabled(void);` + +[:arrow_up_small:](#) + +
+ +## [camera_config_is_mouse_look_enabled](#camera_config_is_mouse_look_enabled) + +### Description +Checks if Mouse Look is 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) + +### Description +Checks if camera X is 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) + +### Description +Checks if camera Y is 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_get_x_sensitivity](#camera_config_get_x_sensitivity) + +### Description +Gets camera 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) + +### Description +Gets camera 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_get_aggression](#camera_config_get_aggression) + +### Description +Gets camera 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_pan_level](#camera_config_get_pan_level) + +### Description +Gets camera 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_deceleration](#camera_config_get_deceleration) + +### Description +Gets camera 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_centering](#camera_config_get_centering) + +### Description +Gets if the L button will center the camera + +### Lua Example +`local booleanValue = camera_config_get_centering()` + +### Parameters +- None + +### Returns +- `boolean` + +### C Prototype +`bool camera_config_get_centering(void);` + +[:arrow_up_small:](#) + +
+ +## [camera_config_enable_free_cam](#camera_config_enable_free_cam) + +### Description +Overrides if Free Camera is enabled + +### 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_analog_cam](#camera_config_enable_analog_cam) + +### Description +Overrides if Analog Camera is enabled + +### 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_centering](#camera_config_enable_centering) + +### Description +Overrides if the L button will center the camera + +### Lua Example +`camera_config_enable_centering(enable)` + +### Parameters +| Field | Type | +| ----- | ---- | +| enable | `boolean` | + +### Returns +- None + +### C Prototype +`void camera_config_enable_centering(bool enable);` + +[:arrow_up_small:](#) + +
+ +## [camera_config_enable_dpad](#camera_config_enable_dpad) + +### Description +Overrides if Freecam DPad Behavior is enabled + +### Lua Example +`camera_config_enable_dpad(enable)` + +### Parameters +| Field | Type | +| ----- | ---- | +| enable | `boolean` | + +### Returns +- None + +### C Prototype +`void camera_config_enable_dpad(bool enable);` + +[:arrow_up_small:](#) + +
+ +## [camera_config_enable_collisions](#camera_config_enable_collisions) + +### Description +Overrides if Camera Collision is enabled + +### Lua Example +`camera_config_enable_collisions(enable)` + +### Parameters +| Field | Type | +| ----- | ---- | +| enable | `boolean` | + +### Returns +- None + +### C Prototype +`void camera_config_enable_collisions(bool enable);` + +[:arrow_up_small:](#) + +
+ +## [camera_config_enable_mouse_look](#camera_config_enable_mouse_look) + +### Description +Overrides if camera mouse look is enabled + +### 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_invert_x](#camera_config_invert_x) + +### Description +Overrides if camera X is inverted + +### 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) + +### Description +Overrides if camera Y is inverted + +### 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_set_x_sensitivity](#camera_config_set_x_sensitivity) + +### Description +Overrides camera 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) + +### Description +Overrides camera 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_config_set_aggression](#camera_config_set_aggression) + +### Description +Overrides camera 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_pan_level](#camera_config_set_pan_level) + +### Description +Overrides camera 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_deceleration](#camera_config_set_deceleration) + +### Description +Overrides camera 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_get_checking_surfaces](#camera_get_checking_surfaces) + +### Description +Checks if the camera should account for surfaces + +### Lua Example +`local booleanValue = camera_get_checking_surfaces()` + +### Parameters +- None + +### Returns +- `boolean` + +### C Prototype +`bool camera_get_checking_surfaces(void);` + +[:arrow_up_small:](#) + +
+ +## [camera_set_checking_surfaces](#camera_set_checking_surfaces) + +### Description +Sets if the camera should account for surfaces + +### Lua Example +`camera_set_checking_surfaces(value)` + +### Parameters +| Field | Type | +| ----- | ---- | +| value | `boolean` | + +### Returns +- None + +### C Prototype +`void camera_set_checking_surfaces(bool value);` + +[:arrow_up_small:](#) + +
+ +--- +# functions from smlua_collision_utils.h + +
+ + +## [collision_find_floor](#collision_find_floor) + +### Description +Finds a potential floor at the given `x`, `y`, and `z` values + +### 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_find_ceil](#collision_find_ceil) + +### Description +Finds a potential ceiling at the given `x`, `y`, and `z` values + +### 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:](#) + +
+ +## [get_water_surface_pseudo_floor](#get_water_surface_pseudo_floor) + +### Description +Gets the generated water floor surface used when riding a shell + +### 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) + +### Description +Gets the `Collision` with `name` + +### 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:](#) + +
+ +## [collision_get_temp_wall_collision_data](#collision_get_temp_wall_collision_data) + +### Description +Returns a temporary wall collision data pointer + +### 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) + +### Description +Gets the surface corresponding to `index` from `wcd` + +### 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:](#) + +
+ +## [smlua_collision_util_get_current_terrain_collision](#smlua_collision_util_get_current_terrain_collision) + +### Description +Gets the current level terrain collision + +### Lua Example +`local PointerValue = smlua_collision_util_get_current_terrain_collision()` + +### Parameters +- None + +### Returns +- `Pointer` <`Collision`> + +### C Prototype +`Collision* smlua_collision_util_get_current_terrain_collision(void);` + +[:arrow_up_small:](#) + +
+ +## [smlua_collision_util_get_level_collision](#smlua_collision_util_get_level_collision) + +### Description +Gets the `level` terrain collision from `area` + +### Lua Example +`local PointerValue = smlua_collision_util_get_level_collision(level, area)` + +### Parameters +| Field | Type | +| ----- | ---- | +| level | `integer` | +| area | `integer` | + +### Returns +- `Pointer` <`Collision`> + +### C Prototype +`Collision *smlua_collision_util_get_level_collision(u32 level, u16 area);` + +[:arrow_up_small:](#) + +
+ +## [smlua_collision_util_find_surface_types](#smlua_collision_util_find_surface_types) + +### Description +Gets a table of the surface types from `data` + +### Lua Example +`smlua_collision_util_find_surface_types(data)` + +### Parameters +| Field | Type | +| ----- | ---- | +| data | `Pointer` <`Collision`> | + +### Returns +- None + +### C Prototype +`void smlua_collision_util_find_surface_types(Collision* data);` + +[:arrow_up_small:](#) + +
+ +--- +# functions from smlua_deprecated.h + +
+ + --- # functions from smlua_gfx_utils.h @@ -2113,6 +3457,9 @@ Checks if the HUD is hidden ## [hud_get_value](#hud_get_value) +### Description +Gets a HUD display value + ### Lua Example `local integerValue = hud_get_value(type)` @@ -2533,33 +3880,6 @@ Sets the water level in an area corresponding to `index` (0-indexed)
-## [play_transition](#play_transition) - -### Description -Plays a screen 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:](#) - -
- ## [course_is_main_course](#course_is_main_course) ### Description @@ -2981,7 +4301,7 @@ Sets the volume level of environment sounds effects Gets an environment region (gas/water boxes) height value ### Lua Example -`local numberValue = get_environment_region(index)` +`local integerValue = get_environment_region(index)` ### Parameters | Field | Type | @@ -2989,10 +4309,10 @@ Gets an environment region (gas/water boxes) height value | index | `integer` | ### Returns -- `number` +- `integer` ### C Prototype -`f32 get_environment_region(u8 index);` +`s16 get_environment_region(u8 index);` [:arrow_up_small:](#) @@ -3016,7 +4336,7 @@ Sets an environment region (gas/water boxes) height value - None ### C Prototype -`void set_environment_region(u8 index, s32 value);` +`void set_environment_region(u8 index, s16 value);` [:arrow_up_small:](#) @@ -5090,27 +6410,6 @@ Stops cap music completely
-## [exec_anim_sound_state](#exec_anim_sound_state) - -### Lua Example -`exec_anim_sound_state(soundStates, maxSoundStates)` - -### Parameters -| Field | Type | -| ----- | ---- | -| soundStates | [SoundState](structs.md#SoundState) | -| maxSoundStates | `integer` | - -### Returns -- None - -### C Prototype -`void exec_anim_sound_state(struct SoundState *soundStates, u16 maxSoundStates);` - -[:arrow_up_small:](#) - -
- ## [cur_obj_play_sound_1](#cur_obj_play_sound_1) ### Description @@ -5384,49 +6683,6 @@ Sets whether collision finding functions should check wall directions.
-## [get_area_terrain_size](#get_area_terrain_size) - -### Lua Example -`local integerValue = get_area_terrain_size(data)` - -### Parameters -| Field | Type | -| ----- | ---- | -| data | `Pointer` <`integer`> | - -### Returns -- `integer` - -### C Prototype -`u32 get_area_terrain_size(s16 *data);` - -[:arrow_up_small:](#) - -
- -## [load_area_terrain](#load_area_terrain) - -### Lua Example -`load_area_terrain(index, data, surfaceRooms, macroObjects)` - -### Parameters -| Field | Type | -| ----- | ---- | -| index | `integer` | -| data | `Pointer` <`integer`> | -| surfaceRooms | `Pointer` <`integer`> | -| macroObjects | `Pointer` <`integer`> | - -### Returns -- None - -### C Prototype -`void load_area_terrain(s16 index, s16 *data, s8 *surfaceRooms, s16 *macroObjects);` - -[:arrow_up_small:](#) - -
- ## [load_object_collision_model](#load_object_collision_model) ### Description @@ -5474,6 +6730,9 @@ Gets a surface corresponding to `index` from the surface pool buffer ## [surface_has_force](#surface_has_force) +### Description +Checks if a surface has force + ### Lua Example `local booleanValue = surface_has_force(surfaceType)` diff --git a/docs/lua/functions.md b/docs/lua/functions.md index 0772e8aff..cfdf90c29 100644 --- a/docs/lua/functions.md +++ b/docs/lua/functions.md @@ -33,8 +33,12 @@
- area.h + - [get_mario_spawn_type](functions.md#get_mario_spawn_type) - [area_get_warp_node](functions.md#area_get_warp_node) + - [area_get_any_warp_node](functions.md#area_get_any_warp_node) - [area_get_warp_node_from_params](functions.md#area_get_warp_node_from_params) + - [play_transition](functions.md#play_transition) + - [play_transition_after_delay](functions.md#play_transition_after_delay)
@@ -1284,44 +1288,43 @@
- obj_behaviors.c - - [set_yoshi_as_not_dead](functions-4.md#set_yoshi_as_not_dead) - - [absf_2](functions-4.md#absf_2) - - [turn_obj_away_from_surface](functions-4.md#turn_obj_away_from_surface) - - [obj_find_wall](functions-4.md#obj_find_wall) - - [turn_obj_away_from_steep_floor](functions-4.md#turn_obj_away_from_steep_floor) - - [obj_orient_graph](functions-4.md#obj_orient_graph) - - [calc_obj_friction](functions-4.md#calc_obj_friction) - - [calc_new_obj_vel_and_pos_y](functions-4.md#calc_new_obj_vel_and_pos_y) - - [calc_new_obj_vel_and_pos_y_underwater](functions-4.md#calc_new_obj_vel_and_pos_y_underwater) - - [obj_update_pos_vel_xz](functions-4.md#obj_update_pos_vel_xz) - - [obj_splash](functions-4.md#obj_splash) - - [object_step](functions-4.md#object_step) - - [object_step_without_floor_orient](functions-4.md#object_step_without_floor_orient) - - [obj_move_xyz_using_fvel_and_yaw](functions-4.md#obj_move_xyz_using_fvel_and_yaw) - - [is_point_within_radius_of_mario](functions-4.md#is_point_within_radius_of_mario) - - [is_point_within_radius_of_any_player](functions-4.md#is_point_within_radius_of_any_player) - - [is_player_active](functions-4.md#is_player_active) - - [is_other_player_active](functions-4.md#is_other_player_active) - - [is_player_in_local_area](functions-4.md#is_player_in_local_area) - - [nearest_mario_state_to_object](functions-4.md#nearest_mario_state_to_object) - - [nearest_possible_mario_state_to_object](functions-4.md#nearest_possible_mario_state_to_object) - - [nearest_player_to_object](functions-4.md#nearest_player_to_object) - - [nearest_interacting_mario_state_to_object](functions-4.md#nearest_interacting_mario_state_to_object) - - [nearest_interacting_player_to_object](functions-4.md#nearest_interacting_player_to_object) - - [is_nearest_mario_state_to_object](functions-4.md#is_nearest_mario_state_to_object) - - [is_nearest_player_to_object](functions-4.md#is_nearest_player_to_object) - - [is_point_close_to_object](functions-4.md#is_point_close_to_object) - - [set_object_visibility](functions-4.md#set_object_visibility) - - [obj_return_home_if_safe](functions-4.md#obj_return_home_if_safe) - - [obj_return_and_displace_home](functions-4.md#obj_return_and_displace_home) - - [obj_check_if_facing_toward_angle](functions-4.md#obj_check_if_facing_toward_angle) - - [obj_find_wall_displacement](functions-4.md#obj_find_wall_displacement) - - [obj_spawn_yellow_coins](functions-4.md#obj_spawn_yellow_coins) - - [obj_flicker_and_disappear](functions-4.md#obj_flicker_and_disappear) - - [current_mario_room_check](functions-4.md#current_mario_room_check) - - [obj_check_floor_death](functions-4.md#obj_check_floor_death) - - [obj_lava_death](functions-4.md#obj_lava_death) - - [spawn_orange_number](functions-4.md#spawn_orange_number) + - [set_yoshi_as_not_dead](functions-5.md#set_yoshi_as_not_dead) + - [absf_2](functions-5.md#absf_2) + - [obj_find_wall](functions-5.md#obj_find_wall) + - [turn_obj_away_from_steep_floor](functions-5.md#turn_obj_away_from_steep_floor) + - [obj_orient_graph](functions-5.md#obj_orient_graph) + - [calc_obj_friction](functions-5.md#calc_obj_friction) + - [calc_new_obj_vel_and_pos_y](functions-5.md#calc_new_obj_vel_and_pos_y) + - [calc_new_obj_vel_and_pos_y_underwater](functions-5.md#calc_new_obj_vel_and_pos_y_underwater) + - [obj_update_pos_vel_xz](functions-5.md#obj_update_pos_vel_xz) + - [obj_splash](functions-5.md#obj_splash) + - [object_step](functions-5.md#object_step) + - [object_step_without_floor_orient](functions-5.md#object_step_without_floor_orient) + - [obj_move_xyz_using_fvel_and_yaw](functions-5.md#obj_move_xyz_using_fvel_and_yaw) + - [is_point_within_radius_of_mario](functions-5.md#is_point_within_radius_of_mario) + - [is_point_within_radius_of_any_player](functions-5.md#is_point_within_radius_of_any_player) + - [is_player_active](functions-5.md#is_player_active) + - [is_other_player_active](functions-5.md#is_other_player_active) + - [is_player_in_local_area](functions-5.md#is_player_in_local_area) + - [nearest_mario_state_to_object](functions-5.md#nearest_mario_state_to_object) + - [nearest_possible_mario_state_to_object](functions-5.md#nearest_possible_mario_state_to_object) + - [nearest_player_to_object](functions-5.md#nearest_player_to_object) + - [nearest_interacting_mario_state_to_object](functions-5.md#nearest_interacting_mario_state_to_object) + - [nearest_interacting_player_to_object](functions-5.md#nearest_interacting_player_to_object) + - [is_nearest_mario_state_to_object](functions-5.md#is_nearest_mario_state_to_object) + - [is_nearest_player_to_object](functions-5.md#is_nearest_player_to_object) + - [is_point_close_to_object](functions-5.md#is_point_close_to_object) + - [set_object_visibility](functions-5.md#set_object_visibility) + - [obj_return_home_if_safe](functions-5.md#obj_return_home_if_safe) + - [obj_return_and_displace_home](functions-5.md#obj_return_and_displace_home) + - [obj_check_if_facing_toward_angle](functions-5.md#obj_check_if_facing_toward_angle) + - [obj_find_wall_displacement](functions-5.md#obj_find_wall_displacement) + - [obj_spawn_yellow_coins](functions-5.md#obj_spawn_yellow_coins) + - [obj_flicker_and_disappear](functions-5.md#obj_flicker_and_disappear) + - [current_mario_room_check](functions-5.md#current_mario_room_check) + - [obj_check_floor_death](functions-5.md#obj_check_floor_death) + - [obj_lava_death](functions-5.md#obj_lava_death) + - [spawn_orange_number](functions-5.md#spawn_orange_number)
@@ -1693,70 +1696,70 @@
- smlua_camera_utils.h - - [camera_reset_overrides](functions-5.md#camera_reset_overrides) - - [camera_freeze](functions-5.md#camera_freeze) - - [camera_unfreeze](functions-5.md#camera_unfreeze) - - [camera_is_frozen](functions-5.md#camera_is_frozen) - - [camera_romhack_allow_only_mods](functions-5.md#camera_romhack_allow_only_mods) - - [camera_set_romhack_override](functions-5.md#camera_set_romhack_override) - - [camera_romhack_allow_centering](functions-5.md#camera_romhack_allow_centering) - - [camera_allow_toxic_gas_camera](functions-5.md#camera_allow_toxic_gas_camera) - - [camera_romhack_allow_dpad_usage](functions-5.md#camera_romhack_allow_dpad_usage) - - [rom_hack_cam_set_collisions](functions-5.md#rom_hack_cam_set_collisions) - - [camera_romhack_set_zoomed_in_dist](functions-5.md#camera_romhack_set_zoomed_in_dist) - - [camera_romhack_set_zoomed_out_dist](functions-5.md#camera_romhack_set_zoomed_out_dist) - - [camera_romhack_set_zoomed_in_height](functions-5.md#camera_romhack_set_zoomed_in_height) - - [camera_romhack_set_zoomed_out_height](functions-5.md#camera_romhack_set_zoomed_out_height) - - [camera_romhack_get_zoomed_in_dist](functions-5.md#camera_romhack_get_zoomed_in_dist) - - [camera_romhack_get_zoomed_out_dist](functions-5.md#camera_romhack_get_zoomed_out_dist) - - [camera_romhack_get_zoomed_in_height](functions-5.md#camera_romhack_get_zoomed_in_height) - - [camera_romhack_get_zoomed_out_height](functions-5.md#camera_romhack_get_zoomed_out_height) - - [camera_get_romhack_override](functions-5.md#camera_get_romhack_override) - - [camera_romhack_get_allow_centering](functions-5.md#camera_romhack_get_allow_centering) - - [camera_get_allow_toxic_gas_camera](functions-5.md#camera_get_allow_toxic_gas_camera) - - [camera_romhack_get_allow_dpad_usage](functions-5.md#camera_romhack_get_allow_dpad_usage) - - [camera_romhack_get_collisions](functions-5.md#camera_romhack_get_collisions) - - [camera_config_is_free_cam_enabled](functions-5.md#camera_config_is_free_cam_enabled) - - [camera_config_is_analog_cam_enabled](functions-5.md#camera_config_is_analog_cam_enabled) - - [camera_config_is_dpad_enabled](functions-5.md#camera_config_is_dpad_enabled) - - [camera_config_is_collision_enabled](functions-5.md#camera_config_is_collision_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_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_get_aggression](functions-5.md#camera_config_get_aggression) - - [camera_config_get_pan_level](functions-5.md#camera_config_get_pan_level) - - [camera_config_get_deceleration](functions-5.md#camera_config_get_deceleration) - - [camera_config_get_centering](functions-5.md#camera_config_get_centering) - - [camera_config_enable_free_cam](functions-5.md#camera_config_enable_free_cam) - - [camera_config_enable_analog_cam](functions-5.md#camera_config_enable_analog_cam) - - [camera_config_enable_centering](functions-5.md#camera_config_enable_centering) - - [camera_config_enable_dpad](functions-5.md#camera_config_enable_dpad) - - [camera_config_enable_collisions](functions-5.md#camera_config_enable_collisions) - - [camera_config_enable_mouse_look](functions-5.md#camera_config_enable_mouse_look) - - [camera_config_invert_x](functions-5.md#camera_config_invert_x) - - [camera_config_invert_y](functions-5.md#camera_config_invert_y) - - [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_config_set_aggression](functions-5.md#camera_config_set_aggression) - - [camera_config_set_pan_level](functions-5.md#camera_config_set_pan_level) - - [camera_config_set_deceleration](functions-5.md#camera_config_set_deceleration) - - [camera_get_checking_surfaces](functions-5.md#camera_get_checking_surfaces) - - [camera_set_checking_surfaces](functions-5.md#camera_set_checking_surfaces) + - [camera_reset_overrides](functions-6.md#camera_reset_overrides) + - [camera_freeze](functions-6.md#camera_freeze) + - [camera_unfreeze](functions-6.md#camera_unfreeze) + - [camera_is_frozen](functions-6.md#camera_is_frozen) + - [camera_romhack_allow_only_mods](functions-6.md#camera_romhack_allow_only_mods) + - [camera_set_romhack_override](functions-6.md#camera_set_romhack_override) + - [camera_romhack_allow_centering](functions-6.md#camera_romhack_allow_centering) + - [camera_allow_toxic_gas_camera](functions-6.md#camera_allow_toxic_gas_camera) + - [camera_romhack_allow_dpad_usage](functions-6.md#camera_romhack_allow_dpad_usage) + - [rom_hack_cam_set_collisions](functions-6.md#rom_hack_cam_set_collisions) + - [camera_romhack_set_zoomed_in_dist](functions-6.md#camera_romhack_set_zoomed_in_dist) + - [camera_romhack_set_zoomed_out_dist](functions-6.md#camera_romhack_set_zoomed_out_dist) + - [camera_romhack_set_zoomed_in_height](functions-6.md#camera_romhack_set_zoomed_in_height) + - [camera_romhack_set_zoomed_out_height](functions-6.md#camera_romhack_set_zoomed_out_height) + - [camera_romhack_get_zoomed_in_dist](functions-6.md#camera_romhack_get_zoomed_in_dist) + - [camera_romhack_get_zoomed_out_dist](functions-6.md#camera_romhack_get_zoomed_out_dist) + - [camera_romhack_get_zoomed_in_height](functions-6.md#camera_romhack_get_zoomed_in_height) + - [camera_romhack_get_zoomed_out_height](functions-6.md#camera_romhack_get_zoomed_out_height) + - [camera_get_romhack_override](functions-6.md#camera_get_romhack_override) + - [camera_romhack_get_allow_centering](functions-6.md#camera_romhack_get_allow_centering) + - [camera_get_allow_toxic_gas_camera](functions-6.md#camera_get_allow_toxic_gas_camera) + - [camera_romhack_get_allow_dpad_usage](functions-6.md#camera_romhack_get_allow_dpad_usage) + - [camera_romhack_get_collisions](functions-6.md#camera_romhack_get_collisions) + - [camera_config_is_free_cam_enabled](functions-6.md#camera_config_is_free_cam_enabled) + - [camera_config_is_analog_cam_enabled](functions-6.md#camera_config_is_analog_cam_enabled) + - [camera_config_is_dpad_enabled](functions-6.md#camera_config_is_dpad_enabled) + - [camera_config_is_collision_enabled](functions-6.md#camera_config_is_collision_enabled) + - [camera_config_is_mouse_look_enabled](functions-6.md#camera_config_is_mouse_look_enabled) + - [camera_config_is_x_inverted](functions-6.md#camera_config_is_x_inverted) + - [camera_config_is_y_inverted](functions-6.md#camera_config_is_y_inverted) + - [camera_config_get_x_sensitivity](functions-6.md#camera_config_get_x_sensitivity) + - [camera_config_get_y_sensitivity](functions-6.md#camera_config_get_y_sensitivity) + - [camera_config_get_aggression](functions-6.md#camera_config_get_aggression) + - [camera_config_get_pan_level](functions-6.md#camera_config_get_pan_level) + - [camera_config_get_deceleration](functions-6.md#camera_config_get_deceleration) + - [camera_config_get_centering](functions-6.md#camera_config_get_centering) + - [camera_config_enable_free_cam](functions-6.md#camera_config_enable_free_cam) + - [camera_config_enable_analog_cam](functions-6.md#camera_config_enable_analog_cam) + - [camera_config_enable_centering](functions-6.md#camera_config_enable_centering) + - [camera_config_enable_dpad](functions-6.md#camera_config_enable_dpad) + - [camera_config_enable_collisions](functions-6.md#camera_config_enable_collisions) + - [camera_config_enable_mouse_look](functions-6.md#camera_config_enable_mouse_look) + - [camera_config_invert_x](functions-6.md#camera_config_invert_x) + - [camera_config_invert_y](functions-6.md#camera_config_invert_y) + - [camera_config_set_x_sensitivity](functions-6.md#camera_config_set_x_sensitivity) + - [camera_config_set_y_sensitivity](functions-6.md#camera_config_set_y_sensitivity) + - [camera_config_set_aggression](functions-6.md#camera_config_set_aggression) + - [camera_config_set_pan_level](functions-6.md#camera_config_set_pan_level) + - [camera_config_set_deceleration](functions-6.md#camera_config_set_deceleration) + - [camera_get_checking_surfaces](functions-6.md#camera_get_checking_surfaces) + - [camera_set_checking_surfaces](functions-6.md#camera_set_checking_surfaces)
- smlua_collision_utils.h - - [collision_find_floor](functions-5.md#collision_find_floor) - - [collision_find_ceil](functions-5.md#collision_find_ceil) - - [get_water_surface_pseudo_floor](functions-5.md#get_water_surface_pseudo_floor) - - [smlua_collision_util_get](functions-5.md#smlua_collision_util_get) - - [collision_get_temp_wall_collision_data](functions-5.md#collision_get_temp_wall_collision_data) - - [get_surface_from_wcd_index](functions-5.md#get_surface_from_wcd_index) - - [smlua_collision_util_get_current_terrain_collision](functions-5.md#smlua_collision_util_get_current_terrain_collision) - - [smlua_collision_util_get_level_collision](functions-5.md#smlua_collision_util_get_level_collision) - - [smlua_collision_util_find_surface_types](functions-5.md#smlua_collision_util_find_surface_types) + - [collision_find_floor](functions-6.md#collision_find_floor) + - [collision_find_ceil](functions-6.md#collision_find_ceil) + - [get_water_surface_pseudo_floor](functions-6.md#get_water_surface_pseudo_floor) + - [smlua_collision_util_get](functions-6.md#smlua_collision_util_get) + - [collision_get_temp_wall_collision_data](functions-6.md#collision_get_temp_wall_collision_data) + - [get_surface_from_wcd_index](functions-6.md#get_surface_from_wcd_index) + - [smlua_collision_util_get_current_terrain_collision](functions-6.md#smlua_collision_util_get_current_terrain_collision) + - [smlua_collision_util_get_level_collision](functions-6.md#smlua_collision_util_get_level_collision) + - [smlua_collision_util_find_surface_types](functions-6.md#smlua_collision_util_find_surface_types)
@@ -1886,7 +1889,6 @@ - [movtexqc_register](functions-6.md#movtexqc_register) - [get_water_level](functions-6.md#get_water_level) - [set_water_level](functions-6.md#set_water_level) - - [play_transition](functions-6.md#play_transition) - [course_is_main_course](functions-6.md#course_is_main_course) - [get_ttc_speed_setting](functions-6.md#get_ttc_speed_setting) - [set_ttc_speed_setting](functions-6.md#set_ttc_speed_setting) @@ -2015,7 +2017,6 @@
- spawn_sound.h - - [exec_anim_sound_state](functions-6.md#exec_anim_sound_state) - [cur_obj_play_sound_1](functions-6.md#cur_obj_play_sound_1) - [cur_obj_play_sound_2](functions-6.md#cur_obj_play_sound_2) - [create_sound_spawner](functions-6.md#create_sound_spawner) @@ -2035,8 +2036,6 @@
- surface_load.h - - [get_area_terrain_size](functions-6.md#get_area_terrain_size) - - [load_area_terrain](functions-6.md#load_area_terrain) - [load_object_collision_model](functions-6.md#load_object_collision_model) - [obj_get_surface_from_index](functions-6.md#obj_get_surface_from_index) - [surface_has_force](functions-6.md#surface_has_force) @@ -2629,6 +2628,29 @@ N/A
+## [get_mario_spawn_type](#get_mario_spawn_type) + +### Description +Derives a `MARIO_SPAWN_*` constant from `o` + +### Lua Example +`local enumValue = get_mario_spawn_type(o)` + +### Parameters +| Field | Type | +| ----- | ---- | +| o | [Object](structs.md#Object) | + +### Returns +[enum MarioSpawnType](constants.md#enum-MarioSpawnType) + +### C Prototype +`enum MarioSpawnType get_mario_spawn_type(struct Object *o);` + +[:arrow_up_small:](#) + +
+ ## [area_get_warp_node](#area_get_warp_node) ### Description @@ -2652,6 +2674,27 @@ Finds a warp node in the current area by its ID. The warp node must exist in the
+## [area_get_any_warp_node](#area_get_any_warp_node) + +### Description +Gets the first warp node found in the area, otherwise returns nil + +### Lua Example +`local ObjectWarpNodeValue = area_get_any_warp_node()` + +### Parameters +- None + +### Returns +[ObjectWarpNode](structs.md#ObjectWarpNode) + +### C Prototype +`struct ObjectWarpNode *area_get_any_warp_node(void);` + +[:arrow_up_small:](#) + +
+ ## [area_get_warp_node_from_params](#area_get_warp_node_from_params) ### Description @@ -2673,6 +2716,61 @@ Finds a warp node in the current area using parameters from the provided object. [:arrow_up_small:](#) +
+ +## [play_transition](#play_transition) + +### Description +Plays a screen 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:](#) + +
+ +## [play_transition_after_delay](#play_transition_after_delay) + +### Description +Plays a screen transition after a `delay` in frames + +### Lua Example +`play_transition_after_delay(transType, time, red, green, blue, delay)` + +### Parameters +| Field | Type | +| ----- | ---- | +| transType | `integer` | +| time | `integer` | +| red | `integer` | +| green | `integer` | +| blue | `integer` | +| delay | `integer` | + +### Returns +- None + +### C Prototype +`void play_transition_after_delay(s16 transType, s16 time, u8 red, u8 green, u8 blue, s16 delay);` + +[:arrow_up_small:](#) +
--- diff --git a/docs/lua/guides/hooks.md b/docs/lua/guides/hooks.md index 2c3cfa390..6bbef3b7c 100644 --- a/docs/lua/guides/hooks.md +++ b/docs/lua/guides/hooks.md @@ -146,7 +146,7 @@ The lua functions sent to `hook_event()` will be automatically called by SM64 wh | HOOK_MARIO_OVERRIDE_GEOMETRY_INPUTS | Called before running Mario's geometry input logic, return `false` to not run it. | [MarioState](../structs.md) m | | HOOK_ON_INTERACTIONS | Called when the Mario interactions are processed | [MarioState](../structs.md#MarioState) mario | | HOOK_ALLOW_FORCE_WATER_ACTION | Called when executing a non-water action while under the water's surface, or vice versa. Return `false` to prevent the player from being forced out of the action at the water's surface | [MarioState](../structs.md#MarioState) mario, `boolean` isInWaterAction | -| HOOK_BEFORE_WARP | Called before the local player warps. Return a table with `destLevel`, `destArea`, `destAreaWarpNode`, and `arg` to override the warp | `integer` destLevel, `integer` destArea, `integer` destAreaWarpNode, `integer` arg | +| HOOK_BEFORE_WARP | Called before the local player warps. Return a table with `destLevel`, `destArea`, `destWarpNode`, and `arg` to override the warp | `integer` destLevel, `integer` destArea, `integer` destWarpNode, `integer` arg | ### Parameters diff --git a/docs/lua/structs.md b/docs/lua/structs.md index bf7524f33..afd459a0b 100644 --- a/docs/lua/structs.md +++ b/docs/lua/structs.md @@ -100,7 +100,6 @@ - [SpawnParticlesInfo](#SpawnParticlesInfo) - [StarPositions](#StarPositions) - [StarsNeededForDialog](#StarsNeededForDialog) -- [Struct802A272C](#Struct802A272C) - [Surface](#Surface) - [TextureInfo](#TextureInfo) - [TransitionInfo](#TransitionInfo) @@ -120,7 +119,6 @@ - [WaterDropletParams](#WaterDropletParams) - [Waypoint](#Waypoint) - [Whirlpool](#Whirlpool) -- [struct802A1230](#struct802A1230)
@@ -3116,17 +3114,6 @@
-## [Struct802A272C](#Struct802A272C) - -| Field | Type | Access | -| ----- | ---- | ------ | -| vecF | [Vec3f](structs.md#Vec3f) | read-only | -| vecS | [Vec3s](structs.md#Vec3s) | read-only | - -[:arrow_up_small:](#) - -
- ## [Surface](#Surface) | Field | Type | Access | @@ -3385,14 +3372,3 @@
-## [struct802A1230](#struct802A1230) - -| Field | Type | Access | -| ----- | ---- | ------ | -| unk00 | `integer` | | -| unk02 | `integer` | | - -[:arrow_up_small:](#) - -
- diff --git a/src/audio/external.h b/src/audio/external.h index 355b7c523..e0381e2ae 100644 --- a/src/audio/external.h +++ b/src/audio/external.h @@ -133,9 +133,9 @@ void audio_set_sound_mode(u8 arg0); void audio_init(void); // in load.c -/* |description||descriptionEnd| */ +/* |description|Resets a sequence's (`seqId`) volume back to the default volume|descriptionEnd| */ void sound_reset_background_music_default_volume(u8 seqId); -/* |description||descriptionEnd| */ +/* |description|Sets a sequence's (`seqId`) volume to `volume`|descriptionEnd| */ void sound_set_background_music_default_volume(u8 seqId, u8 volume); #if defined(VERSION_EU) || defined(VERSION_SH) @@ -143,7 +143,9 @@ struct SPTask *unused_80321460(); struct SPTask *unused_80321460(void); #endif +/* |description|Gets a sound left/right pan using `x` and `z`|descriptionEnd| */ f32 get_sound_pan(f32 x, f32 z); +/* |description|Gets a sound level intensity based on `distance`|descriptionEnd| */ f32 sound_get_level_intensity(f32 distance); #endif // AUDIO_EXTERNAL_H diff --git a/src/engine/math_util.h b/src/engine/math_util.h index 344eb4f5b..d8acb9f45 100644 --- a/src/engine/math_util.h +++ b/src/engine/math_util.h @@ -287,7 +287,7 @@ void vec3f_get_dist_and_angle(Vec3f from, Vec3f to, f32 *dist, s16 *pitch, s16 * /* |description| Positions the point `to` at a given `dist`, `pitch`, and `yaw` relative to the point `from`. This can be used to place objects around a reference point at specific angles and distances |descriptionEnd| */ -void vec3f_set_dist_and_angle(Vec3f from, Vec3f to, f32 dist, s16 pitch, s16 yaw); +void vec3f_set_dist_and_angle(Vec3f from, Vec3f to, f32 dist, s16 pitch, s16 yaw); /* |description| Gradually moves an integer `current` value toward a `target` value, increasing it by `inc` if it is too low, or decreasing it by `dec` if it is too high. This is often used for smooth transitions or animations diff --git a/src/engine/surface_load.h b/src/engine/surface_load.h index c3753f47e..262958423 100644 --- a/src/engine/surface_load.h +++ b/src/engine/surface_load.h @@ -40,7 +40,7 @@ You must run this every frame in your object's behavior loop for it to have coll void load_object_collision_model(void); /* |description|Gets a surface corresponding to `index` from the surface pool buffer|descriptionEnd| */ struct Surface *obj_get_surface_from_index(struct Object *o, u32 index); -/* |description||descriptionEnd| */ +/* |description|Checks if a surface has force|descriptionEnd| */ bool surface_has_force(s16 surfaceType); #endif // SURFACE_LOAD_H diff --git a/src/game/area.c b/src/game/area.c index 5924145bb..095ea1603 100644 --- a/src/game/area.c +++ b/src/game/area.c @@ -147,18 +147,18 @@ void print_intro_text(void) { } } -u32 get_mario_spawn_type(struct Object *o) { - if (o == NULL || o->behavior == NULL) { return 0; } +enum MarioSpawnType get_mario_spawn_type(struct Object *o) { + if (o == NULL || o->behavior == NULL) { return MARIO_SPAWN_NONE; } const BehaviorScript *behavior = virtual_to_segmented(0x13, o->behavior); - if (behavior == NULL) { return 0; } + if (behavior == NULL) { return MARIO_SPAWN_NONE; } for (s32 i = 0; i < 20; i++) { - if (sWarpBhvSpawnTable[i] == behavior) { + if (sWarpBhvSpawnTable[i] == smlua_override_behavior(behavior)) { return sSpawnTypeFromWarpBhv[i]; } } - return 0; + return MARIO_SPAWN_NONE; } struct ObjectWarpNode *area_get_warp_node(u8 id) { diff --git a/src/game/area.h b/src/game/area.h index b49b1f45c..d7c4b1928 100644 --- a/src/game/area.h +++ b/src/game/area.h @@ -157,13 +157,15 @@ extern u8 gSpawnedStarHiddenCount; void override_viewport_and_clip(Vp *a, Vp *b, u8 c, u8 d, u8 e); void print_intro_text(void); -u32 get_mario_spawn_type(struct Object *o); +/* |description|Derives a `MARIO_SPAWN_*` constant from `o`|descriptionEnd| */ +enum MarioSpawnType get_mario_spawn_type(struct Object *o); /* |description| Finds a warp node in the current area by its ID. The warp node must exist in the list of warp nodes for the current area. Useful for locating a specific warp point in the level, such as teleportation zones or connections to other areas |descriptionEnd| */ struct ObjectWarpNode *area_get_warp_node(u8 id); +/* |description|Gets the first warp node found in the area, otherwise returns nil|descriptionEnd| */ struct ObjectWarpNode *area_get_any_warp_node(void); /* |description| @@ -179,7 +181,9 @@ void load_mario_area(void); void unload_mario_area(void); void change_area(s32 index); void area_update_objects(void); +/* |description|Plays a screen transition|descriptionEnd| */ void play_transition(s16 transType, s16 time, u8 red, u8 green, u8 blue); +/* |description|Plays a screen transition after a `delay` in frames|descriptionEnd| */ void play_transition_after_delay(s16 transType, s16 time, u8 red, u8 green, u8 blue, s16 delay); void render_game(void); diff --git a/src/game/camera.h b/src/game/camera.h index 4371cc168..e66f033ab 100644 --- a/src/game/camera.h +++ b/src/game/camera.h @@ -1152,6 +1152,7 @@ This function handles smooth transitions between different gameplay scenarios |descriptionEnd| */ s16 next_lakitu_state(Vec3f newPos, Vec3f newFoc, Vec3f curPos, Vec3f curFoc, Vec3f oldPos, Vec3f oldFoc, s16 yaw); +/* |description|Set the fixed camera base pos depending on the current level area|descriptionEnd| */ void set_fixed_cam_axis_sa_lobby(UNUSED s16 preset); /* |description| Processes course-specific camera settings, such as predefined positions or modes. diff --git a/src/game/characters.h b/src/game/characters.h index 229d1b8a4..f43256387 100644 --- a/src/game/characters.h +++ b/src/game/characters.h @@ -357,6 +357,7 @@ struct Character { struct MarioState; extern struct Character gCharacters[]; +/* |description|Gets a Character struct from `m`|descriptionEnd| */ struct Character* get_character(struct MarioState* m); /* |description| diff --git a/src/game/level_info.h b/src/game/level_info.h index 2dfafde74..49b760f87 100644 --- a/src/game/level_info.h +++ b/src/game/level_info.h @@ -15,7 +15,7 @@ Returns the name of the level corresponding to `courseNum`, `levelNum` and `area This function should not be used in Lua mods. Set `charCase` to 1 to capitalize or -1 to decapitalize the returned string |descriptionEnd| */ -const u8 *get_level_name_sm64(s16 courseNum, s16 levelNum, s16 areaIndex, s16 charCase); +const u8 *get_level_name_sm64(s16 courseNum, s16 levelNum, s16 areaIndex, s16 charCase); /* |description| Returns the name of the level corresponding to `courseNum`, `levelNum` and `areaIndex` as a decapitalized ASCII (human readable) string |descriptionEnd| */ @@ -30,7 +30,7 @@ Returns the name of the star corresponding to `courseNum` and `starNum` as an SM This function should not be used in Lua mods. Set `charCase` to 1 to capitalize or -1 to decapitalize the returned string |descriptionEnd| */ -const u8 *get_star_name_sm64(s16 courseNum, s16 starNum, s16 charCase); +const u8 *get_star_name_sm64(s16 courseNum, s16 starNum, s16 charCase); /* |description| Returns the name of the star corresponding to `courseNum` and `starNum` as a decapitalized ASCII (human readable) string |descriptionEnd| */ diff --git a/src/game/level_update.c b/src/game/level_update.c index e8ca64d7a..0f59b5457 100644 --- a/src/game/level_update.c +++ b/src/game/level_update.c @@ -419,7 +419,7 @@ void init_mario_after_warp(void) { if (spawnNode == NULL || spawnNode->object == NULL) { spawnNode = area_get_any_warp_node(); } if (spawnNode == NULL || spawnNode->object == NULL) { return; } - u32 marioSpawnType = get_mario_spawn_type(spawnNode->object); + enum MarioSpawnType marioSpawnType = get_mario_spawn_type(spawnNode->object); if (gMarioState && gMarioState->action != ACT_UNINITIALIZED) { for (s32 i = 0; i < MAX_PLAYERS; i++) { diff --git a/src/game/mario_actions_cutscene.c b/src/game/mario_actions_cutscene.c index 73991e386..d24f9b432 100644 --- a/src/game/mario_actions_cutscene.c +++ b/src/game/mario_actions_cutscene.c @@ -1944,8 +1944,7 @@ s32 act_taking_off_cap(struct MarioState *m) { /* |description| Handles the cutscene and animation sequence for when Mario is stuck in the ground (head, butt, or feet). Plays a designated `animation`, checks specific frames (`unstuckFrame`, `target2`, `target3`) for sound effects or transitions, and frees Mario to the `endAction` once the animation completes |descriptionEnd| */ -void stuck_in_ground_handler(struct MarioState *m, s32 animation, s32 unstuckFrame, s32 target2, - s32 target3, s32 endAction) { +void stuck_in_ground_handler(struct MarioState *m, s32 animation, s32 unstuckFrame, s32 target2, s32 target3, s32 endAction) { if (!m) { return; } s32 animFrame = set_character_animation(m, animation); diff --git a/src/game/mario_step.h b/src/game/mario_step.h index 37127e6ff..960e040d9 100644 --- a/src/game/mario_step.h +++ b/src/game/mario_step.h @@ -24,8 +24,8 @@ void stub_mario_step_2(void); /* |description|Reflects Mario off a wall if he is colliding with one and flips forward velocity if `negateSpeed` is TRUE |descriptionEnd| */ void mario_bonk_reflection(struct MarioState *m, u8 negateSpeed); void transfer_bully_speed(struct BullyCollisionData *obj1, struct BullyCollisionData *obj2); -BAD_RETURN(s32) init_bully_collision_data(struct BullyCollisionData *data, f32 posX, f32 posZ, - f32 forwardVel, s16 yaw, f32 conversionRatio, f32 radius); +/* |description|Sets the values of `data` for bully "collision"|descriptionEnd| */ +BAD_RETURN(s32) init_bully_collision_data(struct BullyCollisionData *data, f32 posX, f32 posZ, f32 forwardVel, s16 yaw, f32 conversionRatio, f32 radius); /* |description|Updates Mario's state in quicksand, sinks him at `sinkingSpeed` if he's in non instant quicksand|descriptionEnd| */ u32 mario_update_quicksand(struct MarioState *m, f32 sinkingSpeed); /* |description|Pushes Mario off a steep floor and sets his action to `action` with `actionArg`|descriptionEnd| */ diff --git a/src/game/obj_behaviors.c b/src/game/obj_behaviors.c index 581a4638b..8337e5c71 100644 --- a/src/game/obj_behaviors.c +++ b/src/game/obj_behaviors.c @@ -77,10 +77,7 @@ s16 sPrevCheckMarioRoom = 0; */ s8 sYoshiDead = FALSE; -/** - * Resets yoshi as spawned/despawned upon new file select. - * Possibly a function with stubbed code. - */ +/* |description|Resets Yoshi as being alive|descriptionEnd| */ void set_yoshi_as_not_dead(void) { sYoshiDead = FALSE; } @@ -128,9 +125,7 @@ Gfx UNUSED *geo_obj_transparency_something(s32 callContext, struct GraphNode *no return gfxHead; } -/** - * An absolute value function. - */ +/* |description|An absolute value (always positive) function.|descriptionEnd| */ f32 absf_2(f32 f) { if (f < 0) { f *= -1.0f; @@ -153,9 +148,7 @@ void turn_obj_away_from_surface(f32 velX, f32 velZ, f32 nX, UNUSED f32 nY, f32 n if (isnan(*objYawZ)) { *objYawZ = 0; } } -/** - * Finds any wall collisions, applies them, and turns away from the surface. - */ +/* |description|Finds any wall collisions, applies them, and turns away from the surface.|descriptionEnd| */ s8 obj_find_wall(f32 objNewX, f32 objY, f32 objNewZ, f32 objVelX, f32 objVelZ) { if (!o) { return 0; } struct WallCollisionData hitbox = { 0 }; @@ -195,9 +188,7 @@ s8 obj_find_wall(f32 objNewX, f32 objY, f32 objNewZ, f32 objVelX, f32 objVelZ) { return TRUE; } -/** - * Turns an object away from steep floors, similarly to walls. - */ +/* |description|Turns an object away from steep floors, similarly to walls.|descriptionEnd| */ s8 turn_obj_away_from_steep_floor(struct Surface *objFloor, f32 floorY, f32 objVelX, f32 objVelZ) { if (!o) { return 0; } f32 floor_nX, floor_nY, floor_nZ, objVelXCopy, objVelZCopy, objYawX, objYawZ; @@ -225,9 +216,7 @@ s8 turn_obj_away_from_steep_floor(struct Surface *objFloor, f32 floorY, f32 objV return TRUE; } -/** - * Orients an object with the given normals, typically the surface under the object. - */ +/* |description|Orients an object with the given normals, typically the surface under the object.|descriptionEnd| */ void obj_orient_graph(struct Object *obj, f32 normalX, f32 normalY, f32 normalZ) { if (!obj) { return; } Vec3f objVisualPosition, surfaceNormals; @@ -275,9 +264,7 @@ void calc_obj_friction(f32 *objFriction, f32 floor_nY) { } } -/** - * Updates an objects speed for gravity and updates Y position. - */ +/* |description|Updates an objects speed for gravity and updates Y position.|descriptionEnd| */ void calc_new_obj_vel_and_pos_y(struct Surface *objFloor, f32 objFloorY, f32 objVelX, f32 objVelZ) { if (!o) { return; } if (!objFloor) { return; } @@ -337,8 +324,8 @@ void calc_new_obj_vel_and_pos_y(struct Surface *objFloor, f32 objFloorY, f32 obj } } -void calc_new_obj_vel_and_pos_y_underwater(struct Surface *objFloor, f32 floorY, f32 objVelX, f32 objVelZ, - f32 waterY) { +/* |description|Adjusts the current object's veloicty and y position for being underwater|descriptionEnd| */ +void calc_new_obj_vel_and_pos_y_underwater(struct Surface *objFloor, f32 floorY, f32 objVelX, f32 objVelZ, f32 waterY) { if (!o) { return; } if (!objFloor) { return; } f32 floor_nX = objFloor->normal.x; @@ -406,9 +393,7 @@ void calc_new_obj_vel_and_pos_y_underwater(struct Surface *objFloor, f32 floorY, o->oVelY *= 0.8; } -/** - * Updates an objects position from oForwardVel and oMoveAngleYaw. - */ +/* |description|Updates an objects position from oForwardVel and oMoveAngleYaw.|descriptionEnd| */ void obj_update_pos_vel_xz(void) { if (!o) { return; } f32 xVel = o->oForwardVel * sins(o->oMoveAngleYaw); @@ -418,10 +403,7 @@ void obj_update_pos_vel_xz(void) { o->oPosZ += zVel; } -/** - * Generates splashes if at surface of water, entering water, or bubbles - * if underwater. - */ +/* |description|Generates splashes if at surface of water, entering water, or bubbles if underwater|descriptionEnd| */ void obj_splash(s32 waterY, s32 objY) { if (!o) { return; } u32 globalTimer = gGlobalTimer; @@ -441,10 +423,10 @@ void obj_splash(s32 waterY, s32 objY) { } } -/** - * Generic object move function. Handles walls, water, floors, and gravity. - * Returns flags for certain interactions. - */ +/* |description| +Generic object move function. Handles walls, water, floors, and gravity. +Returns flags for certain interactions +|descriptionEnd| */ s16 object_step(void) { if (!o) { return 0; } f32 objX = o->oPosX; @@ -493,10 +475,10 @@ s16 object_step(void) { return collisionFlags; } -/** - * Takes an object step but does not orient with the object's floor. - * Used for boulders, falling pillars, and the rolling snowman body. - */ +/* |description| +Takes an object step but does not orient with the object's floor. +Used for boulders, falling pillars, and the rolling snowman body +|descriptionEnd| */ s16 object_step_without_floor_orient(void) { s16 collisionFlags = 0; sOrientObjWithFloor = FALSE; @@ -506,13 +488,10 @@ s16 object_step_without_floor_orient(void) { return collisionFlags; } -/** - * Uses an object's forward velocity and yaw to move its X, Y, and Z positions. - * This does accept an object as an argument, though it is always called with `o`. - * If it wasn't called with `o`, it would modify `o`'s X and Z velocities based on - * `obj`'s forward velocity and yaw instead of `o`'s, and wouldn't update `o`'s - * position. - */ +/* |description| +Don't use this function outside of of a context where the current object and `obj` are the same. +Moves `obj` based on a seemingly random mix of using either the current obj or `obj`'s fields +|descriptionEnd| */ void obj_move_xyz_using_fvel_and_yaw(struct Object *obj) { if (!o || !obj) { return; } o->oVelX = obj->oForwardVel * sins(obj->oMoveAngleYaw); @@ -523,9 +502,7 @@ void obj_move_xyz_using_fvel_and_yaw(struct Object *obj) { obj->oPosZ += o->oVelZ; } -/** - * Checks if a point is within distance from Mario's graphical position. Test is exclusive. - */ +/* |description|Checks if a point is within distance from any active Mario visible to enemies' graphical position|descriptionEnd| */ s8 is_point_within_radius_of_mario(f32 x, f32 y, f32 z, s32 dist) { for (s32 i = 0; i < MAX_PLAYERS; i++) { if (!is_player_active(&gMarioStates[i])) { continue; } @@ -545,6 +522,7 @@ s8 is_point_within_radius_of_mario(f32 x, f32 y, f32 z, s32 dist) { return FALSE; } +/* |description|Checks if a point is within distance from any active Mario's graphical position|descriptionEnd| */ s8 is_point_within_radius_of_any_player(f32 x, f32 y, f32 z, s32 dist) { for (s32 i = 0; i < MAX_PLAYERS; i++) { if (!is_player_active(&gMarioStates[i])) { continue; } @@ -563,6 +541,7 @@ s8 is_point_within_radius_of_any_player(f32 x, f32 y, f32 z, s32 dist) { return FALSE; } +/* |description|Checks if `m` is in the current course/act/level/area and isn't bubbled|descriptionEnd| */ u8 is_player_active(struct MarioState* m) { if (!m) { return FALSE; } if (gNetworkType == NT_NONE && m == &gMarioStates[0]) { return TRUE; } @@ -582,6 +561,7 @@ u8 is_player_active(struct MarioState* m) { return TRUE; } +/* |description|Checks if any player besides the local player is in the current course/act/level/area|descriptionEnd| */ u8 is_other_player_active(void) { for (s32 i = 1; i < MAX_PLAYERS; i++) { struct MarioState *m = &gMarioStates[i]; @@ -590,6 +570,7 @@ u8 is_other_player_active(void) { return FALSE; } +/* |description|Checks if `m` is in the current course/act/level/area|descriptionEnd| */ u8 is_player_in_local_area(struct MarioState* m) { if (!m) { return FALSE; } if (gNetworkType == NT_NONE && m == &gMarioStates[0]) { return TRUE; } @@ -608,9 +589,7 @@ u8 is_player_in_local_area(struct MarioState* m) { return TRUE; } -/** - * Returns closest MarioState - */ +/* |description|Gets the nearest active Mario who isn't bubbled to `obj`|descriptionEnd| */ struct MarioState* nearest_mario_state_to_object(struct Object *obj) { if (!obj) { return NULL; } struct MarioState* nearest = NULL; @@ -630,6 +609,7 @@ struct MarioState* nearest_mario_state_to_object(struct Object *obj) { return nearest; } +/* |description|Gets the nearest possible Mario to `obj` despite anything like bubbled state or enemy visibility|descriptionEnd| */ struct MarioState* nearest_possible_mario_state_to_object(struct Object *obj) { if (!obj) { return NULL; } struct MarioState* nearest = NULL; @@ -648,9 +628,7 @@ struct MarioState* nearest_possible_mario_state_to_object(struct Object *obj) { return nearest; } -/** - * Returns closest marioObj - */ +/* |description|Gets the nearest player (Mario Object) to `obj`|descriptionEnd| */ struct Object* nearest_player_to_object(struct Object *obj) { if (!obj) { return NULL; } struct MarioState* nearest = nearest_mario_state_to_object(obj); @@ -658,9 +636,7 @@ struct Object* nearest_player_to_object(struct Object *obj) { return nearest->marioObj; } -/** - * Returns closest MarioState that's interacting with the object. - */ +/* |description|Gets the nearest interacting Mario to `obj`|descriptionEnd| */ struct MarioState *nearest_interacting_mario_state_to_object(struct Object *obj) { if (!obj) { return NULL; } struct MarioState *nearest = NULL; @@ -686,9 +662,7 @@ struct MarioState *nearest_interacting_mario_state_to_object(struct Object *obj) return nearest; } -/** - * Returns closest marioObj that's interacting with the object. - */ +/* |description|Gets the nearest interacting player (Mario Object) to `obj`|descriptionEnd| */ struct Object *nearest_interacting_player_to_object(struct Object *obj) { if (!obj) { return NULL; } struct MarioState *nearest = nearest_interacting_mario_state_to_object(obj); @@ -696,20 +670,14 @@ struct Object *nearest_interacting_player_to_object(struct Object *obj) { return nearest->marioObj; } -/** - * Returns whether or not the MarioState is the closet MarioState - * to the object. - */ +/* |description|Checks if `m` is the nearest Mario to `obj`|descriptionEnd| */ u8 is_nearest_mario_state_to_object(struct MarioState *m, struct Object *obj) { if (m == NULL || obj == NULL) { return FALSE; } struct MarioState *nearest = nearest_mario_state_to_object(obj); return m == nearest; } -/** - * Returns whether or not the player is the closet player - * to the object. - */ +/* |description|Checks if `m` is the nearest player (Mario Object) to `obj` |descriptionEnd| */ u8 is_nearest_player_to_object(struct Object *m, struct Object *obj) { if (m == NULL || obj == NULL) { return FALSE; } struct MarioState *nearest = nearest_mario_state_to_object(obj); @@ -717,9 +685,7 @@ u8 is_nearest_player_to_object(struct Object *m, struct Object *obj) { return m == nearest->marioObj; } -/** - * Checks whether a point is within distance of a given point. Test is exclusive. - */ +/* |description|Checks if a point is within `dist` of `obj`|descriptionEnd|*/ s8 is_point_close_to_object(struct Object *obj, f32 x, f32 y, f32 z, s32 dist) { if (!obj) { return FALSE; } f32 objX = obj->oPosX; @@ -734,9 +700,7 @@ s8 is_point_close_to_object(struct Object *obj, f32 x, f32 y, f32 z, s32 dist) { return FALSE; } -/** - * Sets an object as visible if within a certain distance of Mario's graphical position. - */ +/* |description|Sets an object as visible if within a certain distance of Mario's graphical position|descriptionEnd| */ void set_object_visibility(struct Object *obj, s32 dist) { if (!obj) { return; } s32 distanceToPlayer = dist_between_objects(obj, gMarioStates[0].marioObj); @@ -747,9 +711,7 @@ void set_object_visibility(struct Object *obj, s32 dist) { } } -/** - * Turns an object towards home if Mario is not near to it. - */ +/* |description|Turns an object towards home if Mario is not near to it|descriptionEnd| */ s8 obj_return_home_if_safe(struct Object *obj, f32 homeX, f32 y, f32 homeZ, s32 dist) { if (!obj) { return FALSE; } f32 homeDistX = homeX - obj->oPosX; @@ -765,9 +727,7 @@ s8 obj_return_home_if_safe(struct Object *obj, f32 homeX, f32 y, f32 homeZ, s32 return FALSE; } -/** - * Randomly displaces an objects home if RNG says to, and turns the object towards its home. - */ +/* |description|Randomly displaces an objects home if RNG says to, and turns the object towards its home|descriptionEnd| */ void obj_return_and_displace_home(struct Object *obj, f32 homeX, UNUSED f32 homeY, f32 homeZ, s32 baseDisp) { if (!obj) { return; } s16 angleToNewHome; @@ -784,10 +744,10 @@ void obj_return_and_displace_home(struct Object *obj, f32 homeX, UNUSED f32 home obj->oMoveAngleYaw = approach_s16_symmetric(obj->oMoveAngleYaw, angleToNewHome, 320); } -/** - * A series of checks using sin and cos to see if a given angle is facing in the same direction - * of a given angle, within a certain range. - */ +/* |description| +A series of checks using sin and cos to see if a given angle is facing in the same direction +of a given angle, within a certain range +|descriptionEnd|*/ s8 obj_check_if_facing_toward_angle(u32 base, u32 goal, s16 range) { s16 dAngle = (u16) goal - (u16) base; @@ -799,9 +759,7 @@ s8 obj_check_if_facing_toward_angle(u32 base, u32 goal, s16 range) { return FALSE; } -/** - * Finds any wall collisions and returns what the displacement vector would be. - */ +/* |description|Finds any wall collisions and returns what the displacement vector would be.|descriptionEnd| */ s8 obj_find_wall_displacement(Vec3f dist, f32 x, f32 y, f32 z, f32 radius) { struct WallCollisionData hitbox; UNUSED u8 filler[0x20]; @@ -822,10 +780,9 @@ s8 obj_find_wall_displacement(Vec3f dist, f32 x, f32 y, f32 z, f32 radius) { } } -/** - * Spawns a number of coins at the location of an object - * with a random forward velocity, y velocity, and direction. - */ +/* |description| +Spawns a number of coins at the location of an object with a random forward velocity, y velocity, and direction +|descriptionEnd| */ void obj_spawn_yellow_coins(struct Object *obj, s8 nCoins) { if (!o) { return; } if (!obj) { return; } @@ -844,9 +801,7 @@ void obj_spawn_yellow_coins(struct Object *obj, s8 nCoins) { rng_position_finish(); } -/** - * Controls whether certain objects should flicker/when to despawn. - */ +/* |description|Controls whether certain objects should flicker/when to despawn|descriptionEnd| */ s8 obj_flicker_and_disappear(struct Object *obj, s16 lifeSpan) { if (!obj) { return FALSE; } if (obj->oTimer < lifeSpan) { @@ -867,9 +822,7 @@ s8 obj_flicker_and_disappear(struct Object *obj, s16 lifeSpan) { return FALSE; } -/** - * Checks if a given room is Mario's current room, even if on an object. - */ +/* |description|Checks if a given room is Mario's current room, even if on an object|descriptionEnd| */ s8 current_mario_room_check(s16 room) { s16 result; @@ -924,9 +877,10 @@ s16 trigger_obj_dialog_when_facing(struct MarioState* m, s32 *inDialog, s16 dial return 0; } -/** - *Checks if a floor is one that should cause an object to "die". - */ +/* |description| +Checks if `floor`'s type is burning or death plane and if so change the +current object's action accordingly +|descriptionEnd| */ void obj_check_floor_death(s16 collisionFlags, struct Surface *floor) { if (!o) { return; } if (floor == NULL) { return; } @@ -946,10 +900,10 @@ void obj_check_floor_death(s16 collisionFlags, struct Surface *floor) { } } -/** - * Controls an object dying in lava by creating smoke, sinking the object, playing - * audio, and eventually despawning it. Returns TRUE when the obj is dead. - */ +/* |description| +Controls an object dying in lava by creating smoke, sinking the object, playing +audio, and eventually despawning it. Returns TRUE when the obj is dead +|descriptionEnd| */ s8 obj_lava_death(void) { if (!o) { return 0; } struct Object *deathSmoke; @@ -976,9 +930,7 @@ s8 obj_lava_death(void) { return FALSE; } -/** - * Spawns an orange number object relatively, such as those that count up for secrets. - */ +/* |description|Spawns an orange number object relatively, such as those that count up for secrets.|descriptionEnd| */ void spawn_orange_number(s8 behParam, s16 relX, s16 relY, s16 relZ) { struct Object *orangeNumber; orangeNumber = spawn_object_relative(behParam, relX, relY, relZ, o, MODEL_NUMBER, bhvOrangeNumber); diff --git a/src/game/object_helpers.c b/src/game/object_helpers.c index 6c4ea9475..52378fcf0 100644 --- a/src/game/object_helpers.c +++ b/src/game/object_helpers.c @@ -3476,6 +3476,7 @@ void cur_obj_spawn_star_at_y_offset(f32 targetX, f32 targetY, f32 targetZ, f32 o } #endif +/* |description|Sets the current object's home only the first time it's called|descriptionEnd| */ void cur_obj_set_home_once(void) { if (!o) { return; } if (o->setHome) { return; } @@ -3485,6 +3486,8 @@ void cur_obj_set_home_once(void) { o->oHomeZ = o->oPosZ; } + +/* |description|Gets a trajectory's length|descriptionEnd| */ s32 get_trajectory_length(Trajectory* trajectory) { if (!trajectory) { return 0; } s32 count = 0; diff --git a/src/game/object_helpers.h b/src/game/object_helpers.h index deef435c8..701b67cbb 100644 --- a/src/game/object_helpers.h +++ b/src/game/object_helpers.h @@ -40,16 +40,6 @@ struct WaterDropletParams f32 randSizeScale; }; -struct struct802A1230 { - /*0x00*/ s16 unk00; - /*0x02*/ s16 unk02; -}; - -struct Struct802A272C { - Vec3f vecF; - Vec3s vecS; -}; - // TODO: Field names struct SpawnParticlesInfo { diff --git a/src/pc/lua/smlua_cobject_autogen.c b/src/pc/lua/smlua_cobject_autogen.c index b53aea946..8d222bf3d 100644 --- a/src/pc/lua/smlua_cobject_autogen.c +++ b/src/pc/lua/smlua_cobject_autogen.c @@ -2655,12 +2655,6 @@ static struct LuaObjectField sStarsNeededForDialogFields[LUA_STARS_NEEDED_FOR_DI { "dialog6", LVT_U16, offsetof(struct StarsNeededForDialog, dialog6), false, LOT_NONE, 1, sizeof(u16) }, }; -#define LUA_STRUCT802_A272_C_FIELD_COUNT 2 -static struct LuaObjectField sStruct802A272CFields[LUA_STRUCT802_A272_C_FIELD_COUNT] = { - { "vecF", LVT_COBJECT, offsetof(struct Struct802A272C, vecF), true, LOT_VEC3F, 1, sizeof(Vec3f) }, - { "vecS", LVT_COBJECT, offsetof(struct Struct802A272C, vecS), true, LOT_VEC3S, 1, sizeof(Vec3s) }, -}; - #define LUA_SURFACE_FIELD_COUNT 16 static struct LuaObjectField sSurfaceFields[LUA_SURFACE_FIELD_COUNT] = { { "flags", LVT_S8, offsetof(struct Surface, flags), false, LOT_NONE, 1, sizeof(s8) }, @@ -2798,12 +2792,6 @@ static struct LuaObjectField sWhirlpoolFields[LUA_WHIRLPOOL_FIELD_COUNT] = { { "strength", LVT_S16, offsetof(struct Whirlpool, strength), false, LOT_NONE, 1, sizeof(s16) }, }; -#define LUA_STRUCT802_A1230_FIELD_COUNT 2 -static struct LuaObjectField sstruct802A1230Fields[LUA_STRUCT802_A1230_FIELD_COUNT] = { - { "unk00", LVT_S16, offsetof(struct struct802A1230, unk00), false, LOT_NONE, 1, sizeof(s16) }, - { "unk02", LVT_S16, offsetof(struct struct802A1230, unk02), false, LOT_NONE, 1, sizeof(s16) }, -}; - struct LuaObjectTable sLuaObjectAutogenTable[LOT_AUTOGEN_MAX - LOT_AUTOGEN_MIN] = { { LOT_ANIMINFO, sAnimInfoFields, LUA_ANIM_INFO_FIELD_COUNT }, { LOT_ANIMATION, sAnimationFields, LUA_ANIMATION_FIELD_COUNT }, @@ -2899,7 +2887,6 @@ struct LuaObjectTable sLuaObjectAutogenTable[LOT_AUTOGEN_MAX - LOT_AUTOGEN_MIN] { LOT_SPAWNPARTICLESINFO, sSpawnParticlesInfoFields, LUA_SPAWN_PARTICLES_INFO_FIELD_COUNT }, { LOT_STARPOSITIONS, sStarPositionsFields, LUA_STAR_POSITIONS_FIELD_COUNT }, { LOT_STARSNEEDEDFORDIALOG, sStarsNeededForDialogFields, LUA_STARS_NEEDED_FOR_DIALOG_FIELD_COUNT }, - { LOT_STRUCT802A272C, sStruct802A272CFields, LUA_STRUCT802_A272_C_FIELD_COUNT }, { LOT_SURFACE, sSurfaceFields, LUA_SURFACE_FIELD_COUNT }, { LOT_TEXTUREINFO, sTextureInfoFields, LUA_TEXTURE_INFO_FIELD_COUNT }, { LOT_TRANSITIONINFO, sTransitionInfoFields, LUA_TRANSITION_INFO_FIELD_COUNT }, @@ -2912,7 +2899,6 @@ struct LuaObjectTable sLuaObjectAutogenTable[LOT_AUTOGEN_MAX - LOT_AUTOGEN_MIN] { LOT_WATERDROPLETPARAMS, sWaterDropletParamsFields, LUA_WATER_DROPLET_PARAMS_FIELD_COUNT }, { LOT_WAYPOINT, sWaypointFields, LUA_WAYPOINT_FIELD_COUNT }, { LOT_WHIRLPOOL, sWhirlpoolFields, LUA_WHIRLPOOL_FIELD_COUNT }, - { LOT_STRUCT802A1230, sstruct802A1230Fields, LUA_STRUCT802_A1230_FIELD_COUNT }, }; const char *sLuaLotNames[] = { @@ -3021,7 +3007,6 @@ const char *sLuaLotNames[] = { [LOT_SPAWNPARTICLESINFO] = "SpawnParticlesInfo", [LOT_STARPOSITIONS] = "StarPositions", [LOT_STARSNEEDEDFORDIALOG] = "StarsNeededForDialog", - [LOT_STRUCT802A272C] = "Struct802A272C", [LOT_SURFACE] = "Surface", [LOT_TEXTUREINFO] = "TextureInfo", [LOT_TRANSITIONINFO] = "TransitionInfo", @@ -3034,7 +3019,6 @@ const char *sLuaLotNames[] = { [LOT_WATERDROPLETPARAMS] = "WaterDropletParams", [LOT_WAYPOINT] = "Waypoint", [LOT_WHIRLPOOL] = "Whirlpool", - [LOT_STRUCT802A1230] = "struct802A1230", }; const char *smlua_get_lot_name(u16 lot) { diff --git a/src/pc/lua/smlua_cobject_autogen.h b/src/pc/lua/smlua_cobject_autogen.h index 3a2cd4bd2..84e3223ad 100644 --- a/src/pc/lua/smlua_cobject_autogen.h +++ b/src/pc/lua/smlua_cobject_autogen.h @@ -113,7 +113,6 @@ enum LuaObjectAutogenType { LOT_SPAWNPARTICLESINFO, LOT_STARPOSITIONS, LOT_STARSNEEDEDFORDIALOG, - LOT_STRUCT802A272C, LOT_SURFACE, LOT_TEXTUREINFO, LOT_TRANSITIONINFO, @@ -126,7 +125,6 @@ enum LuaObjectAutogenType { LOT_WATERDROPLETPARAMS, LOT_WAYPOINT, LOT_WHIRLPOOL, - LOT_STRUCT802A1230, LOT_AUTOGEN_MAX, }; diff --git a/src/pc/lua/smlua_functions_autogen.c b/src/pc/lua/smlua_functions_autogen.c index c6062c2c8..2982c0eba 100644 --- a/src/pc/lua/smlua_functions_autogen.c +++ b/src/pc/lua/smlua_functions_autogen.c @@ -193,6 +193,24 @@ static void smlua_push_color(Color src, int index) { // area.h // //////////// +int smlua_func_get_mario_spawn_type(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_mario_spawn_type", 1, top); + return 0; + } + + if (lua_isnil(L, 1)) { return 0; } + struct Object* o = (struct Object*)smlua_to_cobject(L, 1, LOT_OBJECT); + if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "get_mario_spawn_type"); return 0; } + + lua_pushinteger(L, get_mario_spawn_type(o)); + + return 1; +} + int smlua_func_area_get_warp_node(lua_State* L) { if (L == NULL) { return 0; } @@ -210,6 +228,21 @@ int smlua_func_area_get_warp_node(lua_State* L) { return 1; } +int smlua_func_area_get_any_warp_node(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", "area_get_any_warp_node", 0, top); + return 0; + } + + + smlua_push_object(L, LOT_OBJECTWARPNODE, area_get_any_warp_node(), NULL); + + return 1; +} + int smlua_func_area_get_warp_node_from_params(lua_State* L) { if (L == NULL) { return 0; } @@ -228,6 +261,58 @@ int smlua_func_area_get_warp_node_from_params(lua_State* L) { return 1; } +int smlua_func_play_transition(lua_State* L) { + if (L == NULL) { return 0; } + + int top = lua_gettop(L); + if (top != 5) { + LOG_LUA_LINE("Improper param count for '%s': Expected %u, Received %u", "play_transition", 5, top); + return 0; + } + + s16 transType = smlua_to_integer(L, 1); + if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "play_transition"); return 0; } + s16 time = smlua_to_integer(L, 2); + if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 2, "play_transition"); return 0; } + u8 red = smlua_to_integer(L, 3); + if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 3, "play_transition"); return 0; } + u8 green = smlua_to_integer(L, 4); + if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 4, "play_transition"); return 0; } + u8 blue = smlua_to_integer(L, 5); + if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 5, "play_transition"); return 0; } + + play_transition(transType, time, red, green, blue); + + return 1; +} + +int smlua_func_play_transition_after_delay(lua_State* L) { + if (L == NULL) { return 0; } + + int top = lua_gettop(L); + if (top != 6) { + LOG_LUA_LINE("Improper param count for '%s': Expected %u, Received %u", "play_transition_after_delay", 6, top); + return 0; + } + + s16 transType = smlua_to_integer(L, 1); + if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "play_transition_after_delay"); return 0; } + s16 time = smlua_to_integer(L, 2); + if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 2, "play_transition_after_delay"); return 0; } + u8 red = smlua_to_integer(L, 3); + if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 3, "play_transition_after_delay"); return 0; } + u8 green = smlua_to_integer(L, 4); + if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 4, "play_transition_after_delay"); return 0; } + u8 blue = smlua_to_integer(L, 5); + if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 5, "play_transition_after_delay"); return 0; } + s16 delay = smlua_to_integer(L, 6); + if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 6, "play_transition_after_delay"); return 0; } + + play_transition_after_delay(transType, time, red, green, blue, delay); + + return 1; +} + //////////////////////// // behavior_actions.h // //////////////////////// @@ -21200,36 +21285,6 @@ int smlua_func_absf_2(lua_State* L) { return 1; } -int smlua_func_turn_obj_away_from_surface(lua_State* L) { - if (L == NULL) { return 0; } - - int top = lua_gettop(L); - if (top != 7) { - LOG_LUA_LINE("Improper param count for '%s': Expected %u, Received %u", "turn_obj_away_from_surface", 7, top); - return 0; - } - - f32 velX = smlua_to_number(L, 1); - if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "turn_obj_away_from_surface"); return 0; } - f32 velZ = smlua_to_number(L, 2); - if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 2, "turn_obj_away_from_surface"); return 0; } - f32 nX = smlua_to_number(L, 3); - if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 3, "turn_obj_away_from_surface"); return 0; } - f32 nY = smlua_to_number(L, 4); - if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 4, "turn_obj_away_from_surface"); return 0; } - f32 nZ = smlua_to_number(L, 5); - if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 5, "turn_obj_away_from_surface"); return 0; } - f32 * objYawX = (f32 *)smlua_to_cpointer(L, 6, LVT_F32_P); - if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 6, "turn_obj_away_from_surface"); return 0; } - f32 * objYawZ = (f32 *)smlua_to_cpointer(L, 7, LVT_F32_P); - if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 7, "turn_obj_away_from_surface"); return 0; } - - extern void turn_obj_away_from_surface(f32 velX, f32 velZ, f32 nX, UNUSED f32 nY, f32 nZ, f32 *objYawX, f32 *objYawZ); - turn_obj_away_from_surface(velX, velZ, nX, nY, nZ, objYawX, objYawZ); - - return 1; -} - int smlua_func_obj_find_wall(lua_State* L) { if (L == NULL) { return 0; } @@ -31731,31 +31786,6 @@ int smlua_func_set_water_level(lua_State* L) { return 1; } -int smlua_func_play_transition(lua_State* L) { - if (L == NULL) { return 0; } - - int top = lua_gettop(L); - if (top != 5) { - LOG_LUA_LINE("Improper param count for '%s': Expected %u, Received %u", "play_transition", 5, top); - return 0; - } - - s16 transType = smlua_to_integer(L, 1); - if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "play_transition"); return 0; } - s16 time = smlua_to_integer(L, 2); - if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 2, "play_transition"); return 0; } - u8 red = smlua_to_integer(L, 3); - if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 3, "play_transition"); return 0; } - u8 green = smlua_to_integer(L, 4); - if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 4, "play_transition"); return 0; } - u8 blue = smlua_to_integer(L, 5); - if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 5, "play_transition"); return 0; } - - play_transition(transType, time, red, green, blue); - - return 1; -} - int smlua_func_course_is_main_course(lua_State* L) { if (L == NULL) { return 0; } @@ -32069,7 +32099,7 @@ int smlua_func_get_environment_region(lua_State* L) { 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)); + lua_pushinteger(L, get_environment_region(index)); return 1; } @@ -32085,7 +32115,7 @@ int smlua_func_set_environment_region(lua_State* L) { 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); + s16 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); @@ -33740,26 +33770,6 @@ int smlua_func_stop_cap_music(UNUSED lua_State* L) { // spawn_sound.h // /////////////////// -int smlua_func_exec_anim_sound_state(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", "exec_anim_sound_state", 2, top); - return 0; - } - - if (lua_isnil(L, 1)) { return 0; } - struct SoundState* soundStates = (struct SoundState*)smlua_to_cobject(L, 1, LOT_SOUNDSTATE); - if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "exec_anim_sound_state"); return 0; } - u16 maxSoundStates = smlua_to_integer(L, 2); - if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 2, "exec_anim_sound_state"); return 0; } - - exec_anim_sound_state(soundStates, maxSoundStates); - - return 1; -} - int smlua_func_cur_obj_play_sound_1(lua_State* L) { if (L == NULL) { return 0; } @@ -34094,46 +34104,6 @@ int smlua_func_set_find_wall_direction(lua_State* L) { // surface_load.h // //////////////////// -int smlua_func_get_area_terrain_size(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_area_terrain_size", 1, top); - return 0; - } - - s16 * data = (s16 *)smlua_to_cpointer(L, 1, LVT_S16_P); - if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "get_area_terrain_size"); return 0; } - - lua_pushinteger(L, get_area_terrain_size(data)); - - return 1; -} - -int smlua_func_load_area_terrain(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", "load_area_terrain", 4, top); - return 0; - } - - s16 index = smlua_to_integer(L, 1); - if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "load_area_terrain"); return 0; } - s16 * data = (s16 *)smlua_to_cpointer(L, 2, LVT_S16_P); - if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 2, "load_area_terrain"); return 0; } - s8 * surfaceRooms = (s8 *)smlua_to_cpointer(L, 3, LVT_S8_P); - if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 3, "load_area_terrain"); return 0; } - s16 * macroObjects = (s16 *)smlua_to_cpointer(L, 4, LVT_S16_P); - if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 4, "load_area_terrain"); return 0; } - - load_area_terrain(index, data, surfaceRooms, macroObjects); - - return 1; -} - int smlua_func_load_object_collision_model(UNUSED lua_State* L) { if (L == NULL) { return 0; } @@ -34192,8 +34162,12 @@ void smlua_bind_functions_autogen(void) { lua_State* L = gLuaState; // area.h + smlua_bind_function(L, "get_mario_spawn_type", smlua_func_get_mario_spawn_type); smlua_bind_function(L, "area_get_warp_node", smlua_func_area_get_warp_node); + smlua_bind_function(L, "area_get_any_warp_node", smlua_func_area_get_any_warp_node); smlua_bind_function(L, "area_get_warp_node_from_params", smlua_func_area_get_warp_node_from_params); + smlua_bind_function(L, "play_transition", smlua_func_play_transition); + smlua_bind_function(L, "play_transition_after_delay", smlua_func_play_transition_after_delay); // behavior_actions.h smlua_bind_function(L, "spawn_mist_particles_variable", smlua_func_spawn_mist_particles_variable); @@ -35397,7 +35371,6 @@ void smlua_bind_functions_autogen(void) { smlua_bind_function(L, "set_yoshi_as_not_dead", smlua_func_set_yoshi_as_not_dead); //smlua_bind_function(L, "geo_obj_transparency_something", smlua_func_geo_obj_transparency_something); <--- UNIMPLEMENTED smlua_bind_function(L, "absf_2", smlua_func_absf_2); - smlua_bind_function(L, "turn_obj_away_from_surface", smlua_func_turn_obj_away_from_surface); smlua_bind_function(L, "obj_find_wall", smlua_func_obj_find_wall); smlua_bind_function(L, "turn_obj_away_from_steep_floor", smlua_func_turn_obj_away_from_steep_floor); smlua_bind_function(L, "obj_orient_graph", smlua_func_obj_orient_graph); @@ -35981,7 +35954,6 @@ void smlua_bind_functions_autogen(void) { smlua_bind_function(L, "movtexqc_register", smlua_func_movtexqc_register); smlua_bind_function(L, "get_water_level", smlua_func_get_water_level); smlua_bind_function(L, "set_water_level", smlua_func_set_water_level); - smlua_bind_function(L, "play_transition", smlua_func_play_transition); smlua_bind_function(L, "course_is_main_course", smlua_func_course_is_main_course); smlua_bind_function(L, "get_ttc_speed_setting", smlua_func_get_ttc_speed_setting); smlua_bind_function(L, "set_ttc_speed_setting", smlua_func_set_ttc_speed_setting); @@ -36100,7 +36072,6 @@ void smlua_bind_functions_autogen(void) { smlua_bind_function(L, "stop_cap_music", smlua_func_stop_cap_music); // spawn_sound.h - smlua_bind_function(L, "exec_anim_sound_state", smlua_func_exec_anim_sound_state); smlua_bind_function(L, "cur_obj_play_sound_1", smlua_func_cur_obj_play_sound_1); smlua_bind_function(L, "cur_obj_play_sound_2", smlua_func_cur_obj_play_sound_2); smlua_bind_function(L, "create_sound_spawner", smlua_func_create_sound_spawner); @@ -36120,8 +36091,6 @@ void smlua_bind_functions_autogen(void) { smlua_bind_function(L, "set_find_wall_direction", smlua_func_set_find_wall_direction); // surface_load.h - smlua_bind_function(L, "get_area_terrain_size", smlua_func_get_area_terrain_size); - smlua_bind_function(L, "load_area_terrain", smlua_func_load_area_terrain); smlua_bind_function(L, "load_object_collision_model", smlua_func_load_object_collision_model); smlua_bind_function(L, "obj_get_surface_from_index", smlua_func_obj_get_surface_from_index); smlua_bind_function(L, "surface_has_force", smlua_func_surface_has_force); diff --git a/src/pc/lua/utils/smlua_audio_utils.h b/src/pc/lua/utils/smlua_audio_utils.h index a644bb223..4fc276548 100644 --- a/src/pc/lua/utils/smlua_audio_utils.h +++ b/src/pc/lua/utils/smlua_audio_utils.h @@ -3,8 +3,10 @@ #include "pc/utils/miniaudio.h" +/* |description|Resets all custom sequences back to vanilla|descriptionEnd| */ void smlua_audio_utils_reset_all(void); bool smlua_audio_utils_override(u8 sequenceId, s32* bankId, void** seqData); +/* |description|Replaces the sequence corresponding to `sequenceId` with one called `m64Name`.m64 with `bankId` and `defaultVolume`|descriptionEnd| */ void smlua_audio_utils_replace_sequence(u8 sequenceId, u8 bankId, u8 defaultVolume, const char* m64Name); //////////////// @@ -41,15 +43,15 @@ void audio_stream_play(struct ModAudio* audio, bool restart, f32 volume); void audio_stream_pause(struct ModAudio* audio); /* |description|Stops an `audio` stream|descriptionEnd| */ void audio_stream_stop(struct ModAudio* audio); -/* |description|Gets the position of an `audio` stream|descriptionEnd| */ +/* |description|Gets the position of an `audio` stream in seconds|descriptionEnd| */ f32 audio_stream_get_position(struct ModAudio* audio); -/* |description|Sets the position of an `audio` stream|descriptionEnd| */ +/* |description|Sets the position of an `audio` stream in seconds|descriptionEnd| */ void audio_stream_set_position(struct ModAudio* audio, f32 pos); /* |description|Gets if an `audio` stream is looping or not|descriptionEnd| */ bool audio_stream_get_looping(struct ModAudio* audio); /* |description|Sets if an `audio` stream is looping or not|descriptionEnd| */ void audio_stream_set_looping(struct ModAudio* audio, bool looping); -/* |description|Sets an `audio` stream's loop points (samples)|descriptionEnd| */ +/* |description|Sets an `audio` stream's loop points in samples|descriptionEnd| */ void audio_stream_set_loop_points(struct ModAudio* audio, s64 loopStart, s64 loopEnd); /* |description|Gets the frequency of an `audio` stream|descriptionEnd| */ f32 audio_stream_get_frequency(struct ModAudio* audio); @@ -71,9 +73,7 @@ void audio_sample_stop(struct ModAudio* audio); void audio_sample_play(struct ModAudio* audio, Vec3f position, f32 volume); void audio_custom_update_volume(void); - void audio_custom_shutdown(void); - void smlua_audio_custom_deinit(void); #endif diff --git a/src/pc/lua/utils/smlua_camera_utils.h b/src/pc/lua/utils/smlua_camera_utils.h index a4fd5424f..5065d6d07 100644 --- a/src/pc/lua/utils/smlua_camera_utils.h +++ b/src/pc/lua/utils/smlua_camera_utils.h @@ -78,15 +78,15 @@ bool camera_config_is_x_inverted(void); /* |description|Checks if camera Y is inverted|descriptionEnd| */ bool camera_config_is_y_inverted(void); /* |description|Gets camera X sensitivity|descriptionEnd| */ -u32 camera_config_get_x_sensitivity(void); +u32 camera_config_get_x_sensitivity(void); /* |description|Gets camera Y sensitivity|descriptionEnd| */ -u32 camera_config_get_y_sensitivity(void); +u32 camera_config_get_y_sensitivity(void); /* |description|Gets camera aggression|descriptionEnd| */ -u32 camera_config_get_aggression(void); +u32 camera_config_get_aggression(void); /* |description|Gets camera pan level|descriptionEnd| */ -u32 camera_config_get_pan_level(void); +u32 camera_config_get_pan_level(void); /* |description|Gets camera deceleration|descriptionEnd| */ -u32 camera_config_get_deceleration(void); +u32 camera_config_get_deceleration(void); /* |description|Gets if the L button will center the camera|descriptionEnd| */ bool camera_config_get_centering(void); diff --git a/src/pc/lua/utils/smlua_collision_utils.h b/src/pc/lua/utils/smlua_collision_utils.h index 78ff439d4..8782fc37e 100644 --- a/src/pc/lua/utils/smlua_collision_utils.h +++ b/src/pc/lua/utils/smlua_collision_utils.h @@ -121,6 +121,7 @@ struct Surface* collision_find_floor(f32 x, f32 y, f32 z); /* |description|Finds a potential ceiling at the given `x`, `y`, and `z` values|descriptionEnd| */ struct Surface* collision_find_ceil(f32 x, f32 y, f32 z); +/* |description|Gets the generated water floor surface used when riding a shell|descriptionEnd| */ struct Surface* get_water_surface_pseudo_floor(void); /* |description|Gets the `Collision` with `name`|descriptionEnd| */ diff --git a/src/pc/lua/utils/smlua_misc_utils.c b/src/pc/lua/utils/smlua_misc_utils.c index 0248cbfc8..c3545f97f 100644 --- a/src/pc/lua/utils/smlua_misc_utils.c +++ b/src/pc/lua/utils/smlua_misc_utils.c @@ -484,16 +484,16 @@ void set_volume_env(f32 volume) { /// -f32 get_environment_region(u8 index) { - s32 idx = 6 * index; +s16 get_environment_region(u8 index) { + u8 idx = 6 * index; if (gEnvironmentRegions != NULL && index > 0 && index <= gEnvironmentRegions[0] && gEnvironmentRegionsLength > idx) { return gEnvironmentRegions[idx]; } return gLevelValues.floorLowerLimit; } -void set_environment_region(u8 index, s32 value) { - s32 idx = 6 * index; +void set_environment_region(u8 index, s16 value) { + u8 idx = 6 * index; if (gEnvironmentRegions != NULL && index > 0 && index <= gEnvironmentRegions[0] && gEnvironmentRegionsLength > idx) { gEnvironmentRegions[idx] = value; } diff --git a/src/pc/lua/utils/smlua_misc_utils.h b/src/pc/lua/utils/smlua_misc_utils.h index 3fda24b89..22e3765fe 100644 --- a/src/pc/lua/utils/smlua_misc_utils.h +++ b/src/pc/lua/utils/smlua_misc_utils.h @@ -96,7 +96,7 @@ void hud_show(void); /* |description|Checks if the HUD is hidden|descriptionEnd| */ bool hud_is_hidden(void); /* |description|Gets a HUD display value|descriptionEnd| */ -s32 hud_get_value(enum HudDisplayValue type); +s32 hud_get_value(enum HudDisplayValue type); /* |description|Sets a HUD display value|descriptionEnd| */ void hud_set_value(enum HudDisplayValue type, s32 value); /* |description|Renders a power meter on the HUD|descriptionEnd| */ @@ -143,9 +143,6 @@ s16 get_water_level(u8 index); /* |description|Sets the water level in an area corresponding to `index` (0-indexed)|descriptionEnd| */ void set_water_level(u8 index, s16 height, bool sync); -/* |description|Plays a screen transition|descriptionEnd| */ -void play_transition(s16 transType, s16 time, u8 red, u8 green, u8 blue); - /* |description|Checks if a course is a main course and not the castle or secret levels|descriptionEnd| */ bool course_is_main_course(u16 courseNum); @@ -193,9 +190,9 @@ void set_volume_sfx(f32 volume); void set_volume_env(f32 volume); /* |description|Gets an environment region (gas/water boxes) height value|descriptionEnd| */ -f32 get_environment_region(u8 index); +s16 get_environment_region(u8 index); /* |description|Sets an environment region (gas/water boxes) height value|descriptionEnd| */ -void set_environment_region(u8 index, s32 value); +void set_environment_region(u8 index, s16 value); /* |description|Checks if a file exists inside of a mod|descriptionEnd| */ bool mod_file_exists(const char* filename); diff --git a/src/pc/network/network_player.h b/src/pc/network/network_player.h index ed1dcb0b3..b0bc7df9e 100644 --- a/src/pc/network/network_player.h +++ b/src/pc/network/network_player.h @@ -77,19 +77,31 @@ bool network_player_name_valid(char* buffer); void network_player_init(void); void network_player_update_model(u8 localIndex); bool network_player_any_connected(void); +/* |description|Gets the amount of players connected|descriptionEnd| */ u8 network_player_connected_count(void); +/* |description|Sets the description field of `np`|descriptionEnd| */ void network_player_set_description(struct NetworkPlayer* np, const char* description, u8 r, u8 g, u8 b, u8 a); +/* |description|Overrides the location of `np`|descriptionEnd| */ void network_player_set_override_location(struct NetworkPlayer *np, const char *location); +/* |description|Gets a network player from `globalIndex`|descriptionEnd| */ struct NetworkPlayer* network_player_from_global_index(u8 globalIndex); +/* |description|Gets the first network player whose information matches `courseNum`, `actNum`, and `levelNum`|descriptionEnd| */ struct NetworkPlayer* get_network_player_from_level(s16 courseNum, s16 actNum, s16 levelNum); +/* |description|Gets the first network player whose information matches `courseNum`, `actNum`, `levelNum`, and `areaIndex`|descriptionEnd| */ struct NetworkPlayer* get_network_player_from_area(s16 courseNum, s16 actNum, s16 levelNum, s16 areaIndex); +/* |description|Gets the active network player with the smallest global index. Useful for assigning one player to "own" some kind of functionality or object|descriptionEnd| */ struct NetworkPlayer* get_network_player_smallest_global(void); +/* |description|Gets a red, green, or blue value from a part in `np`'s color palette|descriptionEnd| */ u8 network_player_get_palette_color_channel(struct NetworkPlayer *np, enum PlayerPart part, u8 index); +/* |description|Gets a red, green, or blue value from a part in `np`'s override color palette|descriptionEnd| */ u8 network_player_get_override_palette_color_channel(struct NetworkPlayer *np, enum PlayerPart part, u8 index); +/* |description|Sets the `part in `np`'s override color palette`|descriptionEnd| */ void network_player_set_override_palette_color(struct NetworkPlayer *np, enum PlayerPart part, Color color); +/* |description|Resets `np`'s override color palette|descriptionEnd| */ void network_player_reset_override_palette(struct NetworkPlayer *np); +/* |description|Checks if `np`'s override color palette is identical to the regular color palette|descriptionEnd| */ bool network_player_is_override_palette_same(struct NetworkPlayer *np); void network_player_update(void);