Add more bhv functions and a func to ge tthe current save

This commit is contained in:
MysterD 2022-04-07 01:17:48 -07:00
parent 4aff26cf27
commit 3731ab31af
6 changed files with 199 additions and 0 deletions

View file

@ -47,6 +47,7 @@ in_files = [
"src/engine/surface_load.h", "src/engine/surface_load.h",
"src/game/object_list_processor.h", "src/game/object_list_processor.h",
"src/game/behavior_actions.h", "src/game/behavior_actions.h",
"src/game/mario_misc.h",
] ]
override_allowed_functions = { override_allowed_functions = {
@ -56,6 +57,7 @@ override_allowed_functions = {
"src/game/save_file.h": [ "save_file_get_", "save_file_set_flags", "save_file_clear_flags" ], "src/game/save_file.h": [ "save_file_get_", "save_file_set_flags", "save_file_clear_flags" ],
"src/pc/lua/utils/smlua_model_utils.h": [ "smlua_model_util_get_id" ], "src/pc/lua/utils/smlua_model_utils.h": [ "smlua_model_util_get_id" ],
"src/game/object_list_processor.h": [ "set_object_respawn_info_bits" ], "src/game/object_list_processor.h": [ "set_object_respawn_info_bits" ],
"src/game/mario_misc.h": [ "bhv_toad.*", "bhv_unlock_door.*" ]
} }
override_disallowed_functions = { override_disallowed_functions = {

View file

@ -4812,6 +4812,26 @@ function set_swimming_at_surface_particles(m, particleFlag)
-- ... -- ...
end end
--- @return nil
function bhv_toad_message_init()
-- ...
end
--- @return nil
function bhv_toad_message_loop()
-- ...
end
--- @return nil
function bhv_unlock_door_star_init()
-- ...
end
--- @return nil
function bhv_unlock_door_star_loop()
-- ...
end
--- @return number --- @return number
function get_additive_y_vel_for_jumps() function get_additive_y_vel_for_jumps()
-- ... -- ...
@ -7025,6 +7045,11 @@ function deref_s32_pointer(pointer)
-- ... -- ...
end end
--- @return integer
function get_current_save_file_num()
-- ...
end
--- @param index integer --- @param index integer
--- @return number --- @return number
function get_environment_region(index) function get_environment_region(index)

View file

@ -926,6 +926,14 @@
<br /> <br />
- mario_misc.h
- [bhv_toad_message_init](#bhv_toad_message_init)
- [bhv_toad_message_loop](#bhv_toad_message_loop)
- [bhv_unlock_door_star_init](#bhv_unlock_door_star_init)
- [bhv_unlock_door_star_loop](#bhv_unlock_door_star_loop)
<br />
- mario_step.h - mario_step.h
- [get_additive_y_vel_for_jumps](#get_additive_y_vel_for_jumps) - [get_additive_y_vel_for_jumps](#get_additive_y_vel_for_jumps)
- [init_bully_collision_data](#init_bully_collision_data) - [init_bully_collision_data](#init_bully_collision_data)
@ -1303,6 +1311,7 @@
- smlua_misc_utils.h - smlua_misc_utils.h
- [allocate_mario_action](#allocate_mario_action) - [allocate_mario_action](#allocate_mario_action)
- [deref_s32_pointer](#deref_s32_pointer) - [deref_s32_pointer](#deref_s32_pointer)
- [get_current_save_file_num](#get_current_save_file_num)
- [get_environment_region](#get_environment_region) - [get_environment_region](#get_environment_region)
- [get_hand_foot_pos_x](#get_hand_foot_pos_x) - [get_hand_foot_pos_x](#get_hand_foot_pos_x)
- [get_hand_foot_pos_y](#get_hand_foot_pos_y) - [get_hand_foot_pos_y](#get_hand_foot_pos_y)
@ -17648,6 +17657,84 @@ The `reliable` field will ensure that the packet arrives, but should be used spa
<br /> <br />
---
# functions from mario_misc.h
<br />
## [bhv_toad_message_init](#bhv_toad_message_init)
### Lua Example
`bhv_toad_message_init()`
### Parameters
- None
### Returns
- None
### C Prototype
`void bhv_toad_message_init(void);`
[:arrow_up_small:](#)
<br />
## [bhv_toad_message_loop](#bhv_toad_message_loop)
### Lua Example
`bhv_toad_message_loop()`
### Parameters
- None
### Returns
- None
### C Prototype
`void bhv_toad_message_loop(void);`
[:arrow_up_small:](#)
<br />
## [bhv_unlock_door_star_init](#bhv_unlock_door_star_init)
### Lua Example
`bhv_unlock_door_star_init()`
### Parameters
- None
### Returns
- None
### C Prototype
`void bhv_unlock_door_star_init(void);`
[:arrow_up_small:](#)
<br />
## [bhv_unlock_door_star_loop](#bhv_unlock_door_star_loop)
### Lua Example
`bhv_unlock_door_star_loop()`
### Parameters
- None
### Returns
- None
### C Prototype
`void bhv_unlock_door_star_loop(void);`
[:arrow_up_small:](#)
<br />
--- ---
# functions from mario_step.h # functions from mario_step.h
@ -24545,6 +24632,24 @@ The `reliable` field will ensure that the packet arrives, but should be used spa
<br /> <br />
## [get_current_save_file_num](#get_current_save_file_num)
### Lua Example
`local integerValue = get_current_save_file_num()`
### Parameters
- None
### Returns
- `integer`
### C Prototype
`s16 get_current_save_file_num(void);`
[:arrow_up_small:](#)
<br />
## [get_environment_region](#get_environment_region) ## [get_environment_region](#get_environment_region)
### Lua Example ### Lua Example

View file

@ -26,6 +26,7 @@
#include "src/engine/surface_load.h" #include "src/engine/surface_load.h"
#include "src/game/object_list_processor.h" #include "src/game/object_list_processor.h"
#include "src/game/behavior_actions.h" #include "src/game/behavior_actions.h"
#include "src/game/mario_misc.h"
//////////////////////// ////////////////////////
@ -9897,6 +9898,46 @@ int smlua_func_set_swimming_at_surface_particles(lua_State* L) {
return 1; return 1;
} }
//////////////////
// mario_misc.h //
//////////////////
int smlua_func_bhv_toad_message_init(UNUSED lua_State* L) {
if(!smlua_functions_valid_param_count(L, 0)) { return 0; }
bhv_toad_message_init();
return 1;
}
int smlua_func_bhv_toad_message_loop(UNUSED lua_State* L) {
if(!smlua_functions_valid_param_count(L, 0)) { return 0; }
bhv_toad_message_loop();
return 1;
}
int smlua_func_bhv_unlock_door_star_init(UNUSED lua_State* L) {
if(!smlua_functions_valid_param_count(L, 0)) { return 0; }
bhv_unlock_door_star_init();
return 1;
}
int smlua_func_bhv_unlock_door_star_loop(UNUSED lua_State* L) {
if(!smlua_functions_valid_param_count(L, 0)) { return 0; }
bhv_unlock_door_star_loop();
return 1;
}
////////////////// //////////////////
// mario_step.h // // mario_step.h //
////////////////// //////////////////
@ -14615,6 +14656,15 @@ int smlua_func_deref_s32_pointer(lua_State* L) {
return 1; return 1;
} }
int smlua_func_get_current_save_file_num(UNUSED lua_State* L) {
if(!smlua_functions_valid_param_count(L, 0)) { return 0; }
lua_pushinteger(L, get_current_save_file_num());
return 1;
}
int smlua_func_get_environment_region(lua_State* L) { int smlua_func_get_environment_region(lua_State* L) {
if(!smlua_functions_valid_param_count(L, 1)) { return 0; } if(!smlua_functions_valid_param_count(L, 1)) { return 0; }
@ -16375,6 +16425,12 @@ void smlua_bind_functions_autogen(void) {
smlua_bind_function(L, "perform_water_step", smlua_func_perform_water_step); smlua_bind_function(L, "perform_water_step", smlua_func_perform_water_step);
smlua_bind_function(L, "set_swimming_at_surface_particles", smlua_func_set_swimming_at_surface_particles); smlua_bind_function(L, "set_swimming_at_surface_particles", smlua_func_set_swimming_at_surface_particles);
// mario_misc.h
smlua_bind_function(L, "bhv_toad_message_init", smlua_func_bhv_toad_message_init);
smlua_bind_function(L, "bhv_toad_message_loop", smlua_func_bhv_toad_message_loop);
smlua_bind_function(L, "bhv_unlock_door_star_init", smlua_func_bhv_unlock_door_star_init);
smlua_bind_function(L, "bhv_unlock_door_star_loop", smlua_func_bhv_unlock_door_star_loop);
// mario_step.h // mario_step.h
smlua_bind_function(L, "get_additive_y_vel_for_jumps", smlua_func_get_additive_y_vel_for_jumps); smlua_bind_function(L, "get_additive_y_vel_for_jumps", smlua_func_get_additive_y_vel_for_jumps);
smlua_bind_function(L, "init_bully_collision_data", smlua_func_init_bully_collision_data); smlua_bind_function(L, "init_bully_collision_data", smlua_func_init_bully_collision_data);
@ -16745,6 +16801,7 @@ void smlua_bind_functions_autogen(void) {
// smlua_misc_utils.h // smlua_misc_utils.h
smlua_bind_function(L, "allocate_mario_action", smlua_func_allocate_mario_action); smlua_bind_function(L, "allocate_mario_action", smlua_func_allocate_mario_action);
smlua_bind_function(L, "deref_s32_pointer", smlua_func_deref_s32_pointer); smlua_bind_function(L, "deref_s32_pointer", smlua_func_deref_s32_pointer);
smlua_bind_function(L, "get_current_save_file_num", smlua_func_get_current_save_file_num);
smlua_bind_function(L, "get_environment_region", smlua_func_get_environment_region); smlua_bind_function(L, "get_environment_region", smlua_func_get_environment_region);
smlua_bind_function(L, "get_hand_foot_pos_x", smlua_func_get_hand_foot_pos_x); smlua_bind_function(L, "get_hand_foot_pos_x", smlua_func_get_hand_foot_pos_x);
smlua_bind_function(L, "get_hand_foot_pos_y", smlua_func_get_hand_foot_pos_y); smlua_bind_function(L, "get_hand_foot_pos_y", smlua_func_get_hand_foot_pos_y);

View file

@ -83,6 +83,13 @@ f32 get_hand_foot_pos_z(struct MarioState* m, u8 index) {
/// ///
s16 get_current_save_file_num(void) {
extern s16 gCurrSaveFileNum;
return gCurrSaveFileNum;
}
///
LevelScript* smlua_level_util_get(const char* name) { LevelScript* smlua_level_util_get(const char* name) {
return dynos_level_get(name); return dynos_level_get(name);
} }

View file

@ -20,7 +20,10 @@ f32 get_hand_foot_pos_x(struct MarioState* m, u8 index);
f32 get_hand_foot_pos_y(struct MarioState* m, u8 index); f32 get_hand_foot_pos_y(struct MarioState* m, u8 index);
f32 get_hand_foot_pos_z(struct MarioState* m, u8 index); f32 get_hand_foot_pos_z(struct MarioState* m, u8 index);
s16 get_current_save_file_num(void);
LevelScript* smlua_level_util_get(const char* name); LevelScript* smlua_level_util_get(const char* name);
f32 get_environment_region(u8 index); f32 get_environment_region(u8 index);
void set_environment_region(u8 index, s32 value); void set_environment_region(u8 index, s32 value);