sm64coopdx/docs/lua/functions-8.md
2025-11-30 02:15:38 -06:00

14 KiB

Lua Functions


< prev | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8]


functions from spawn_sound.h


cur_obj_play_sound_1

Description

Plays a sound if the current object is visible

Lua Example

local <generator object doc_function.<locals>.<genexpr> at 0x000001e039c74f20> = cur_obj_play_sound_1(soundMagic)

Parameters

Field Type
soundMagic integer

Returns

  • None

C Prototype

void cur_obj_play_sound_1(s32 soundMagic);

🔼


cur_obj_play_sound_2

Description

Plays a sound if the current object is visible and queues rumble for specific sounds

Lua Example

local <generator object doc_function.<locals>.<genexpr> at 0x000001e039c75000> = cur_obj_play_sound_2(soundMagic)

Parameters

Field Type
soundMagic integer

Returns

  • None

C Prototype

void cur_obj_play_sound_2(s32 soundMagic);

🔼


create_sound_spawner

Description

Create a sound spawner for objects that need a sound play once. (Breakable walls, King Bobomb exploding, etc)

Lua Example

local <generator object doc_function.<locals>.<genexpr> at 0x000001e039c74f20> = create_sound_spawner(soundMagic)

Parameters

Field Type
soundMagic integer

Returns

  • None

C Prototype

void create_sound_spawner(s32 soundMagic);

🔼


calc_dist_to_volume_range_1

Description

Unused vanilla function, calculates a volume based on distance. If distance is less than 500 then 127, if distance is greater than 1500 then 0, if distance is between 500 and 1500 then it ranges linearly from 60 to 124. What an even more strange and confusing function

Lua Example

local <generator object doc_function.<locals>.<genexpr> at 0x000001e039c74f20> = calc_dist_to_volume_range_1(distance)

Parameters

Field Type
distance number

Returns

  • integer

C Prototype

s32 calc_dist_to_volume_range_1(f32 distance);

🔼


calc_dist_to_volume_range_2

Description

Unused vanilla function, calculates a volume based on distance. If distance is less than 1300 then 127, if distance is greater than 2300 then 0, if distance is between 1300 and 2300 then it ranges linearly from 60 to 127. What a strange and confusing function

Lua Example

local <generator object doc_function.<locals>.<genexpr> at 0x000001e039c74f20> = calc_dist_to_volume_range_2(distance)

Parameters

Field Type
distance number

Returns

  • integer

C Prototype

s32 calc_dist_to_volume_range_2(f32 distance);

🔼



functions from surface_collision.h


find_wall_collisions

Description

Detects wall collisions at a given position and adjusts the position based on the walls found. Returns the number of wall collisions detected

Lua Example

local <generator object doc_function.<locals>.<genexpr> at 0x000001e039c74f20> = find_wall_collisions(colData)

Parameters

Field Type
colData WallCollisionData

Returns

  • integer

C Prototype

s32 find_wall_collisions(struct WallCollisionData *colData);

🔼


find_ceil

Lua Example

local <generator object doc_function.<locals>.<genexpr> at 0x000001e039c74f20> = find_ceil(posX, posY, posZ, pceil)

Parameters

Field Type
posX number
posY number
posZ number
pceil Surface

Returns

  • number

C Prototype

f32 find_ceil(f32 posX, f32 posY, f32 posZ, struct Surface **pceil);

🔼


find_ceil_height

Description

Finds the height of the highest ceiling above a given position (x, y, z). If no ceiling is found, returns the default height limit of gLevelValues.cellHeightLimit(20000 by default)

Lua Example

local <generator object doc_function.<locals>.<genexpr> at 0x000001e039c74f20> = find_ceil_height(x, y, z)

Parameters

Field Type
x number
y number
z number

Returns

  • number

C Prototype

f32 find_ceil_height(f32 x, f32 y, f32 z);

🔼


find_floor_height_and_data

Lua Example

local <generator object doc_function.<locals>.<genexpr> at 0x000001e039c74f20> = find_floor_height_and_data(xPos, yPos, zPos, floorGeo)

Parameters

Field Type
xPos number
yPos number
zPos number
floorGeo FloorGeometry

Returns

  • number

C Prototype

f32 find_floor_height_and_data(f32 xPos, f32 yPos, f32 zPos, struct FloorGeometry **floorGeo);

🔼


find_floor_height

Description

Finds the height of the highest floor below a given position (x, y, z). If no floor is found, returns the default floor height of gLevelValues.floorLowerLimit(-11000 by default)

Lua Example

local <generator object doc_function.<locals>.<genexpr> at 0x000001e039c74f20> = find_floor_height(x, y, z)

Parameters

Field Type
x number
y number
z number

Returns

  • number

C Prototype

f32 find_floor_height(f32 x, f32 y, f32 z);

🔼


find_floor

Lua Example

local <generator object doc_function.<locals>.<genexpr> at 0x000001e039c74f20> = find_floor(xPos, yPos, zPos, pfloor)

Parameters

Field Type
xPos number
yPos number
zPos number
pfloor Surface

Returns

  • number

C Prototype

f32 find_floor(f32 xPos, f32 yPos, f32 zPos, struct Surface **pfloor);

🔼


find_water_level

Description

Finds the height of water at a given position (x, z), if the position is within a water region. If no water is found, returns the default height of gLevelValues.floorLowerLimit(-11000 by default)

Lua Example

