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 GitHub
parent dade8181c6
commit b60ef755d2
11 changed files with 320 additions and 194 deletions

View File

@ -74,7 +74,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

@ -3982,6 +3982,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

View File

@ -4197,6 +4197,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

@ -1392,6 +1392,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

View File

@ -3858,6 +3858,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
@ -8580,182 +8601,6 @@
[:arrow_up_small:](#) [:arrow_up_small:](#)
<br />
---
# functions from network_player.h
<br />
## [get_network_player_from_area](#get_network_player_from_area)
### Lua Example
`local NetworkPlayerValue = get_network_player_from_area(courseNum, actNum, levelNum, areaIndex)`
### Parameters
| Field | Type |
| ----- | ---- |
| courseNum | `integer` |
| actNum | `integer` |
| levelNum | `integer` |
| areaIndex | `integer` |
### Returns
[NetworkPlayer](structs.md#NetworkPlayer)
### C Prototype
`struct NetworkPlayer* get_network_player_from_area(s16 courseNum, s16 actNum, s16 levelNum, s16 areaIndex);`
[:arrow_up_small:](#)
<br />
## [get_network_player_from_level](#get_network_player_from_level)
### Lua Example
`local NetworkPlayerValue = get_network_player_from_level(courseNum, actNum, levelNum)`
### Parameters
| Field | Type |
| ----- | ---- |
| courseNum | `integer` |
| actNum | `integer` |
| levelNum | `integer` |
### Returns
[NetworkPlayer](structs.md#NetworkPlayer)
### C Prototype
`struct NetworkPlayer* get_network_player_from_level(s16 courseNum, s16 actNum, s16 levelNum);`
[:arrow_up_small:](#)
<br />
## [get_network_player_smallest_global](#get_network_player_smallest_global)
### Lua Example
`local NetworkPlayerValue = get_network_player_smallest_global()`
### Parameters
- None
### Returns
[NetworkPlayer](structs.md#NetworkPlayer)
### C Prototype
`struct NetworkPlayer* get_network_player_smallest_global(void);`
[:arrow_up_small:](#)
<br />
## [network_player_color_to_palette](#network_player_color_to_palette)
### Lua Example
`network_player_color_to_palette(np, part, color)`
### Parameters
| Field | Type |
| ----- | ---- |
| np | [NetworkPlayer](structs.md#NetworkPlayer) |
| part | [enum PlayerParts](constants.md#enum-PlayerParts) |
| color | `Color` |
### Returns
- None
### C Prototype
`void network_player_color_to_palette(struct NetworkPlayer *np, enum PlayerParts part, Color color);`
[:arrow_up_small:](#)
<br />
## [network_player_connected_count](#network_player_connected_count)
### Lua Example
`local integerValue = network_player_connected_count()`
### Parameters
- None
### Returns
- `integer`
### C Prototype
`u8 network_player_connected_count(void);`
[:arrow_up_small:](#)
<br />
## [network_player_from_global_index](#network_player_from_global_index)
### Lua Example
`local NetworkPlayerValue = network_player_from_global_index(globalIndex)`
### Parameters
| Field | Type |
| ----- | ---- |
| globalIndex | `integer` |
### Returns
[NetworkPlayer](structs.md#NetworkPlayer)
### C Prototype
`struct NetworkPlayer* network_player_from_global_index(u8 globalIndex);`
[:arrow_up_small:](#)
<br />
## [network_player_palette_to_color](#network_player_palette_to_color)
### Lua Example
`network_player_palette_to_color(np, part, out)`
### Parameters
| Field | Type |
| ----- | ---- |
| np | [NetworkPlayer](structs.md#NetworkPlayer) |
| part | [enum PlayerParts](constants.md#enum-PlayerParts) |
| out | `Color` |
### Returns
- None
### C Prototype
`void network_player_palette_to_color(struct NetworkPlayer *np, enum PlayerParts part, Color out);`
[:arrow_up_small:](#)
<br />
## [network_player_set_description](#network_player_set_description)
### Lua Example
`network_player_set_description(np, description, r, g, b, a)`
### Parameters
| Field | Type |
| ----- | ---- |
| np | [NetworkPlayer](structs.md#NetworkPlayer) |
| description | `string` |
| r | `integer` |
| g | `integer` |
| b | `integer` |
| a | `integer` |
### Returns
- None
### C Prototype
`void network_player_set_description(struct NetworkPlayer* np, const char* description, u8 r, u8 g, u8 b, u8 a);`
[:arrow_up_small:](#)
<br /> <br />
--- ---

View File

@ -5,6 +5,182 @@
[< prev](functions-3.md) | [1](functions.md) | [2](functions-2.md) | [3](functions-3.md) | 4 | [5](functions-5.md) | [next >](functions-5.md)] [< prev](functions-3.md) | [1](functions.md) | [2](functions-2.md) | [3](functions-3.md) | 4 | [5](functions-5.md) | [next >](functions-5.md)]
---
# functions from network_player.h
<br />
## [get_network_player_from_area](#get_network_player_from_area)
### Lua Example
`local NetworkPlayerValue = get_network_player_from_area(courseNum, actNum, levelNum, areaIndex)`
### Parameters
| Field | Type |
| ----- | ---- |
| courseNum | `integer` |
| actNum | `integer` |
| levelNum | `integer` |
| areaIndex | `integer` |
### Returns
[NetworkPlayer](structs.md#NetworkPlayer)
### C Prototype
`struct NetworkPlayer* get_network_player_from_area(s16 courseNum, s16 actNum, s16 levelNum, s16 areaIndex);`
[:arrow_up_small:](#)
<br />
## [get_network_player_from_level](#get_network_player_from_level)
### Lua Example
`local NetworkPlayerValue = get_network_player_from_level(courseNum, actNum, levelNum)`
### Parameters
| Field | Type |
| ----- | ---- |
| courseNum | `integer` |
| actNum | `integer` |
| levelNum | `integer` |
### Returns
[NetworkPlayer](structs.md#NetworkPlayer)
### C Prototype
`struct NetworkPlayer* get_network_player_from_level(s16 courseNum, s16 actNum, s16 levelNum);`
[:arrow_up_small:](#)
<br />
## [get_network_player_smallest_global](#get_network_player_smallest_global)
### Lua Example
`local NetworkPlayerValue = get_network_player_smallest_global()`
### Parameters
- None
### Returns
[NetworkPlayer](structs.md#NetworkPlayer)
### C Prototype
`struct NetworkPlayer* get_network_player_smallest_global(void);`
[:arrow_up_small:](#)
<br />
## [network_player_color_to_palette](#network_player_color_to_palette)
### Lua Example
`network_player_color_to_palette(np, part, color)`
### Parameters
| Field | Type |
| ----- | ---- |
| np | [NetworkPlayer](structs.md#NetworkPlayer) |
| part | [enum PlayerParts](constants.md#enum-PlayerParts) |
| color | `Color` |
### Returns
- None
### C Prototype
`void network_player_color_to_palette(struct NetworkPlayer *np, enum PlayerParts part, Color color);`
[:arrow_up_small:](#)
<br />
## [network_player_connected_count](#network_player_connected_count)
### Lua Example
`local integerValue = network_player_connected_count()`
### Parameters
- None
### Returns
- `integer`
### C Prototype
`u8 network_player_connected_count(void);`
[:arrow_up_small:](#)
<br />
## [network_player_from_global_index](#network_player_from_global_index)
### Lua Example
`local NetworkPlayerValue = network_player_from_global_index(globalIndex)`
### Parameters
| Field | Type |
| ----- | ---- |
| globalIndex | `integer` |
### Returns
[NetworkPlayer](structs.md#NetworkPlayer)
### C Prototype
`struct NetworkPlayer* network_player_from_global_index(u8 globalIndex);`
[:arrow_up_small:](#)
<br />
## [network_player_palette_to_color](#network_player_palette_to_color)
### Lua Example
`network_player_palette_to_color(np, part, out)`
### Parameters
| Field | Type |
| ----- | ---- |
| np | [NetworkPlayer](structs.md#NetworkPlayer) |
| part | [enum PlayerParts](constants.md#enum-PlayerParts) |
| out | `Color` |
### Returns
- None
### C Prototype
`void network_player_palette_to_color(struct NetworkPlayer *np, enum PlayerParts part, Color out);`
[:arrow_up_small:](#)
<br />
## [network_player_set_description](#network_player_set_description)
### Lua Example
`network_player_set_description(np, description, r, g, b, a)`
### Parameters
| Field | Type |
| ----- | ---- |
| np | [NetworkPlayer](structs.md#NetworkPlayer) |
| description | `string` |
| r | `integer` |
| g | `integer` |
| b | `integer` |
| a | `integer` |
### Returns
- None
### C Prototype
`void network_player_set_description(struct NetworkPlayer* np, const char* description, u8 r, u8 g, u8 b, u8 a);`
[:arrow_up_small:](#)
<br />
--- ---
# functions from network_utils.h # functions from network_utils.h

View File

@ -839,6 +839,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 />
@ -1117,14 +1118,14 @@
<br /> <br />
- network_player.h - network_player.h
- [get_network_player_from_area](functions-3.md#get_network_player_from_area) - [get_network_player_from_area](functions-4.md#get_network_player_from_area)
- [get_network_player_from_level](functions-3.md#get_network_player_from_level) - [get_network_player_from_level](functions-4.md#get_network_player_from_level)
- [get_network_player_smallest_global](functions-3.md#get_network_player_smallest_global) - [get_network_player_smallest_global](functions-4.md#get_network_player_smallest_global)
- [network_player_color_to_palette](functions-3.md#network_player_color_to_palette) - [network_player_color_to_palette](functions-4.md#network_player_color_to_palette)
- [network_player_connected_count](functions-3.md#network_player_connected_count) - [network_player_connected_count](functions-4.md#network_player_connected_count)
- [network_player_from_global_index](functions-3.md#network_player_from_global_index) - [network_player_from_global_index](functions-4.md#network_player_from_global_index)
- [network_player_palette_to_color](functions-3.md#network_player_palette_to_color) - [network_player_palette_to_color](functions-4.md#network_player_palette_to_color)
- [network_player_set_description](functions-3.md#network_player_set_description) - [network_player_set_description](functions-4.md#network_player_set_description)
<br /> <br />

View File

@ -47,15 +47,6 @@
#include "engine/level_script.h" #include "engine/level_script.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 16 #define MENU_LEVEL_MAX 16

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

@ -1,6 +1,8 @@
char gSmluaConstants[] = "" char gSmluaConstants[] = ""
"math.randomseed(get_time())\n" "math.randomseed(get_time())\n"
"\n"
"_CObjectPool = {}\n" "_CObjectPool = {}\n"
"\n"
"_CObject = {\n" "_CObject = {\n"
" __index = function (t,k)\n" " __index = function (t,k)\n"
" return _get_field(t['_lot'], t['_pointer'], k, t)\n" " return _get_field(t['_lot'], t['_pointer'], k, t)\n"
@ -15,10 +17,12 @@ char gSmluaConstants[] = ""
" return a['_pointer'] == b['_pointer'] and a['_lot'] == b['_lot'] and a['_pointer'] ~= nil and a['_lot'] ~= nil\n" " return a['_pointer'] == b['_pointer'] and a['_lot'] == b['_lot'] and a['_pointer'] ~= nil and a['_lot'] ~= nil\n"
" end\n" " end\n"
"}\n" "}\n"
"\n"
"function _NewCObject(lot, pointer)\n" "function _NewCObject(lot, pointer)\n"
" if _CObjectPool[lot] == nil then\n" " if _CObjectPool[lot] == nil then\n"
" _CObjectPool[lot] = {}\n" " _CObjectPool[lot] = {}\n"
" end\n" " end\n"
"\n"
" if _CObjectPool[lot][pointer] == nil then\n" " if _CObjectPool[lot][pointer] == nil then\n"
" local obj = {}\n" " local obj = {}\n"
" rawset(obj, '_pointer', pointer)\n" " rawset(obj, '_pointer', pointer)\n"
@ -27,9 +31,12 @@ char gSmluaConstants[] = ""
" _CObjectPool[lot][pointer] = obj\n" " _CObjectPool[lot][pointer] = obj\n"
" return obj\n" " return obj\n"
" end\n" " end\n"
"\n"
" return _CObjectPool[lot][pointer]\n" " return _CObjectPool[lot][pointer]\n"
"end\n" "end\n"
"\n"
"local _CPointerPool = {}\n" "local _CPointerPool = {}\n"
"\n"
"_CPointer = {\n" "_CPointer = {\n"
" __index = function (t,k)\n" " __index = function (t,k)\n"
" return nil\n" " return nil\n"
@ -43,10 +50,12 @@ char gSmluaConstants[] = ""
" return a['_pointer'] == b['_pointer'] and a['_pointer'] ~= nil and a['_lvt'] ~= nil\n" " return a['_pointer'] == b['_pointer'] and a['_pointer'] ~= nil and a['_lvt'] ~= nil\n"
" end\n" " end\n"
"}\n" "}\n"
"\n"
"function _NewCPointer(lvt, pointer)\n" "function _NewCPointer(lvt, pointer)\n"
" if _CPointerPool[lvt] == nil then\n" " if _CPointerPool[lvt] == nil then\n"
" _CPointerPool[lvt] = {}\n" " _CPointerPool[lvt] = {}\n"
" end\n" " end\n"
"\n"
" if _CPointerPool[lvt][pointer] == nil then\n" " if _CPointerPool[lvt][pointer] == nil then\n"
" local obj = {}\n" " local obj = {}\n"
" rawset(obj, '_pointer', pointer)\n" " rawset(obj, '_pointer', pointer)\n"
@ -55,8 +64,10 @@ char gSmluaConstants[] = ""
" _CPointerPool[lvt][pointer] = obj\n" " _CPointerPool[lvt][pointer] = obj\n"
" return obj\n" " return obj\n"
" end\n" " end\n"
"\n"
" return _CPointerPool[lvt][pointer]\n" " return _CPointerPool[lvt][pointer]\n"
"end\n" "end\n"
"\n"
"_SyncTable = {\n" "_SyncTable = {\n"
" __index = function (t,k)\n" " __index = function (t,k)\n"
" local _table = rawget(t, '_table')\n" " local _table = rawget(t, '_table')\n"
@ -68,6 +79,7 @@ char gSmluaConstants[] = ""
" _set_sync_table_field(t, k, v)\n" " _set_sync_table_field(t, k, v)\n"
" end\n" " end\n"
"}\n" "}\n"
"\n"
"_ReadOnlyTable = {\n" "_ReadOnlyTable = {\n"
" __index = function (t,k)\n" " __index = function (t,k)\n"
" local _table = rawget(t, '_table')\n" " local _table = rawget(t, '_table')\n"
@ -76,6 +88,7 @@ char gSmluaConstants[] = ""
" __newindex = function (t,k,v)\n" " __newindex = function (t,k,v)\n"
" end\n" " end\n"
"}\n" "}\n"
"\n"
"--- @param dest Vec3f\n" "--- @param dest Vec3f\n"
"--- @param src Vec3f\n" "--- @param src Vec3f\n"
"--- @return Vec3f\n" "--- @return Vec3f\n"
@ -85,6 +98,7 @@ char gSmluaConstants[] = ""
" dest.z = src.z\n" " dest.z = src.z\n"
" return dest\n" " return dest\n"
"end\n" "end\n"
"\n"
"--- @param dest Vec3f\n" "--- @param dest Vec3f\n"
"--- @param x number\n" "--- @param x number\n"
"--- @param y number\n" "--- @param y number\n"
@ -96,6 +110,7 @@ char gSmluaConstants[] = ""
" dest.z = z\n" " dest.z = z\n"
" return dest\n" " return dest\n"
"end\n" "end\n"
"\n"
"--- @param dest Vec3f\n" "--- @param dest Vec3f\n"
"--- @param a Vec3f\n" "--- @param a Vec3f\n"
"--- @return Vec3f\n" "--- @return Vec3f\n"
@ -105,6 +120,7 @@ char gSmluaConstants[] = ""
" dest.z = dest.z + a.z\n" " dest.z = dest.z + a.z\n"
" return dest\n" " return dest\n"
"end\n" "end\n"
"\n"
"--- @param dest Vec3f\n" "--- @param dest Vec3f\n"
"--- @param a Vec3f\n" "--- @param a Vec3f\n"
"--- @param b Vec3f\n" "--- @param b Vec3f\n"
@ -115,6 +131,7 @@ char gSmluaConstants[] = ""
" dest.z = a.z + b.z\n" " dest.z = a.z + b.z\n"
" return dest\n" " return dest\n"
"end\n" "end\n"
"\n"
"--- @param dest Vec3f\n" "--- @param dest Vec3f\n"
"--- @param a number\n" "--- @param a number\n"
"--- @return Vec3f\n" "--- @return Vec3f\n"
@ -124,6 +141,7 @@ char gSmluaConstants[] = ""
" dest.z = dest.z * a\n" " dest.z = dest.z * a\n"
" return dest\n" " return dest\n"
"end\n" "end\n"
"\n"
"--- @param dest Vec3f\n" "--- @param dest Vec3f\n"
"--- @return Vec3f\n" "--- @return Vec3f\n"
"function vec3f_normalize(dest)\n" "function vec3f_normalize(dest)\n"
@ -131,23 +149,28 @@ char gSmluaConstants[] = ""
" if divisor == 0 then\n" " if divisor == 0 then\n"
" return dest\n" " return dest\n"
" end\n" " end\n"
"\n"
" local invsqrt = 1.0 / divisor\n" " local invsqrt = 1.0 / divisor\n"
" dest.x = dest.x * invsqrt\n" " dest.x = dest.x * invsqrt\n"
" dest.y = dest.y * invsqrt\n" " dest.y = dest.y * invsqrt\n"
" dest.z = dest.z * invsqrt\n" " dest.z = dest.z * invsqrt\n"
"\n"
" return dest\n" " return dest\n"
"end\n" "end\n"
"\n"
"--- @param a Vec3f\n" "--- @param a Vec3f\n"
"--- @return number\n" "--- @return number\n"
"function vec3f_length(a)\n" "function vec3f_length(a)\n"
" return math.sqrt(a.x * a.x + a.y * a.y + a.z * a.z)\n" " return math.sqrt(a.x * a.x + a.y * a.y + a.z * a.z)\n"
"end\n" "end\n"
"\n"
"--- @param a Vec3f\n" "--- @param a Vec3f\n"
"--- @param b Vec3f\n" "--- @param b Vec3f\n"
"--- @return number\n" "--- @return number\n"
"function vec3f_dot(a, b)\n" "function vec3f_dot(a, b)\n"
" return a.x * b.x + a.y * b.y + a.z * b.z\n" " return a.x * b.x + a.y * b.y + a.z * b.z\n"
"end\n" "end\n"
"\n"
"--- @param vec Vec3f\n" "--- @param vec Vec3f\n"
"--- @param onto Vec3f\n" "--- @param onto Vec3f\n"
"--- @return Vec3f\n" "--- @return Vec3f\n"
@ -159,6 +182,7 @@ char gSmluaConstants[] = ""
" vec3f_mul(out, numerator / denominator)\n" " vec3f_mul(out, numerator / denominator)\n"
" return out\n" " return out\n"
"end\n" "end\n"
"\n"
"--- @param v1 Vec3f\n" "--- @param v1 Vec3f\n"
"--- @param v2 Vec3f\n" "--- @param v2 Vec3f\n"
"--- @return number\n" "--- @return number\n"
@ -168,6 +192,7 @@ char gSmluaConstants[] = ""
" dz = v1.z - v2.z\n" " dz = v1.z - v2.z\n"
" return math.sqrt(dx * dx + dy * dy + dz * dz)\n" " return math.sqrt(dx * dx + dy * dy + dz * dz)\n"
"end\n" "end\n"
"\n"
"--- @param dest Vec3s\n" "--- @param dest Vec3s\n"
"--- @param src Vec3s\n" "--- @param src Vec3s\n"
"--- @return Vec3s\n" "--- @return Vec3s\n"
@ -177,6 +202,7 @@ char gSmluaConstants[] = ""
" dest.z = src.z\n" " dest.z = src.z\n"
" return dest\n" " return dest\n"
"end\n" "end\n"
"\n"
"--- @param dest Vec3s\n" "--- @param dest Vec3s\n"
"--- @param x number\n" "--- @param x number\n"
"--- @param y number\n" "--- @param y number\n"
@ -188,6 +214,7 @@ char gSmluaConstants[] = ""
" dest.z = z\n" " dest.z = z\n"
" return dest\n" " return dest\n"
"end\n" "end\n"
"\n"
"--- @param dest Vec3s\n" "--- @param dest Vec3s\n"
"--- @param a Vec3s\n" "--- @param a Vec3s\n"
"--- @return Vec3s\n" "--- @return Vec3s\n"
@ -197,6 +224,7 @@ char gSmluaConstants[] = ""
" dest.z = dest.z + a.z\n" " dest.z = dest.z + a.z\n"
" return dest\n" " return dest\n"
"end\n" "end\n"
"\n"
"--- @param dest Vec3s\n" "--- @param dest Vec3s\n"
"--- @param a Vec3s\n" "--- @param a Vec3s\n"
"--- @param b Vec3s\n" "--- @param b Vec3s\n"
@ -207,6 +235,7 @@ char gSmluaConstants[] = ""
" dest.z = a.z + b.z\n" " dest.z = a.z + b.z\n"
" return dest\n" " return dest\n"
"end\n" "end\n"
"\n"
"--- @param dest Vec3s\n" "--- @param dest Vec3s\n"
"--- @param a number\n" "--- @param a number\n"
"--- @return Vec3s\n" "--- @return Vec3s\n"
@ -216,6 +245,7 @@ char gSmluaConstants[] = ""
" dest.z = dest.z * a\n" " dest.z = dest.z * a\n"
" return dest\n" " return dest\n"
"end\n" "end\n"
"\n"
"--- @param v1 Vec3s\n" "--- @param v1 Vec3s\n"
"--- @param v2 Vec3s\n" "--- @param v2 Vec3s\n"
"--- @return number\n" "--- @return number\n"
@ -225,6 +255,7 @@ char gSmluaConstants[] = ""
" dz = v1.z - v2.z\n" " dz = v1.z - v2.z\n"
" return math.sqrt(dx * dx + dy * dy + dz * dz)\n" " return math.sqrt(dx * dx + dy * dy + dz * dz)\n"
"end\n" "end\n"
"\n"
"--- @param current number\n" "--- @param current number\n"
"--- @param target number\n" "--- @param target number\n"
"--- @param inc number\n" "--- @param inc number\n"
@ -244,6 +275,7 @@ char gSmluaConstants[] = ""
" end\n" " end\n"
" return current;\n" " return current;\n"
"end\n" "end\n"
"\n"
"--- @param current number\n" "--- @param current number\n"
"--- @param target number\n" "--- @param target number\n"
"--- @param inc number\n" "--- @param inc number\n"
@ -261,6 +293,7 @@ char gSmluaConstants[] = ""
" current = target\n" " current = target\n"
" end\n" " end\n"
" end\n" " end\n"
"\n"
" -- keep within 32 bits\n" " -- keep within 32 bits\n"
" if current > 2147483647 then\n" " if current > 2147483647 then\n"
" current = -2147483648 + (current - 2147483647)\n" " current = -2147483648 + (current - 2147483647)\n"
@ -269,6 +302,7 @@ char gSmluaConstants[] = ""
" end\n" " end\n"
" return current;\n" " return current;\n"
"end\n" "end\n"
"\n"
"--- @param bank number\n" "--- @param bank number\n"
"--- @param soundID number\n" "--- @param soundID number\n"
"--- @param priority number\n" "--- @param priority number\n"
@ -278,9 +312,11 @@ char gSmluaConstants[] = ""
" if flags == nil then flags = 0 end\n" " if flags == nil then flags = 0 end\n"
" return (bank << 28) | (soundID << 16) | (priority << 8) | flags | SOUND_STATUS_WAITING\n" " return (bank << 28) | (soundID << 16) | (priority << 8) | flags | SOUND_STATUS_WAITING\n"
"end\n" "end\n"
"\n"
"-------------\n" "-------------\n"
"-- courses --\n" "-- courses --\n"
"-------------\n" "-------------\n"
"\n"
"--- @type integer\n" "--- @type integer\n"
"COURSE_NONE = 0\n" "COURSE_NONE = 0\n"
"--- @type integer\n" "--- @type integer\n"
@ -1551,6 +1587,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"

View File

@ -13723,6 +13723,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; }
@ -31793,6 +31812,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