add gfx.weather library & add weather.set command

This commit is contained in:
MihailRis
2025-02-27 07:30:49 +03:00
parent 02d8d8d6bf
commit 4d5b450145
8 changed files with 44 additions and 18 deletions
+1
View File
@@ -46,6 +46,7 @@ extern const luaL_Reg utf8lib[];
extern const luaL_Reg vec2lib[]; // vecn.cpp
extern const luaL_Reg vec3lib[]; // vecn.cpp
extern const luaL_Reg vec4lib[]; // vecn.cpp
extern const luaL_Reg weatherlib[]; // gfx.weather
extern const luaL_Reg worldlib[];
// Components
@@ -0,0 +1,16 @@
#include "libhud.hpp"
using namespace scripting;
static int l_change(lua::State* L) {
WeatherPreset weather {};
weather.deserialize(lua::tovalue(L, 1));
float time = lua::tonumber(L, 2);
renderer->weather.change(std::move(weather), time);
return 0;
}
const luaL_Reg weatherlib[] = {
{"change", wrap_hud<l_change>},
{NULL, NULL}
};
+1
View File
@@ -36,6 +36,7 @@ void scripting::on_frontend_init(Hud* hud, WorldRenderer* renderer) {
lua::openlib(L, "gfx", "blockwraps", blockwrapslib);
lua::openlib(L, "gfx", "particles", particleslib);
lua::openlib(L, "gfx", "text3d", text3dlib);
lua::openlib(L, "gfx", "weather", weatherlib);
load_script("hud_classes.lua");