local <generator object doc_function.<locals>.<genexpr> at 0x000001e039c74f20> = find_water_level(x, z)

Parameters

Field Type
x number
z number

Returns

  • number

C Prototype

f32 find_water_level(f32 x, f32 z);

🔼


find_poison_gas_level

Description

Finds the height of the poison gas at a given position (x, z), if the position is within a gas region. If no gas is found, returns the default height of gLevelValues.floorLowerLimit(-11000 by default)

Lua Example

local <generator object doc_function.<locals>.<genexpr> at 0x000001e039c74f20> = find_poison_gas_level(x, z)

Parameters

Field Type
x number
z number

Returns

  • number

C Prototype

f32 find_poison_gas_level(f32 x, f32 z);

🔼


find_surface_on_ray

Lua Example

local <generator object doc_function.<locals>.<genexpr> at 0x000001e039c74f20> = find_surface_on_ray(orig, dir, hit_surface, hit_pos, precision)

Parameters

Field Type
orig Vec3f
dir Vec3f
hit_surface Surface
hit_pos Vec3f
precision number

Returns

  • None

C Prototype

void find_surface_on_ray(Vec3f orig, Vec3f dir, struct Surface **hit_surface, Vec3f hit_pos, f32 precision);

🔼


set_find_wall_direction

Description

Sets whether collision finding functions should check wall directions.

Lua Example

local <generator object doc_function.<locals>.<genexpr> at 0x000001e039c74f20> = set_find_wall_direction(dir, active, airborne)

Parameters

Field Type
dir Vec3f
active boolean
airborne boolean

Returns

  • None

C Prototype

void set_find_wall_direction(Vec3f dir, bool active, bool airborne);

🔼


closest_point_to_triangle

Description

Gets the closest point of the triangle to src and returns it in out.

Lua Example

local <generator object doc_function.<locals>.<genexpr> at 0x000001e039c74f20> = closest_point_to_triangle(surf, src, out)

Parameters

Field Type
surf Surface
src Vec3f
out Vec3f

Returns

  • None

C Prototype

void closest_point_to_triangle(struct Surface* surf, Vec3f src, OUT Vec3f out);

🔼



functions from surface_load.h


load_object_collision_model

Description

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

Lua Example

local <generator object doc_function.<locals>.<genexpr> at 0x000001e039c74f20> = load_object_collision_model()

Parameters

  • None

Returns

  • None

C Prototype

void load_object_collision_model(void);

🔼


load_static_object_collision

Description

Loads the object's collision data into static collision. You may run this only once to capture the object's collision at that frame.

Lua Example

local <generator object doc_function.<locals>.<genexpr> at 0x000001e039c74f20> = load_static_object_collision()

Parameters

  • None

Returns

C Prototype

struct StaticObjectCollision *load_static_object_collision();

🔼


toggle_static_object_collision

Description

Toggles a collection of static object surfaces

Lua Example

local <generator object doc_function.<locals>.<genexpr> at 0x000001e039c74f20> = toggle_static_object_collision(col, tangible)

Parameters

Field Type
col StaticObjectCollision
tangible boolean

Returns

  • None

C Prototype

void toggle_static_object_collision(struct StaticObjectCollision *col, bool tangible);

🔼


get_static_object_surface

Description

Gets a surface corresponding to index from the static object collision

Lua Example

local <generator object doc_function.<locals>.<genexpr> at 0x000001e039c74f20> = get_static_object_surface(col, index)

Parameters

Field Type
col StaticObjectCollision
index integer

Returns

C Prototype

struct Surface *get_static_object_surface(struct StaticObjectCollision *col, u32 index);

🔼


obj_get_surface_from_index

Description

Gets a surface corresponding to index from the surface pool buffer

Lua Example

local <generator object doc_function.<locals>.<genexpr> at 0x000001e039c74f20> = obj_get_surface_from_index(o, index)

Parameters

Field Type
o Object
index integer

Returns

C Prototype

struct Surface *obj_get_surface_from_index(struct Object *o, u32 index);

🔼


surface_has_force

Description

Checks if a surface has force

Lua Example

local <generator object doc_function.<locals>.<genexpr> at 0x000001e039c74f20> = surface_has_force(surfaceType)

Parameters

Field Type
surfaceType integer

Returns

  • boolean

C Prototype

bool surface_has_force(s16 surfaceType);

🔼



functions from sync_object.h


sync_object_get_object

Description

Retrieves an object from a sync ID

Lua Example

local <generator object doc_function.<locals>.<genexpr> at 0x000001e039c74f20> = sync_object_get_object(syncId)

Parameters

Field Type
syncId integer

Returns

C Prototype

struct Object* sync_object_get_object(u32 syncId);

🔼


sync_object_is_initialized

Description

Checks if a sync object is initialized using a syncId

Lua Example

local <generator object doc_function.<locals>.<genexpr> at 0x000001e039c74f20> = sync_object_is_initialized(syncId)

Parameters

Field Type
syncId integer

Returns

  • boolean

C Prototype

bool sync_object_is_initialized(u32 syncId);

🔼


sync_object_is_owned_locally

Description

Checks if a sync object is owned locally using a syncId

Lua Example

local <generator object doc_function.<locals>.<genexpr> at 0x000001e039c74f20> = sync_object_is_owned_locally(syncId)

Parameters

Field Type
syncId integer

Returns

  • boolean

C Prototype

bool sync_object_is_owned_locally(u32 syncId);

🔼



< prev | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8]