add get_surface_from_wcd_index (#75)

This commit is contained in:
Isaac0-dev 2024-06-22 02:14:59 +10:00 committed by GitHub
parent 8ee9fb2c32
commit 003136db4f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 56 additions and 0 deletions

View File

@ -7615,6 +7615,13 @@ function collision_get_temp_wall_collision_data()
-- ... -- ...
end end
--- @param wcd WallCollisionData
--- @param index integer
--- @return Surface
function get_surface_from_wcd_index(wcd, index)
-- ...
end
--- @return Surface --- @return Surface
function get_water_surface_pseudo_floor() function get_water_surface_pseudo_floor()
-- ... -- ...

View File

@ -468,6 +468,27 @@
<br /> <br />
## [get_surface_from_wcd_index](#get_surface_from_wcd_index)
### 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:](#)
<br />
## [get_water_surface_pseudo_floor](#get_water_surface_pseudo_floor) ## [get_water_surface_pseudo_floor](#get_water_surface_pseudo_floor)
### Lua Example ### Lua Example

View File

@ -1598,6 +1598,7 @@
- [collision_find_ceil](functions-5.md#collision_find_ceil) - [collision_find_ceil](functions-5.md#collision_find_ceil)
- [collision_find_floor](functions-5.md#collision_find_floor) - [collision_find_floor](functions-5.md#collision_find_floor)
- [collision_get_temp_wall_collision_data](functions-5.md#collision_get_temp_wall_collision_data) - [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)
- [get_water_surface_pseudo_floor](functions-5.md#get_water_surface_pseudo_floor) - [get_water_surface_pseudo_floor](functions-5.md#get_water_surface_pseudo_floor)
- [smlua_collision_util_get](functions-5.md#smlua_collision_util_get) - [smlua_collision_util_get](functions-5.md#smlua_collision_util_get)

View File

@ -28398,6 +28398,25 @@ int smlua_func_collision_get_temp_wall_collision_data(UNUSED lua_State* L) {
return 1; return 1;
} }
int smlua_func_get_surface_from_wcd_index(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", "get_surface_from_wcd_index", 2, top);
return 0;
}
struct WallCollisionData* wcd = (struct WallCollisionData*)smlua_to_cobject(L, 1, LOT_WALLCOLLISIONDATA);
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "get_surface_from_wcd_index"); return 0; }
s8 index = smlua_to_integer(L, 2);
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 2, "get_surface_from_wcd_index"); return 0; }
smlua_push_object(L, LOT_SURFACE, get_surface_from_wcd_index(wcd, index));
return 1;
}
int smlua_func_get_water_surface_pseudo_floor(UNUSED lua_State* L) { int smlua_func_get_water_surface_pseudo_floor(UNUSED lua_State* L) {
if (L == NULL) { return 0; } if (L == NULL) { return 0; }
@ -34135,6 +34154,7 @@ void smlua_bind_functions_autogen(void) {
smlua_bind_function(L, "collision_find_ceil", smlua_func_collision_find_ceil); smlua_bind_function(L, "collision_find_ceil", smlua_func_collision_find_ceil);
smlua_bind_function(L, "collision_find_floor", smlua_func_collision_find_floor); smlua_bind_function(L, "collision_find_floor", smlua_func_collision_find_floor);
smlua_bind_function(L, "collision_get_temp_wall_collision_data", smlua_func_collision_get_temp_wall_collision_data); smlua_bind_function(L, "collision_get_temp_wall_collision_data", smlua_func_collision_get_temp_wall_collision_data);
smlua_bind_function(L, "get_surface_from_wcd_index", smlua_func_get_surface_from_wcd_index);
smlua_bind_function(L, "get_water_surface_pseudo_floor", smlua_func_get_water_surface_pseudo_floor); smlua_bind_function(L, "get_water_surface_pseudo_floor", smlua_func_get_water_surface_pseudo_floor);
smlua_bind_function(L, "smlua_collision_util_get", smlua_func_smlua_collision_util_get); smlua_bind_function(L, "smlua_collision_util_get", smlua_func_smlua_collision_util_get);

View File

@ -190,3 +190,8 @@ struct WallCollisionData* collision_get_temp_wall_collision_data(void) {
memset(&sTmpWcd, 0, sizeof(struct WallCollisionData)); memset(&sTmpWcd, 0, sizeof(struct WallCollisionData));
return &sTmpWcd; return &sTmpWcd;
} }
struct Surface* get_surface_from_wcd_index(struct WallCollisionData* wcd, s8 index) {
if (index < 0 || index >= 4) { return NULL; }
return wcd->walls[index];
}

View File

@ -124,4 +124,6 @@ Collision* smlua_collision_util_get(const char* name);
struct WallCollisionData* collision_get_temp_wall_collision_data(void); struct WallCollisionData* collision_get_temp_wall_collision_data(void);
struct Surface* get_surface_from_wcd_index(struct WallCollisionData* wcd, s8 index);
#endif #endif