Expose lvl_set_current_level (#513)

* Expose Initiate_warp

exposed initiate_warp function
exposed WARP_NODE_ constants

* expose lvl_set_current_level

* remove initiate_warp
This commit is contained in:
Blockyyy 2023-11-15 18:54:48 +01:00 committed by Agent X
parent 5767ae985f
commit c2c846f650
10 changed files with 122 additions and 12 deletions

View file

@ -75,7 +75,7 @@ override_allowed_functions = {
"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.*" ], "src/game/mario_misc.h": [ "bhv_toad.*", "bhv_unlock_door.*" ],
"src/pc/utils/misc.h": [ "update_all_mario_stars" ], "src/pc/utils/misc.h": [ "update_all_mario_stars" ],
"src/game/level_update.h": [ "level_trigger_warp", "get_painting_warp_node", "initiate_painting_warp", "warp_special" ], "src/game/level_update.h": [ "level_trigger_warp", "get_painting_warp_node", "initiate_painting_warp", "warp_special", "lvl_set_current_level" ],
"src/game/area.h": [ "area_get_warp_node" ], "src/game/area.h": [ "area_get_warp_node" ],
"src/engine/level_script.h": [ "area_create_warp_node" ], "src/engine/level_script.h": [ "area_create_warp_node" ],
"src/game/ingame_menu.h": [ "set_min_dialog_width", "set_dialog_override_pos", "reset_dialog_override_pos", "set_dialog_override_color", "reset_dialog_override_color" ] "src/game/ingame_menu.h": [ "set_min_dialog_width", "set_dialog_override_pos", "reset_dialog_override_pos", "set_dialog_override_color", "reset_dialog_override_color" ]

View file

@ -4040,6 +4040,30 @@ TIMER_CONTROL_START = 1
--- @type integer --- @type integer
TIMER_CONTROL_STOP = 2 TIMER_CONTROL_STOP = 2
--- @type integer
WARP_NODE_CREDITS_END = 0xFA
--- @type integer
WARP_NODE_CREDITS_MIN = 0xF8
--- @type integer
WARP_NODE_CREDITS_NEXT = 0xF9
--- @type integer
WARP_NODE_CREDITS_START = 0xF8
--- @type integer
WARP_NODE_DEATH = 0xF1
--- @type integer
WARP_NODE_F0 = 0xF0
--- @type integer
WARP_NODE_F2 = 0xF2
--- @type integer
WARP_NODE_WARP_FLOOR = 0xF3
--- @type integer --- @type integer
WARP_OP_CREDITS_END = 0x15 WARP_OP_CREDITS_END = 0x15
@ -5500,6 +5524,17 @@ PACKET_LENGTH = 3000
--- @type integer --- @type integer
SYNC_DISTANCE_INFINITE = 0 SYNC_DISTANCE_INFINITE = 0
--- @class BouncyLevelBounds
--- @type BouncyLevelBounds
BOUNCY_LEVEL_BOUNDS_OFF = 0
--- @type BouncyLevelBounds
BOUNCY_LEVEL_BOUNDS_ON = 1
--- @type BouncyLevelBounds
BOUNCY_LEVEL_BOUNDS_ON_CAP = 2
--- @class NetworkSystemType --- @class NetworkSystemType
--- @type NetworkSystemType --- @type NetworkSystemType

View file

@ -4244,6 +4244,13 @@ function level_trigger_warp(m, warpOp)
-- ... -- ...
end end
--- @param arg0 integer
--- @param levelNum integer
--- @return integer
function lvl_set_current_level(arg0, levelNum)
-- ...
end
--- @param arg integer --- @param arg integer
--- @return nil --- @return nil
function warp_special(arg) function warp_special(arg)

View file

@ -41,6 +41,7 @@
- [enum MarioHandGSCId](#enum-MarioHandGSCId) - [enum MarioHandGSCId](#enum-MarioHandGSCId)
- [mod_storage.h](#mod_storageh) - [mod_storage.h](#mod_storageh)
- [network.h](#networkh) - [network.h](#networkh)
- [enum BouncyLevelBounds](#enum-BouncyLevelBounds)
- [enum NetworkSystemType](#enum-NetworkSystemType) - [enum NetworkSystemType](#enum-NetworkSystemType)
- [enum PlayerInteractions](#enum-PlayerInteractions) - [enum PlayerInteractions](#enum-PlayerInteractions)
- [network_player.h](#network_playerh) - [network_player.h](#network_playerh)
@ -1427,6 +1428,14 @@
- TIMER_CONTROL_SHOW - TIMER_CONTROL_SHOW
- TIMER_CONTROL_START - TIMER_CONTROL_START
- TIMER_CONTROL_STOP - TIMER_CONTROL_STOP
- WARP_NODE_CREDITS_END
- WARP_NODE_CREDITS_MIN
- WARP_NODE_CREDITS_NEXT
- WARP_NODE_CREDITS_START
- WARP_NODE_DEATH
- WARP_NODE_F0
- WARP_NODE_F2
- WARP_NODE_WARP_FLOOR
- WARP_OP_CREDITS_END - WARP_OP_CREDITS_END
- WARP_OP_CREDITS_NEXT - WARP_OP_CREDITS_NEXT
- WARP_OP_CREDITS_START - WARP_OP_CREDITS_START
@ -1962,6 +1971,13 @@
- PACKET_LENGTH - PACKET_LENGTH
- SYNC_DISTANCE_INFINITE - SYNC_DISTANCE_INFINITE
### [enum BouncyLevelBounds](#BouncyLevelBounds)
| Identifier | Value |
| :--------- | :---- |
| BOUNCY_LEVEL_BOUNDS_OFF | 0 |
| BOUNCY_LEVEL_BOUNDS_ON | 1 |
| BOUNCY_LEVEL_BOUNDS_ON_CAP | 2 |
### [enum NetworkSystemType](#NetworkSystemType) ### [enum NetworkSystemType](#NetworkSystemType)
| Identifier | Value | | Identifier | Value |
| :--------- | :---- | | :--------- | :---- |

View file

@ -4030,6 +4030,27 @@
<br /> <br />
## [lvl_set_current_level](#lvl_set_current_level)
### Lua Example
`local integerValue = lvl_set_current_level(arg0, levelNum)`
### Parameters
| Field | Type |
| ----- | ---- |
| arg0 | `integer` |
| levelNum | `integer` |
### Returns
- `integer`
### C Prototype
`s32 lvl_set_current_level(UNUSED s16 arg0, s32 levelNum);`
[:arrow_up_small:](#)
<br />
## [warp_special](#warp_special) ## [warp_special](#warp_special)
### Lua Example ### Lua Example

View file

@ -859,6 +859,7 @@
- [get_painting_warp_node](functions-3.md#get_painting_warp_node) - [get_painting_warp_node](functions-3.md#get_painting_warp_node)
- [initiate_painting_warp](functions-3.md#initiate_painting_warp) - [initiate_painting_warp](functions-3.md#initiate_painting_warp)
- [level_trigger_warp](functions-3.md#level_trigger_warp) - [level_trigger_warp](functions-3.md#level_trigger_warp)
- [lvl_set_current_level](functions-3.md#lvl_set_current_level)
- [warp_special](functions-3.md#warp_special) - [warp_special](functions-3.md#warp_special)
<br /> <br />

View file

@ -48,17 +48,6 @@
#include "engine/level_script.h" #include "engine/level_script.h"
#include "mario_actions_cutscene.h"
#define WARP_NODE_F0 0xF0
#define WARP_NODE_DEATH 0xF1
#define WARP_NODE_F2 0xF2
#define WARP_NODE_WARP_FLOOR 0xF3
#define WARP_NODE_CREDITS_START 0xF8
#define WARP_NODE_CREDITS_NEXT 0xF9
#define WARP_NODE_CREDITS_END 0xFA
#define WARP_NODE_CREDITS_MIN 0xF8
#define MENU_LEVEL_MIN 0 #define MENU_LEVEL_MIN 0
#define MENU_LEVEL_MAX 17 #define MENU_LEVEL_MAX 17

View file

@ -58,6 +58,15 @@
#define MARIO_SPAWN_LAUNCH_DEATH 0x25 #define MARIO_SPAWN_LAUNCH_DEATH 0x25
#define MARIO_SPAWN_UNKNOWN_27 0x27 #define MARIO_SPAWN_UNKNOWN_27 0x27
#define WARP_NODE_F0 0xF0
#define WARP_NODE_DEATH 0xF1
#define WARP_NODE_F2 0xF2
#define WARP_NODE_WARP_FLOOR 0xF3
#define WARP_NODE_CREDITS_START 0xF8
#define WARP_NODE_CREDITS_NEXT 0xF9
#define WARP_NODE_CREDITS_END 0xFA
#define WARP_NODE_CREDITS_MIN 0xF8
#define WARP_TYPE_NOT_WARPING 0 #define WARP_TYPE_NOT_WARPING 0
#define WARP_TYPE_CHANGE_LEVEL 1 #define WARP_TYPE_CHANGE_LEVEL 1
#define WARP_TYPE_CHANGE_AREA 2 #define WARP_TYPE_CHANGE_AREA 2
@ -162,6 +171,7 @@ void initiate_painting_warp(s16 paintingIndex);
s16 level_trigger_warp(struct MarioState *m, s32 warpOp); s16 level_trigger_warp(struct MarioState *m, s32 warpOp);
void level_set_transition(s16 length, void (*updateFunction)(s16 *)); void level_set_transition(s16 length, void (*updateFunction)(s16 *));
void warp_special(s32 arg); void warp_special(s32 arg);
void initiate_warp(s16 destLevel, s16 destArea, s16 destWarpNode, s32 arg3);
s32 lvl_init_or_update(s16 initOrUpdate, UNUSED s32 unused); s32 lvl_init_or_update(s16 initOrUpdate, UNUSED s32 unused);
s32 lvl_init_from_save_file(UNUSED s16 arg0, s32 levelNum); s32 lvl_init_from_save_file(UNUSED s16 arg0, s32 levelNum);

View file

@ -1569,6 +1569,14 @@ char gSmluaConstants[] = ""
"MARIO_SPAWN_LAUNCH_STAR_COLLECT = 0x24\n" "MARIO_SPAWN_LAUNCH_STAR_COLLECT = 0x24\n"
"MARIO_SPAWN_LAUNCH_DEATH = 0x25\n" "MARIO_SPAWN_LAUNCH_DEATH = 0x25\n"
"MARIO_SPAWN_UNKNOWN_27 = 0x27\n" "MARIO_SPAWN_UNKNOWN_27 = 0x27\n"
"WARP_NODE_F0 = 0xF0\n"
"WARP_NODE_DEATH = 0xF1\n"
"WARP_NODE_F2 = 0xF2\n"
"WARP_NODE_WARP_FLOOR = 0xF3\n"
"WARP_NODE_CREDITS_START = 0xF8\n"
"WARP_NODE_CREDITS_NEXT = 0xF9\n"
"WARP_NODE_CREDITS_END = 0xFA\n"
"WARP_NODE_CREDITS_MIN = 0xF8\n"
"WARP_TYPE_NOT_WARPING = 0\n" "WARP_TYPE_NOT_WARPING = 0\n"
"WARP_TYPE_CHANGE_LEVEL = 1\n" "WARP_TYPE_CHANGE_LEVEL = 1\n"
"WARP_TYPE_CHANGE_AREA = 2\n" "WARP_TYPE_CHANGE_AREA = 2\n"
@ -2040,6 +2048,9 @@ char gSmluaConstants[] = ""
"PLAYER_INTERACTIONS_NONE = 0\n" "PLAYER_INTERACTIONS_NONE = 0\n"
"PLAYER_INTERACTIONS_SOLID = 1\n" "PLAYER_INTERACTIONS_SOLID = 1\n"
"PLAYER_INTERACTIONS_PVP = 2\n" "PLAYER_INTERACTIONS_PVP = 2\n"
"BOUNCY_LEVEL_BOUNDS_OFF = 0\n"
"BOUNCY_LEVEL_BOUNDS_ON = 1\n"
"BOUNCY_LEVEL_BOUNDS_ON_CAP = 2\n"
"UNKNOWN_LOCAL_INDEX = (-1)\n" "UNKNOWN_LOCAL_INDEX = (-1)\n"
"UNKNOWN_GLOBAL_INDEX = (-1)\n" "UNKNOWN_GLOBAL_INDEX = (-1)\n"
"UNKNOWN_NETWORK_INDEX = (-1)\n" "UNKNOWN_NETWORK_INDEX = (-1)\n"

View file

@ -13867,6 +13867,25 @@ int smlua_func_level_trigger_warp(lua_State* L) {
return 1; return 1;
} }
int smlua_func_lvl_set_current_level(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", "lvl_set_current_level", 2, top);
return 0;
}
s16 arg0 = smlua_to_integer(L, 1);
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "lvl_set_current_level"); return 0; }
s32 levelNum = smlua_to_integer(L, 2);
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 2, "lvl_set_current_level"); return 0; }
lua_pushinteger(L, lvl_set_current_level(arg0, levelNum));
return 1;
}
int smlua_func_warp_special(lua_State* L) { int smlua_func_warp_special(lua_State* L) {
if (L == NULL) { return 0; } if (L == NULL) { return 0; }
@ -32084,6 +32103,7 @@ void smlua_bind_functions_autogen(void) {
smlua_bind_function(L, "get_painting_warp_node", smlua_func_get_painting_warp_node); smlua_bind_function(L, "get_painting_warp_node", smlua_func_get_painting_warp_node);
smlua_bind_function(L, "initiate_painting_warp", smlua_func_initiate_painting_warp); smlua_bind_function(L, "initiate_painting_warp", smlua_func_initiate_painting_warp);
smlua_bind_function(L, "level_trigger_warp", smlua_func_level_trigger_warp); smlua_bind_function(L, "level_trigger_warp", smlua_func_level_trigger_warp);
smlua_bind_function(L, "lvl_set_current_level", smlua_func_lvl_set_current_level);
smlua_bind_function(L, "warp_special", smlua_func_warp_special); smlua_bind_function(L, "warp_special", smlua_func_warp_special);
// mario.h // mario.h