sm64coopdx/docs/lua/functions.md
2024-06-27 16:54:13 -04:00

127 KiB

Lua Reference


1 | 2 | 3 | 4 | 5 | next >]


Supported Functions













































  • smlua_deprecated.h













manually written functions

define_custom_obj_fields

Defines a custom set of overlapping object fields.

The fieldTable table's keys must start with the letter o and the values must be either u32, s32, or f32.

Lua Example

define_custom_obj_fields({ oCustomField1 = 'u32', oCustomField2 = 's32', oCustomField3 = 'f32' })

Parameters

Field Type
fieldTable Lua Table

C Prototype

N/A

🔼

network_init_object

Enables synchronization on an object.

  • Setting standardSync to true will automatically synchronize the object at a rate that is determined based on player distance. The commonly used object fields will be automatically synchronized.
  • Setting standardSync to false will not automatically synchronize the object, or add commonly used object fields. The mod must manually call network_send_object() when fields have changed.

The fieldTable parameter can be nil, or a list of object fields.

Lua Example

network_init_object(obj, true, { 'oCustomField1', 'oCustomField2', 'oCustomField3' })

Parameters

Field Type
object Object
standardSync bool
fieldTable Lua Table

C Prototype

N/A

🔼


network_send_object

Sends a packet that synchronizes an object. This does not need to be called when standardSync is enabled.

The reliable field will ensure that the packet arrives, but should be used sparingly and only when missing a packet would cause a desync.

Lua Example

network_send_object(obj, false)

Parameters

Field Type
object Object
reliable bool

C Prototype

N/A

🔼


network_send_to

Sends a packet to a particular player (using their local index) containing whatever data you want.

dataTable can only contain strings, integers, numbers, booleans, and nil

The reliable field will ensure that the packet arrives, but should be used sparingly and only when missing a packet would cause a desync.

Lua Example

network_send_to(localPlayerIndex, reliable, { data1 = 'hello', data2 = 10})

Parameters

Field Type
localPlayerIndex integer
reliable bool
dataTable table

C Prototype

N/A

🔼


network_send

Sends a packet to all players containing whatever data you want.

dataTable can only contain strings, integers, numbers, booleans, and nil

The reliable field will ensure that the packet arrives, but should be used sparingly and only when missing a packet would cause a desync.

Lua Example

network_send(reliable, { data1 = 'hello', data2 = 10})

Parameters

Field Type
reliable bool
dataTable table

C Prototype

N/A

🔼


get_texture_info

Retrieves a texture by name.

Lua Example

get_texture_info(textureName)

Parameters

Field Type
textureName string

Returns

C Prototype

N/A

🔼


djui_hud_render_texture

Renders a texture to the screen.

Lua Example

djui_hud_render_texture(texInfo, 0, 0, 1, 1)

Parameters

Field Type
texInfo TextureInfo
x number
y number
scaleW number
scaleH number

Returns

  • None

C Prototype

void djui_hud_render_texture(struct TextureInfo* texInfo, f32 x, f32 y, f32 scaleW, f32 scaleH);

🔼


djui_hud_render_texture_tile

Renders a tile of a texture to the screen.

Lua Example

djui_hud_render_texture_tile(texInfo, 0, 0, 1, 1, 0, 0, 16, 16)

Parameters

Field Type
texInfo TextureInfo
x number
y number
scaleW number
scaleH number
tileX number
tileY number
tileW number
tileH number

Returns

  • None

C Prototype

void djui_hud_render_texture_tile(struct TextureInfo* texInfo, f32 x, f32 y, f32 scaleW, f32 scaleH, u32 tileX, u32 tileY, u32 tileW, u32 tileH);

🔼


djui_hud_render_texture_tile_interpolated

Renders an interpolated tile of a texture to the screen.

Lua Example

djui_hud_render_texture_tile_interpolated(texInfo, prevX, prevY, prevScaleW, prevScaleH, 0, 0, 1, 1, 0, 0, 16, 16)

Parameters

Field Type
texInfo TextureInfo
prevX number
prevY number
prevScaleW number
prevScaleH number
x number
y number
scaleW number
scaleH number
tileX number
tileY number
tileW number
tileH number

Returns

  • None

C Prototype

void djui_hud_render_texture_tile_interpolated(struct TextureInfo* texInfo, f32 prevX, f32 prevY, f32 prevScaleW, f32 prevScaleH, f32 x, f32 y, f32 scaleW, f32 scaleH, u32 tileX, u32 tileY, u32 tileW, u32 tileH);

🔼


texture_override_reset

Resets an overridden texture.

Lua Example

texture_override_reset("outside_09004000")

Parameters

Field Type
textureName string

Returns

  • None

C Prototype

void dynos_texture_override_reset(const char* textureName);

🔼


texture_override_set

Overrides a texture with a custom TextureInfo.

Lua Example

texture_override_set("outside_09004000", overrideTexInfo)

Parameters

Field Type
textureName string
overrideTexInfo TextureInfo

Returns

  • None

C Prototype

void dynos_texture_override_set(const char* textureName, struct TextureInfo* overrideTexInfo);

🔼


smlua_anim_util_register_animation

Register a new Lua animation.

Lua Example

smlua_anim_util_register_animation("apparition_idle", 0, 189, 0, 0, 0x5A, values, index)

Parameters

Field Type
name string
flags integer
animYTransDivisor integer
startFrame integer
loopStart integer
loopEnd integer
values table
index table

Returns

  • None

C Prototype

void smlua_anim_util_register_animation(const char *name, s16 flags, s16 animYTransDivisor, s16 startFrame, s16 loopStart, s16 loopEnd, s16 *values, u32 valuesLength, u16 *index, u32 indexLength);

🔼


level_script_parse

Lua Example

level_script_parse(LEVEL_BOB, func)

Parses a level script and passes area index, behavior data, macro behavior IDs and macro behavior arguments to a function.

Parameters

Field Type
levelNum LevelNum
func function

Returns

  • None

C Prototype

void smlua_func_level_script_parse(lua_State* L);

🔼


log_to_console

Logs a message to the in-game console.

Lua Example

log_to_console("sm64coopdx FTW", CONSOLE_MESSAGE_INFO)

Parameters

Field Type
message string
level (optional) ConsoleMessageLevel

Returns

  • None

C Prototype

void log_to_console(const char* message, enum ConsoleMessageLevel level);

🔼


add_scroll_target

Registers a vertex buffer to be used for a scrolling texture. Should be used with RM_Scroll_Texture or editor_Scroll_Texture

Lua Example

add_scroll_target(0, "arena_rainbow_dl_StarRoad_mesh_layer_5_vtx_0")

Parameters

Field Type
index integer
name string

Returns

  • None

C Prototype

void dynos_add_scroll_target(u32 index, const char *name, u32 offset, u32 size);

🔼


collision_find_surface_on_ray

Shoots a raycast from startX, startY, and startZ in the direction of dirX, dirY, and dirZ.

Lua Example

collision_find_surface_on_ray(0, 0, 0, 50, 100, 50)

Parameters

Field Type
startX number
startY number
startZ number
dirX number
dirY number
dirZ number
precision (optional) number

Returns

C Prototype

struct RayIntersectionInfo* collision_find_surface_on_ray(f32 startX, f32 startY, f32 startZ, f32 dirX, f32 dirY, f32 dirZ, f32 precision);

🔼



functions from area.h


area_get_warp_node

Lua Example

local ObjectWarpNodeValue = area_get_warp_node(id)

Parameters

Field Type
id integer

Returns

ObjectWarpNode

C Prototype

struct ObjectWarpNode *area_get_warp_node(u8 id);

🔼


area_get_warp_node_from_params

Lua Example

local ObjectWarpNodeValue = area_get_warp_node_from_params(o)

Parameters

Field Type
o Object

Returns

ObjectWarpNode

C Prototype

struct ObjectWarpNode *area_get_warp_node_from_params(struct Object *o);

🔼


---

1 | 2 | 3 | 4 | 5 | next >]