move weather library out of gfx

This commit is contained in:
MihailRis 2025-03-05 18:39:34 +03:00
parent 8640730520
commit 7a86cbdd60
5 changed files with 12 additions and 12 deletions

View File

@ -273,7 +273,7 @@ console.add_command(
return "weather preset not found"
end
local preset = json.parse(file.read(filename))
gfx.weather.change(preset, args[2], args[1])
weather.change(preset, args[2], args[1])
return "weather set to "..filename.." preset ("..tostring(args[2]).." s)"
end
)
@ -282,9 +282,9 @@ console.add_command(
"weather",
"Display current weather preset name",
function (args, kwargs)
local name = gfx.weather.get_current()
local name = weather.get_current()
if name == "" then
return "unnamed " .. json.tostring(gfx.weather.get_current_data(), true)
return "unnamed " .. json.tostring(weather.get_current_data(), true)
else
return name
end

View File

@ -46,7 +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 weatherlib[];
extern const luaL_Reg worldlib[];
// Components

View File

@ -1,4 +1,4 @@
#include "libhud.hpp"
#include "api_lua.hpp"
#include "world/Level.hpp"
#include "world/World.hpp"
@ -33,7 +33,7 @@ static int l_get_current(lua::State* L) {
}
}
static int l_get_fall_intencity(lua::State* L) {
static int l_get_fall_intensity(lua::State* L) {
auto& weather = require_weather();
const auto& a = weather.a;
const auto& b = weather.b;
@ -58,10 +58,10 @@ static int l_is_transition(lua::State* L) {
}
const luaL_Reg weatherlib[] = {
{"change", wrap_hud<l_change>},
{"get_current", wrap_hud<l_get_current>},
{"get_current_data", wrap_hud<l_get_current_data>},
{"get_fall_intencity", wrap_hud<l_get_fall_intencity>},
{"is_transition", wrap_hud<l_is_transition>},
{"change", lua::wrap<l_change>},
{"get_current", lua::wrap<l_get_current>},
{"get_current_data", lua::wrap<l_get_current_data>},
{"get_fall_intensity", lua::wrap<l_get_fall_intensity>},
{"is_transition", lua::wrap<l_is_transition>},
{NULL, NULL}
};

View File

@ -73,6 +73,7 @@ static void create_libs(State* L, StateType stateType) {
openlib(L, "player", playerlib);
openlib(L, "time", timelib);
openlib(L, "world", worldlib);
openlib(L, "weather", weatherlib);
openlib(L, "entities", entitylib);
openlib(L, "cameras", cameralib);

View File

@ -36,7 +36,6 @@ 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");