Add get/set_environment_region (#56)
Set the water height with a function. Also added an example for it in the documentation.
This commit is contained in:
parent
95f60fd113
commit
746dd50c5c
|
@ -4135,6 +4135,12 @@ function allocate_mario_action(actFlags)
|
|||
-- ...
|
||||
end
|
||||
|
||||
--- @param index integer
|
||||
--- @return number
|
||||
function get_environment_region(index)
|
||||
-- ...
|
||||
end
|
||||
|
||||
--- @param m MarioState
|
||||
--- @param index integer
|
||||
--- @return number
|
||||
|
@ -4171,6 +4177,13 @@ function hud_show()
|
|||
-- ...
|
||||
end
|
||||
|
||||
--- @param index integer
|
||||
--- @param value integer
|
||||
--- @return nil
|
||||
function set_environment_region(index, value)
|
||||
-- ...
|
||||
end
|
||||
|
||||
--- @param aDelay integer
|
||||
--- @return boolean
|
||||
function warp_exit_level(aDelay)
|
||||
|
|
|
@ -0,0 +1,28 @@
|
|||
-- name: Water Height Changer
|
||||
-- description: Use /waterset and /waterget to manipulate water height.
|
||||
|
||||
function on_get_command(msg)
|
||||
if not network_is_server() then
|
||||
djui_chat_message_create("You need to be the host!")
|
||||
return true
|
||||
end
|
||||
|
||||
djui_chat_message_create(tostring(get_environment_region(1)))
|
||||
djui_chat_message_create(tostring(get_environment_region(2)))
|
||||
return false
|
||||
end
|
||||
|
||||
function on_set_command(msg)
|
||||
if not network_is_server() then
|
||||
djui_chat_message_create("You need to be the host!")
|
||||
return true
|
||||
end
|
||||
|
||||
local num = tonumber(msg)
|
||||
set_environment_region(1, num)
|
||||
set_environment_region(2, num)
|
||||
return false
|
||||
end
|
||||
|
||||
hook_chat_command("waterset", "to set the first two water levels", on_set_command)
|
||||
hook_chat_command("waterget", "to get the first two water levels", on_get_command)
|
|
@ -727,12 +727,14 @@
|
|||
|
||||
- smlua_misc_utils.h
|
||||
- [allocate_mario_action](#allocate_mario_action)
|
||||
- [get_environment_region](#get_environment_region)
|
||||
- [get_hand_foot_pos_x](#get_hand_foot_pos_x)
|
||||
- [get_hand_foot_pos_y](#get_hand_foot_pos_y)
|
||||
- [get_hand_foot_pos_z](#get_hand_foot_pos_z)
|
||||
- [get_network_area_timer](#get_network_area_timer)
|
||||
- [hud_hide](#hud_hide)
|
||||
- [hud_show](#hud_show)
|
||||
- [set_environment_region](#set_environment_region)
|
||||
- [warp_exit_level](#warp_exit_level)
|
||||
- [warp_restart_level](#warp_restart_level)
|
||||
- [warp_to_castle](#warp_to_castle)
|
||||
|
@ -13658,6 +13660,26 @@ The `reliable` field will ensure that the packet arrives, but should be used spa
|
|||
|
||||
<br />
|
||||
|
||||
## [get_environment_region](#get_environment_region)
|
||||
|
||||
### Lua Example
|
||||
`local numberValue = get_environment_region(index)`
|
||||
|
||||
### Parameters
|
||||
| Field | Type |
|
||||
| ----- | ---- |
|
||||
| index | `integer` |
|
||||
|
||||
### Returns
|
||||
- `number`
|
||||
|
||||
### C Prototype
|
||||
`f32 get_environment_region(u8 index);`
|
||||
|
||||
[:arrow_up_small:](#)
|
||||
|
||||
<br />
|
||||
|
||||
## [get_hand_foot_pos_x](#get_hand_foot_pos_x)
|
||||
|
||||
### Lua Example
|
||||
|
@ -13775,6 +13797,27 @@ The `reliable` field will ensure that the packet arrives, but should be used spa
|
|||
|
||||
<br />
|
||||
|
||||
## [set_environment_region](#set_environment_region)
|
||||
|
||||
### Lua Example
|
||||
`set_environment_region(index, value)`
|
||||
|
||||
### Parameters
|
||||
| Field | Type |
|
||||
| ----- | ---- |
|
||||
| index | `integer` |
|
||||
| value | `integer` |
|
||||
|
||||
### Returns
|
||||
- None
|
||||
|
||||
### C Prototype
|
||||
`void set_environment_region(u8 index, s32 value);`
|
||||
|
||||
[:arrow_up_small:](#)
|
||||
|
||||
<br />
|
||||
|
||||
## [warp_exit_level](#warp_exit_level)
|
||||
|
||||
### Lua Example
|
||||
|
|
|
@ -54,8 +54,9 @@ All of this is a holdover from when there were only two players. It was a reason
|
|||
- [Custom Surface Collisions](examples/big-paddle)
|
||||
- [Custom Box Model](examples/custom-box-model)
|
||||
- [Custom Player Model](examples/koopa-player-model)
|
||||
- [Moonjump](examples/Moonjump.lua)
|
||||
- [Instant Clip](examples/Instant_Clip.lua)
|
||||
- [Moonjump](examples/moonjump.lua)
|
||||
- [Instant Clip](examples/instant-clip.lua)
|
||||
- [Water Height Changer](examples/water-level.lua)
|
||||
|
||||
## Example Lua mods (large)
|
||||
- [Extended Moveset](../../mods/extended-moveset.lua)
|
||||
|
|
|
@ -9200,6 +9200,17 @@ int smlua_func_allocate_mario_action(lua_State* L) {
|
|||
return 1;
|
||||
}
|
||||
|
||||
int smlua_func_get_environment_region(lua_State* L) {
|
||||
if(!smlua_functions_valid_param_count(L, 1)) { return 0; }
|
||||
|
||||
u8 index = smlua_to_integer(L, 1);
|
||||
if (!gSmLuaConvertSuccess) { return 0; }
|
||||
|
||||
lua_pushnumber(L, get_environment_region(index));
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int smlua_func_get_hand_foot_pos_x(lua_State* L) {
|
||||
if(!smlua_functions_valid_param_count(L, 2)) { return 0; }
|
||||
|
||||
|
@ -9266,6 +9277,19 @@ int smlua_func_hud_show(UNUSED lua_State* L) {
|
|||
return 1;
|
||||
}
|
||||
|
||||
int smlua_func_set_environment_region(lua_State* L) {
|
||||
if(!smlua_functions_valid_param_count(L, 2)) { return 0; }
|
||||
|
||||
u8 index = smlua_to_integer(L, 1);
|
||||
if (!gSmLuaConvertSuccess) { return 0; }
|
||||
s32 value = smlua_to_integer(L, 2);
|
||||
if (!gSmLuaConvertSuccess) { return 0; }
|
||||
|
||||
set_environment_region(index, value);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int smlua_func_warp_exit_level(lua_State* L) {
|
||||
if(!smlua_functions_valid_param_count(L, 1)) { return 0; }
|
||||
|
||||
|
@ -10703,12 +10727,14 @@ void smlua_bind_functions_autogen(void) {
|
|||
|
||||
// smlua_misc_utils.h
|
||||
smlua_bind_function(L, "allocate_mario_action", smlua_func_allocate_mario_action);
|
||||
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_y", smlua_func_get_hand_foot_pos_y);
|
||||
smlua_bind_function(L, "get_hand_foot_pos_z", smlua_func_get_hand_foot_pos_z);
|
||||
smlua_bind_function(L, "get_network_area_timer", smlua_func_get_network_area_timer);
|
||||
smlua_bind_function(L, "hud_hide", smlua_func_hud_hide);
|
||||
smlua_bind_function(L, "hud_show", smlua_func_hud_show);
|
||||
smlua_bind_function(L, "set_environment_region", smlua_func_set_environment_region);
|
||||
smlua_bind_function(L, "warp_exit_level", smlua_func_warp_exit_level);
|
||||
smlua_bind_function(L, "warp_restart_level", smlua_func_warp_restart_level);
|
||||
smlua_bind_function(L, "warp_to_castle", smlua_func_warp_to_castle);
|
||||
|
|
|
@ -7,6 +7,8 @@
|
|||
#include "smlua_misc_utils.h"
|
||||
#include "pc/debuglog.h"
|
||||
|
||||
#include "game/object_list_processor.h"
|
||||
|
||||
u32 get_network_area_timer(void) {
|
||||
return gNetworkAreaTimer;
|
||||
}
|
||||
|
@ -54,3 +56,16 @@ f32 get_hand_foot_pos_z(struct MarioState* m, u8 index) {
|
|||
if (index >= 4) { index = 0; }
|
||||
return m->marioBodyState->handFootPos[index][2];
|
||||
}
|
||||
|
||||
f32 get_environment_region(u8 index) {
|
||||
if (gEnvironmentRegions != NULL && index <= gEnvironmentRegions[0]) {
|
||||
return gEnvironmentRegions[6 * (int)index];
|
||||
}
|
||||
return -11000;
|
||||
}
|
||||
|
||||
void set_environment_region(u8 index, s32 value) {
|
||||
if (gEnvironmentRegions != NULL && index <= gEnvironmentRegions[0]) {
|
||||
gEnvironmentRegions[6 * (int)index] = value;
|
||||
}
|
||||
}
|
|
@ -17,4 +17,7 @@ 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_z(struct MarioState* m, u8 index);
|
||||
|
||||
f32 get_environment_region(u8 index);
|
||||
void set_environment_region(u8 index, s32 value);
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue