Control the Lighting Engine with le_set_enabled in real time (#1193)

* Control the Lighting Engine with le_disable and le_enable in real time

(FORK REDO FOR PR)

* I hate it when I typo

* Control the Lighting Engine in real time with le_set_active (new change)

* Changed to le_set_enabled to be better in line with functions
This commit is contained in:
Emeraldsniper 2026-05-01 20:15:09 -05:00 committed by GitHub
parent 675c71e00d
commit 0e2ba340fc
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 54 additions and 0 deletions

View file

@ -5155,6 +5155,12 @@ function le_set_max_lights_per_vertex(count)
-- ...
end
--- @param value boolean
--- This will let the user control the lighting engine in real time to disable or enable it.
function le_set_enabled(value)
-- ...
end
--- @param pos Vec3f
--- @param out Color
--- @param lightIntensityScalar number

View file

@ -170,6 +170,29 @@ Sets the max amount of lights that can affect a vertex
<br />
## [le_set_enabled](#le_set_enabled)
### Description
This will let the user control the lighting engine in real time to disable or enable it.
### Lua Example
`le_set_enabled(value)`
### Parameters
| Field | Type |
| ----- | ---- |
| value | `boolean` |
### Returns
- None
### C Prototype
`void le_set_enabled(bool value);`
[:arrow_up_small:](#)
<br />
## [le_calculate_lighting_color](#le_calculate_lighting_color)
### Description

View file

@ -983,6 +983,7 @@
- [le_get_ambient_color](functions-4.md#le_get_ambient_color)
- [le_set_ambient_color](functions-4.md#le_set_ambient_color)
- [le_set_max_lights_per_vertex](functions-4.md#le_set_max_lights_per_vertex)
- [le_set_enabled](functions-4.md#le_set_enabled)
- [le_calculate_lighting_color](functions-4.md#le_calculate_lighting_color)
- [le_calculate_lighting_color_with_normal](functions-4.md#le_calculate_lighting_color_with_normal)
- [le_calculate_lighting_dir](functions-4.md#le_calculate_lighting_dir)

View file

@ -92,6 +92,10 @@ C_FIELD void le_set_max_lights_per_vertex(u8 count) {
sMaxLightsPerVertex = count;
}
C_FIELD void le_set_enabled(bool value) {
sEnabled = value;
}
static inline void le_tone_map_total_weighted(Color out, Color inAmbient, Vec3f inColor, f32 weight) {
out[0] = clamp_u8((inAmbient[0] + inColor[0]) / weight);
out[1] = clamp_u8((inAmbient[1] + inColor[1]) / weight);

View file

@ -37,6 +37,8 @@ void le_get_ambient_color(VEC_OUT Color out);
void le_set_ambient_color(u8 r, u8 g, u8 b);
/* |description|Sets the max amount of lights that can affect a vertex|descriptionEnd| */
void le_set_max_lights_per_vertex(u8 count);
/* |description|This will let the user control the lighting engine in real time to disable or enable it. |descriptionEnd|*/
void le_set_enabled(bool value);
void le_calculate_vertex_lighting(const Vtx_t* v, Vec3f pos, VEC_OUT Color out);
/* |description|Calculates the lighting with `lightIntensityScalar` at a position and outputs the color in `out`|descriptionEnd|*/

View file

@ -15657,6 +15657,23 @@ int smlua_func_le_set_max_lights_per_vertex(lua_State* L) {
return 1;
}
int smlua_func_le_set_enabled(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", "le_set_enabled", 1, top);
return 0;
}
bool value = smlua_to_boolean(L, 1);
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "le_set_enabled"); return 0; }
le_set_enabled(value);
return 1;
}
int smlua_func_le_calculate_lighting_color(lua_State* L) {
if (L == NULL) { return 0; }
@ -37809,6 +37826,7 @@ void smlua_bind_functions_autogen(void) {
smlua_bind_function(L, "le_get_ambient_color", smlua_func_le_get_ambient_color);
smlua_bind_function(L, "le_set_ambient_color", smlua_func_le_set_ambient_color);
smlua_bind_function(L, "le_set_max_lights_per_vertex", smlua_func_le_set_max_lights_per_vertex);
smlua_bind_function(L, "le_set_enabled", smlua_func_le_set_enabled);
smlua_bind_function(L, "le_calculate_lighting_color", smlua_func_le_calculate_lighting_color);
smlua_bind_function(L, "le_calculate_lighting_color_with_normal", smlua_func_le_calculate_lighting_color_with_normal);
smlua_bind_function(L, "le_calculate_lighting_dir", smlua_func_le_calculate_lighting_dir);