mirror of
https://github.com/coop-deluxe/sm64coopdx.git
synced 2024-11-21 19:45:10 +00:00
Expose some behavior_script.h functions to Lua
This commit is contained in:
parent
227a4bbcf3
commit
ac805bf94d
7 changed files with 305 additions and 7 deletions
|
@ -65,7 +65,8 @@ in_files = [
|
|||
"src/game/area.h",
|
||||
"src/engine/level_script.h",
|
||||
"src/game/ingame_menu.h",
|
||||
"src/game/first_person_cam.h"
|
||||
"src/game/first_person_cam.h",
|
||||
"src/engine/behavior_script.h"
|
||||
]
|
||||
|
||||
override_allowed_functions = {
|
||||
|
@ -118,7 +119,8 @@ override_disallowed_functions = {
|
|||
"src/pc/lua/utils/smlua_anim_utils.h": [ "smlua_anim_util_reset", "smlua_anim_util_register_animation" ],
|
||||
"src/pc/network/lag_compensation.h": [ "lag_compensation_clear", "lag_compensation_store" ],
|
||||
"src/game/first_person_cam.h": [ "first_person_update" ],
|
||||
"src/pc/lua/utils/smlua_collision_utils.h": [ "collision_find_surface_on_ray" ]
|
||||
"src/pc/lua/utils/smlua_collision_utils.h": [ "collision_find_surface_on_ray" ],
|
||||
"src/engine/behavior_script.h": [ "stub_behavior_script_2", "cur_obj_update" ]
|
||||
}
|
||||
|
||||
override_hide_functions = {
|
||||
|
|
|
@ -2343,6 +2343,41 @@ function vec3f_copy_2(dest, src)
|
|||
-- ...
|
||||
end
|
||||
|
||||
--- @return number
|
||||
function draw_distance_scalar()
|
||||
-- ...
|
||||
end
|
||||
|
||||
--- @param obj Object
|
||||
function obj_update_gfx_pos_and_angle(obj)
|
||||
-- ...
|
||||
end
|
||||
|
||||
--- @return number
|
||||
function position_based_random_float_position()
|
||||
-- ...
|
||||
end
|
||||
|
||||
--- @return integer
|
||||
function position_based_random_u16()
|
||||
-- ...
|
||||
end
|
||||
|
||||
--- @return number
|
||||
function random_float()
|
||||
-- ...
|
||||
end
|
||||
|
||||
--- @return integer
|
||||
function random_sign()
|
||||
-- ...
|
||||
end
|
||||
|
||||
--- @return integer
|
||||
function random_u16()
|
||||
-- ...
|
||||
end
|
||||
|
||||
--- @param id BehaviorId
|
||||
--- @return Pointer_BehaviorScript
|
||||
function get_behavior_from_id(id)
|
||||
|
|
|
@ -10331,6 +10331,140 @@
|
|||
|
||||
<br />
|
||||
|
||||
---
|
||||
# functions from behavior_script.h
|
||||
|
||||
<br />
|
||||
|
||||
|
||||
## [draw_distance_scalar](#draw_distance_scalar)
|
||||
|
||||
### Lua Example
|
||||
`local numberValue = draw_distance_scalar()`
|
||||
|
||||
### Parameters
|
||||
- None
|
||||
|
||||
### Returns
|
||||
- `number`
|
||||
|
||||
### C Prototype
|
||||
`f32 draw_distance_scalar(void);`
|
||||
|
||||
[:arrow_up_small:](#)
|
||||
|
||||
<br />
|
||||
|
||||
## [obj_update_gfx_pos_and_angle](#obj_update_gfx_pos_and_angle)
|
||||
|
||||
### Lua Example
|
||||
`obj_update_gfx_pos_and_angle(obj)`
|
||||
|
||||
### Parameters
|
||||
| Field | Type |
|
||||
| ----- | ---- |
|
||||
| obj | [Object](structs.md#Object) |
|
||||
|
||||
### Returns
|
||||
- None
|
||||
|
||||
### C Prototype
|
||||
`void obj_update_gfx_pos_and_angle(struct Object *obj);`
|
||||
|
||||
[:arrow_up_small:](#)
|
||||
|
||||
<br />
|
||||
|
||||
## [position_based_random_float_position](#position_based_random_float_position)
|
||||
|
||||
### Lua Example
|
||||
`local numberValue = position_based_random_float_position()`
|
||||
|
||||
### Parameters
|
||||
- None
|
||||
|
||||
### Returns
|
||||
- `number`
|
||||
|
||||
### C Prototype
|
||||
`f32 position_based_random_float_position(void);`
|
||||
|
||||
[:arrow_up_small:](#)
|
||||
|
||||
<br />
|
||||
|
||||
## [position_based_random_u16](#position_based_random_u16)
|
||||
|
||||
### Lua Example
|
||||
`local integerValue = position_based_random_u16()`
|
||||
|
||||
### Parameters
|
||||
- None
|
||||
|
||||
### Returns
|
||||
- `integer`
|
||||
|
||||
### C Prototype
|
||||
`u16 position_based_random_u16(void);`
|
||||
|
||||
[:arrow_up_small:](#)
|
||||
|
||||
<br />
|
||||
|
||||
## [random_float](#random_float)
|
||||
|
||||
### Lua Example
|
||||
`local numberValue = random_float()`
|
||||
|
||||
### Parameters
|
||||
- None
|
||||
|
||||
### Returns
|
||||
- `number`
|
||||
|
||||
### C Prototype
|
||||
`float random_float(void);`
|
||||
|
||||
[:arrow_up_small:](#)
|
||||
|
||||
<br />
|
||||
|
||||
## [random_sign](#random_sign)
|
||||
|
||||
### Lua Example
|
||||
`local integerValue = random_sign()`
|
||||
|
||||
### Parameters
|
||||
- None
|
||||
|
||||
### Returns
|
||||
- `integer`
|
||||
|
||||
### C Prototype
|
||||
`s32 random_sign(void);`
|
||||
|
||||
[:arrow_up_small:](#)
|
||||
|
||||
<br />
|
||||
|
||||
## [random_u16](#random_u16)
|
||||
|
||||
### Lua Example
|
||||
`local integerValue = random_u16()`
|
||||
|
||||
### Parameters
|
||||
- None
|
||||
|
||||
### Returns
|
||||
- `integer`
|
||||
|
||||
### C Prototype
|
||||
`u16 random_u16(void);`
|
||||
|
||||
[:arrow_up_small:](#)
|
||||
|
||||
<br />
|
||||
|
||||
---
|
||||
# functions from behavior_table.h
|
||||
|
||||
|
|
|
@ -609,6 +609,17 @@
|
|||
|
||||
<br />
|
||||
|
||||
- behavior_script.h
|
||||
- [draw_distance_scalar](functions-2.md#draw_distance_scalar)
|
||||
- [obj_update_gfx_pos_and_angle](functions-2.md#obj_update_gfx_pos_and_angle)
|
||||
- [position_based_random_float_position](functions-2.md#position_based_random_float_position)
|
||||
- [position_based_random_u16](functions-2.md#position_based_random_u16)
|
||||
- [random_float](functions-2.md#random_float)
|
||||
- [random_sign](functions-2.md#random_sign)
|
||||
- [random_u16](functions-2.md#random_u16)
|
||||
|
||||
<br />
|
||||
|
||||
- behavior_table.h
|
||||
- [get_behavior_from_id](functions-2.md#get_behavior_from_id)
|
||||
- [get_behavior_name_from_id](functions-2.md#get_behavior_name_from_id)
|
||||
|
|
|
@ -1464,10 +1464,6 @@ f32 position_based_random_float_position(void) {
|
|||
return rnd / (double)0x10000;
|
||||
}
|
||||
|
||||
u8 cur_obj_is_last_nat_update_per_frame(void) {
|
||||
return (gCurrentObject->areaTimer == (gNetworkAreaTimer - 1));
|
||||
}
|
||||
|
||||
f32 draw_distance_scalar(void) {
|
||||
if (!gBehaviorValues.InfiniteRenderDistance) { return 1.0f; }
|
||||
|
||||
|
|
|
@ -31,7 +31,6 @@ void obj_update_gfx_pos_and_angle(struct Object *obj);
|
|||
|
||||
u16 position_based_random_u16(void);
|
||||
f32 position_based_random_float_position(void);
|
||||
u8 cur_obj_is_last_nat_update_per_frame(void);
|
||||
f32 draw_distance_scalar(void);
|
||||
|
||||
#endif // BEHAVIOR_SCRIPT_H
|
||||
|
|
|
@ -45,6 +45,7 @@
|
|||
#include "src/engine/level_script.h"
|
||||
#include "src/game/ingame_menu.h"
|
||||
#include "src/game/first_person_cam.h"
|
||||
#include "src/engine/behavior_script.h"
|
||||
|
||||
|
||||
////////////
|
||||
|
@ -9620,6 +9621,117 @@ int smlua_func_vec3f_copy_2(lua_State* L) {
|
|||
return 1;
|
||||
}
|
||||
|
||||
///////////////////////
|
||||
// behavior_script.h //
|
||||
///////////////////////
|
||||
|
||||
int smlua_func_draw_distance_scalar(UNUSED lua_State* L) {
|
||||
if (L == NULL) { return 0; }
|
||||
|
||||
int top = lua_gettop(L);
|
||||
if (top != 0) {
|
||||
LOG_LUA_LINE("Improper param count for '%s': Expected %u, Received %u", "draw_distance_scalar", 0, top);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
lua_pushnumber(L, draw_distance_scalar());
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int smlua_func_obj_update_gfx_pos_and_angle(lua_State* L) {
|
||||
if (L == NULL) { return 0; }
|
||||
|
||||
int top = lua_gettop(L);
|
||||
if (top != 1) {
|
||||
LOG_LUA_LINE("Improper param count for '%s': Expected %u, Received %u", "obj_update_gfx_pos_and_angle", 1, top);
|
||||
return 0;
|
||||
}
|
||||
|
||||
struct Object* obj = (struct Object*)smlua_to_cobject(L, 1, LOT_OBJECT);
|
||||
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "obj_update_gfx_pos_and_angle"); return 0; }
|
||||
|
||||
obj_update_gfx_pos_and_angle(obj);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int smlua_func_position_based_random_float_position(UNUSED lua_State* L) {
|
||||
if (L == NULL) { return 0; }
|
||||
|
||||
int top = lua_gettop(L);
|
||||
if (top != 0) {
|
||||
LOG_LUA_LINE("Improper param count for '%s': Expected %u, Received %u", "position_based_random_float_position", 0, top);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
lua_pushnumber(L, position_based_random_float_position());
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int smlua_func_position_based_random_u16(UNUSED lua_State* L) {
|
||||
if (L == NULL) { return 0; }
|
||||
|
||||
int top = lua_gettop(L);
|
||||
if (top != 0) {
|
||||
LOG_LUA_LINE("Improper param count for '%s': Expected %u, Received %u", "position_based_random_u16", 0, top);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
lua_pushinteger(L, position_based_random_u16());
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int smlua_func_random_float(UNUSED lua_State* L) {
|
||||
if (L == NULL) { return 0; }
|
||||
|
||||
int top = lua_gettop(L);
|
||||
if (top != 0) {
|
||||
LOG_LUA_LINE("Improper param count for '%s': Expected %u, Received %u", "random_float", 0, top);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
lua_pushnumber(L, random_float());
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int smlua_func_random_sign(UNUSED lua_State* L) {
|
||||
if (L == NULL) { return 0; }
|
||||
|
||||
int top = lua_gettop(L);
|
||||
if (top != 0) {
|
||||
LOG_LUA_LINE("Improper param count for '%s': Expected %u, Received %u", "random_sign", 0, top);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
lua_pushinteger(L, random_sign());
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int smlua_func_random_u16(UNUSED lua_State* L) {
|
||||
if (L == NULL) { return 0; }
|
||||
|
||||
int top = lua_gettop(L);
|
||||
if (top != 0) {
|
||||
LOG_LUA_LINE("Improper param count for '%s': Expected %u, Received %u", "random_u16", 0, top);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
lua_pushinteger(L, random_u16());
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
//////////////////////
|
||||
// behavior_table.h //
|
||||
//////////////////////
|
||||
|
@ -33269,6 +33381,15 @@ void smlua_bind_functions_autogen(void) {
|
|||
smlua_bind_function(L, "uv_update_scroll", smlua_func_uv_update_scroll);
|
||||
smlua_bind_function(L, "vec3f_copy_2", smlua_func_vec3f_copy_2);
|
||||
|
||||
// behavior_script.h
|
||||
smlua_bind_function(L, "draw_distance_scalar", smlua_func_draw_distance_scalar);
|
||||
smlua_bind_function(L, "obj_update_gfx_pos_and_angle", smlua_func_obj_update_gfx_pos_and_angle);
|
||||
smlua_bind_function(L, "position_based_random_float_position", smlua_func_position_based_random_float_position);
|
||||
smlua_bind_function(L, "position_based_random_u16", smlua_func_position_based_random_u16);
|
||||
smlua_bind_function(L, "random_float", smlua_func_random_float);
|
||||
smlua_bind_function(L, "random_sign", smlua_func_random_sign);
|
||||
smlua_bind_function(L, "random_u16", smlua_func_random_u16);
|
||||
|
||||
// behavior_table.h
|
||||
smlua_bind_function(L, "get_behavior_from_id", smlua_func_get_behavior_from_id);
|
||||
smlua_bind_function(L, "get_behavior_name_from_id", smlua_func_get_behavior_name_from_id);
|
||||
|
|
Loading…
Reference in a new issue