From 7c60986448edd0977a52777c135f44e3eebe8dc4 Mon Sep 17 00:00:00 2001 From: Cooliokid956 <68075390+Cooliokid956@users.noreply.github.com> Date: Sun, 30 Nov 2025 02:12:15 -0600 Subject: [PATCH] Relocate these functions LVT_FIELD shouldn't be there yet --- autogen/common.py | 6 +--- autogen/lua_definitions/functions.lua | 16 +++++++++ docs/lua/functions-6.md | 48 +++++++++++++++++++++++++++ docs/lua/functions.md | 2 ++ src/pc/lua/smlua_cobject.c | 1 - src/pc/lua/smlua_functions.c | 32 ------------------ src/pc/lua/smlua_functions_autogen.c | 36 ++++++++++++++++++++ src/pc/lua/utils/smlua_gfx_utils.c | 22 ++++++++++++ src/pc/lua/utils/smlua_gfx_utils.h | 11 ++++++ 9 files changed, 136 insertions(+), 38 deletions(-) diff --git a/autogen/common.py b/autogen/common.py index 2c325cae1..9b488e723 100644 --- a/autogen/common.py +++ b/autogen/common.py @@ -254,11 +254,7 @@ def translate_type_to_lot(ptype, allowArrays=True): def translate_type_to_lua(ptype): if type(ptype) is list: - rt, rl = [], [] - for _t in ptype: - t, l = translate_type_to_lua(_t) - rt.append(t); rl.append(l) - return rt, rl + return [list(tup) for tup in zip(*[translate_type_to_lua(t) for t in ptype])] if ptype == 'const char*': return '`string`', None diff --git a/autogen/lua_definitions/functions.lua b/autogen/lua_definitions/functions.lua index 676240c49..ef6d7b5a2 100644 --- a/autogen/lua_definitions/functions.lua +++ b/autogen/lua_definitions/functions.lua @@ -10805,6 +10805,14 @@ function gfx_get_texture(cmd) -- ... end +--- @param name string +--- @return Pointer_Gfx +--- @return integer +--- Gets a display list of the current mod from its name. Returns a pointer to the display list and its length +function gfx_get_from_name(name) + -- ... +end + --- @param gfx Pointer_Gfx --- @return string --- Gets the name of a display list @@ -10868,6 +10876,14 @@ function gfx_delete_all() -- ... end +--- @param name string +--- @return Pointer_Vtx +--- @return integer +--- Gets a vertex buffer of the current mod from its name. Returns a pointer to the vertex buffering and its vertex count +function vtx_get_from_name(name) + -- ... +end + --- @param vtx Pointer_Vtx --- @return string --- Gets the name of a vertex buffer diff --git a/docs/lua/functions-6.md b/docs/lua/functions-6.md index c54d779d1..cc4f0621e 100644 --- a/docs/lua/functions-6.md +++ b/docs/lua/functions-6.md @@ -8032,6 +8032,30 @@ Gets the texture from a display list command if it has an image related op
+## [gfx_get_from_name](#gfx_get_from_name) + +### Description +Gets a display list of the current mod from its name. Returns a pointer to the display list and its length + +### Lua Example +`local PointerValue, integerValue = gfx_get_from_name(name)` + +### Parameters +| Field | Type | +| ----- | ---- | +| name | `string` | + +### Returns +- `Pointer` <`Gfx`> +- `integer` + +### C Prototype +`RETURNS(Gfx*, u32) gfx_get_from_name(const char *name);` + +[:arrow_up_small:](#) + +
+ ## [gfx_get_name](#gfx_get_name) ### Description @@ -8242,6 +8266,30 @@ Deletes all display lists created by `gfx_create`
+## [vtx_get_from_name](#vtx_get_from_name) + +### Description +Gets a vertex buffer of the current mod from its name. Returns a pointer to the vertex buffering and its vertex count + +### Lua Example +`local PointerValue, integerValue = vtx_get_from_name(name)` + +### Parameters +| Field | Type | +| ----- | ---- | +| name | `string` | + +### Returns +- `Pointer` <`Vtx`> +- `integer` + +### C Prototype +`RETURNS(Vtx*, u32) vtx_get_from_name(const char *name);` + +[:arrow_up_small:](#) + +
+ ## [vtx_get_name](#vtx_get_name) ### Description diff --git a/docs/lua/functions.md b/docs/lua/functions.md index e64fc7dde..87534d646 100644 --- a/docs/lua/functions.md +++ b/docs/lua/functions.md @@ -1938,6 +1938,7 @@ - [gfx_get_vertex_buffer](functions-6.md#gfx_get_vertex_buffer) - [gfx_get_vertex_count](functions-6.md#gfx_get_vertex_count) - [gfx_get_texture](functions-6.md#gfx_get_texture) + - [gfx_get_from_name](functions-6.md#gfx_get_from_name) - [gfx_get_name](functions-6.md#gfx_get_name) - [gfx_get_length](functions-6.md#gfx_get_length) - [gfx_get_command](functions-6.md#gfx_get_command) @@ -1947,6 +1948,7 @@ - [gfx_resize](functions-6.md#gfx_resize) - [gfx_delete](functions-6.md#gfx_delete) - [gfx_delete_all](functions-6.md#gfx_delete_all) + - [vtx_get_from_name](functions-6.md#vtx_get_from_name) - [vtx_get_name](functions-6.md#vtx_get_name) - [vtx_get_count](functions-6.md#vtx_get_count) - [vtx_get_vertex](functions-6.md#vtx_get_vertex) diff --git a/src/pc/lua/smlua_cobject.c b/src/pc/lua/smlua_cobject.c index 2c1a074c0..104c02074 100644 --- a/src/pc/lua/smlua_cobject.c +++ b/src/pc/lua/smlua_cobject.c @@ -101,7 +101,6 @@ static const char *sLuaLvtNames[] = { [LVT_LUATABLE] = "LuaTable", [LVT_POINTER] = "pointer", [LVT_FUNCTION] = "function", - [LVT_FIELD] = "field", [LVT_MAX] = "unknown", }; diff --git a/src/pc/lua/smlua_functions.c b/src/pc/lua/smlua_functions.c index dadf70c51..d91055068 100644 --- a/src/pc/lua/smlua_functions.c +++ b/src/pc/lua/smlua_functions.c @@ -1007,36 +1007,6 @@ int smlua_func_gfx_set_command(lua_State* L) { return 1; } -int smlua_func_gfx_get_from_name(lua_State *L) { - if (!smlua_functions_valid_param_count(L, 1)) { return 0; } - - const char *name = smlua_to_string(L, 1); - if (!gSmLuaConvertSuccess) { LOG_LUA("gfx_get_from_name: Failed to convert parameter 1"); return 0; } - - u32 length = 0; - Gfx *gfx = dynos_gfx_get(name, &length); - - smlua_push_object(L, LOT_GFX, gfx, NULL); - lua_pushinteger(L, length); - - return 2; -} - -int smlua_func_vtx_get_from_name(lua_State *L) { - if (!smlua_functions_valid_param_count(L, 1)) { return 0; } - - const char *name = smlua_to_string(L, 1); - if (!gSmLuaConvertSuccess) { LOG_LUA("vtx_get_from_name: Failed to convert parameter 1"); return 0; } - - u32 count = 0; - Vtx *vtx = dynos_vtx_get(name, &count); - - smlua_push_object(L, LOT_VTX, vtx, NULL); - lua_pushinteger(L, count); - - return 2; -} - ////////// // bind // ////////// @@ -1069,6 +1039,4 @@ void smlua_bind_functions(void) { smlua_bind_function(L, "cast_graph_node", smlua_func_cast_graph_node); smlua_bind_function(L, "get_uncolored_string", smlua_func_get_uncolored_string); smlua_bind_function(L, "gfx_set_command", smlua_func_gfx_set_command); - smlua_bind_function(L, "gfx_get_from_name", smlua_func_gfx_get_from_name); - smlua_bind_function(L, "vtx_get_from_name", smlua_func_vtx_get_from_name); } diff --git a/src/pc/lua/smlua_functions_autogen.c b/src/pc/lua/smlua_functions_autogen.c index 3a08fe7b7..ee4c6e66f 100644 --- a/src/pc/lua/smlua_functions_autogen.c +++ b/src/pc/lua/smlua_functions_autogen.c @@ -32603,6 +32603,23 @@ int smlua_func_gfx_get_texture(lua_State* L) { return 1; } +int smlua_func_gfx_get_from_name(lua_State* L) { + if (L == NULL) { return 0; } + + int top = lua_gettop(L); + if (top != 1) { + LOG_LUA_LINE("Improper param count for '%s': Expected %u, Received %u", "gfx_get_from_name", 1, top); + return 0; + } + + const char* name = smlua_to_string(L, 1); + if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "gfx_get_from_name"); return 0; } + + gfx_get_from_name(name); + + return 2; +} + int smlua_func_gfx_get_name(lua_State* L) { if (L == NULL) { return 0; } @@ -32764,6 +32781,23 @@ int smlua_func_gfx_delete_all(UNUSED lua_State* L) { return 1; } +int smlua_func_vtx_get_from_name(lua_State* L) { + if (L == NULL) { return 0; } + + int top = lua_gettop(L); + if (top != 1) { + LOG_LUA_LINE("Improper param count for '%s': Expected %u, Received %u", "vtx_get_from_name", 1, top); + return 0; + } + + const char* name = smlua_to_string(L, 1); + if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "vtx_get_from_name"); return 0; } + + vtx_get_from_name(name); + + return 2; +} + int smlua_func_vtx_get_name(lua_State* L) { if (L == NULL) { return 0; } @@ -38697,6 +38731,7 @@ void smlua_bind_functions_autogen(void) { smlua_bind_function(L, "gfx_get_vertex_buffer", smlua_func_gfx_get_vertex_buffer); smlua_bind_function(L, "gfx_get_vertex_count", smlua_func_gfx_get_vertex_count); smlua_bind_function(L, "gfx_get_texture", smlua_func_gfx_get_texture); + smlua_bind_function(L, "gfx_get_from_name", smlua_func_gfx_get_from_name); smlua_bind_function(L, "gfx_get_name", smlua_func_gfx_get_name); smlua_bind_function(L, "gfx_get_length", smlua_func_gfx_get_length); smlua_bind_function(L, "gfx_get_command", smlua_func_gfx_get_command); @@ -38706,6 +38741,7 @@ void smlua_bind_functions_autogen(void) { smlua_bind_function(L, "gfx_resize", smlua_func_gfx_resize); smlua_bind_function(L, "gfx_delete", smlua_func_gfx_delete); smlua_bind_function(L, "gfx_delete_all", smlua_func_gfx_delete_all); + smlua_bind_function(L, "vtx_get_from_name", smlua_func_vtx_get_from_name); smlua_bind_function(L, "vtx_get_name", smlua_func_vtx_get_name); smlua_bind_function(L, "vtx_get_count", smlua_func_vtx_get_count); smlua_bind_function(L, "vtx_get_vertex", smlua_func_vtx_get_vertex); diff --git a/src/pc/lua/utils/smlua_gfx_utils.c b/src/pc/lua/utils/smlua_gfx_utils.c index 821b42696..b3cbbfda4 100644 --- a/src/pc/lua/utils/smlua_gfx_utils.c +++ b/src/pc/lua/utils/smlua_gfx_utils.c @@ -247,6 +247,17 @@ Texture *gfx_get_texture(Gfx *cmd) { return (Texture *) cmd->words.w1; } +RETURNS(Gfx*, u32) gfx_get_from_name(const char *name) { + lua_State *L = gLuaState; + if (!L) { return; } + + u32 length = 0; + Gfx *gfx = dynos_gfx_get(name, &length); + + smlua_push_object(L, LOT_GFX, gfx, NULL); + lua_pushinteger(L, length); +} + const char *gfx_get_name(Gfx *gfx) { if (!gfx) { return NULL; } @@ -355,6 +366,17 @@ void gfx_delete_all() { dynos_gfx_delete_all(); } +RETURNS(Vtx*, u32) vtx_get_from_name(const char *name) { + lua_State *L = gLuaState; + if (!L) { return; } + + u32 count = 0; + Vtx *vtx = dynos_vtx_get(name, &count); + + smlua_push_object(L, LOT_VTX, vtx, NULL); + lua_pushinteger(L, count); +} + const char *vtx_get_name(Vtx *vtx) { if (!vtx) { return NULL; } diff --git a/src/pc/lua/utils/smlua_gfx_utils.h b/src/pc/lua/utils/smlua_gfx_utils.h index 4175188b3..c23582c79 100644 --- a/src/pc/lua/utils/smlua_gfx_utils.h +++ b/src/pc/lua/utils/smlua_gfx_utils.h @@ -69,6 +69,11 @@ u16 gfx_get_vertex_count(Gfx *cmd); /* |description|Gets the texture from a display list command if it has an image related op|descriptionEnd| */ Texture *gfx_get_texture(Gfx *cmd); +/* |description| +Gets a display list of the current mod from its name. +Returns a pointer to the display list and its length +|descriptionEnd| */ +RETURNS(Gfx*, u32) gfx_get_from_name(const char *name); /* |description|Gets the name of a display list|descriptionEnd| */ const char *gfx_get_name(Gfx *gfx); /* |description|Gets the max length of a display list|descriptionEnd| */ @@ -88,6 +93,12 @@ void gfx_delete(Gfx *gfx); /* |description|Deletes all display lists created by `gfx_create`|descriptionEnd| */ void gfx_delete_all(); + +/* |description| +Gets a vertex buffer of the current mod from its name. +Returns a pointer to the vertex buffering and its vertex count +|descriptionEnd| */ +RETURNS(Vtx*, u32) vtx_get_from_name(const char *name); /* |description|Gets the name of a vertex buffer|descriptionEnd| */ const char *vtx_get_name(Vtx *vtx); /* |description|Gets the max count of vertices of a vertex buffer|descriptionEnd| */