Added warp_to_start_level function (#154)

* Added `warp_to_start_level` function

* Fix include things
This commit is contained in:
Emerald Lockdown 2022-08-25 19:27:05 -05:00 committed by GitHub
parent adaf96ec59
commit 748b7e9134
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 52 additions and 1 deletions

View file

@ -7527,6 +7527,11 @@ function warp_to_level(aLevel, aArea, aAct)
-- ...
end
--- @return boolean
function warp_to_start_level()
-- ...
end
--- @param actFlags integer
--- @return integer
function allocate_mario_action(actFlags)

View file

@ -20,6 +20,7 @@ void dynos_gfx_swap_animations(void *ptr);
LevelScript* dynos_get_level_script(char* scriptEntryName);
bool dynos_warp_to_level(s32 aLevel, s32 aArea, s32 aAct);
bool dynos_warp_restart_level(void);
bool dynos_warp_to_start_level(void);
bool dynos_warp_exit_level(s32 aDelay);
bool dynos_warp_to_castle(s32 aLevel);

View file

@ -1,6 +1,7 @@
#include "dynos.cpp.h"
extern "C" {
#include "src/game/moving_texture.h"
#include "game/hardcoded.h"
void *dynos_swap_cmd(void *cmd) {
return DynOS_SwapCmd(cmd);
@ -38,6 +39,16 @@ bool dynos_warp_to_level(s32 aLevel, s32 aArea, s32 aAct) {
return DynOS_Warp_ToLevel(aLevel, aArea, aAct);
}
bool dynos_warp_to_start_level(void) {
// change the level to the start level
extern s16 gChangeLevel;
gChangeLevel = gLevelValues.entryLevel;
// always return true since it will always suceed
return true;
}
bool dynos_warp_restart_level(void) {
return DynOS_Warp_RestartLevel();
}

View file

@ -6286,6 +6286,24 @@
<br />
## [warp_to_start_level](#warp_to_start_level)
### Lua Example
`local booleanValue = warp_to_start_level()`
### Parameters
- None
### Returns
- `boolean`
### C Prototype
`bool warp_to_start_level(void);`
[:arrow_up_small:](#)
<br />
---
# functions from smlua_misc_utils.h

View file

@ -1400,6 +1400,7 @@
- [warp_restart_level](functions-4.md#warp_restart_level)
- [warp_to_castle](functions-4.md#warp_to_castle)
- [warp_to_level](functions-4.md#warp_to_level)
- [warp_to_start_level](functions-4.md#warp_to_start_level)
<br />

View file

@ -16635,6 +16635,15 @@ int smlua_func_warp_to_level(lua_State* L) {
return 1;
}
int smlua_func_warp_to_start_level(UNUSED lua_State* L) {
if(!smlua_functions_valid_param_count(L, 0)) { return 0; }
lua_pushboolean(L, warp_to_start_level());
return 1;
}
////////////////////////
// smlua_misc_utils.h //
////////////////////////
@ -19426,6 +19435,7 @@ void smlua_bind_functions_autogen(void) {
smlua_bind_function(L, "warp_restart_level", smlua_func_warp_restart_level);
smlua_bind_function(L, "warp_to_castle", smlua_func_warp_to_castle);
smlua_bind_function(L, "warp_to_level", smlua_func_warp_to_level);
smlua_bind_function(L, "warp_to_start_level", smlua_func_warp_to_start_level);
// smlua_misc_utils.h
smlua_bind_function(L, "allocate_mario_action", smlua_func_allocate_mario_action);

View file

@ -130,6 +130,10 @@ bool warp_to_level(s32 aLevel, s32 aArea, s32 aAct) {
return dynos_warp_to_level(aLevel, aArea, aAct);
}
bool warp_to_start_level(void) {
return dynos_warp_to_start_level();
}
bool warp_restart_level(void) {
return dynos_warp_restart_level();
}

View file

@ -23,6 +23,7 @@ struct CustomLevelInfo* smlua_level_util_get_info_from_short_name(char* shortNam
s16 level_register(const char* scriptEntryName, s16 courseNum, const char* fullName, const char* shortName, u32 acousticReach, u32 echoLevel1, u32 echoLevel2, u32 echoLevel3);
bool warp_to_level(s32 aLevel, s32 aArea, s32 aAct);
bool warp_restart_level(void);
bool warp_to_start_level(void);
bool warp_exit_level(s32 aDelay);
bool warp_to_castle(s32 aLevel);