mirror of
https://github.com/coop-deluxe/sm64coopdx.git
synced 2026-04-26 12:01:43 +00:00
Relocate these functions
LVT_FIELD shouldn't be there yet
This commit is contained in:
parent
2e765786ae
commit
7c60986448
9 changed files with 136 additions and 38 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -8032,6 +8032,30 @@ Gets the texture from a display list command if it has an image related op
|
|||
|
||||
<br />
|
||||
|
||||
## [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:](#)
|
||||
|
||||
<br />
|
||||
|
||||
## [gfx_get_name](#gfx_get_name)
|
||||
|
||||
### Description
|
||||
|
|
@ -8242,6 +8266,30 @@ Deletes all display lists created by `gfx_create`
|
|||
|
||||
<br />
|
||||
|
||||
## [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:](#)
|
||||
|
||||
<br />
|
||||
|
||||
## [vtx_get_name](#vtx_get_name)
|
||||
|
||||
### Description
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -101,7 +101,6 @@ static const char *sLuaLvtNames[] = {
|
|||
[LVT_LUATABLE] = "LuaTable",
|
||||
[LVT_POINTER] = "pointer",
|
||||
[LVT_FUNCTION] = "function",
|
||||
[LVT_FIELD] = "field",
|
||||
[LVT_MAX] = "unknown",
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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; }
|
||||
|
||||
|
|
|
|||
|
|
@ -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| */
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue