diff --git a/res/scripts/stdcmd.lua b/res/scripts/stdcmd.lua index c06f059a..35bbb71d 100644 --- a/res/scripts/stdcmd.lua +++ b/res/scripts/stdcmd.lua @@ -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 diff --git a/src/logic/scripting/lua/libs/api_lua.hpp b/src/logic/scripting/lua/libs/api_lua.hpp index 8b068d4c..e44c3609 100644 --- a/src/logic/scripting/lua/libs/api_lua.hpp +++ b/src/logic/scripting/lua/libs/api_lua.hpp @@ -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 diff --git a/src/logic/scripting/lua/libs/libweather.cpp b/src/logic/scripting/lua/libs/libweather.cpp index 7b1fcecb..3778cd6a 100644 --- a/src/logic/scripting/lua/libs/libweather.cpp +++ b/src/logic/scripting/lua/libs/libweather.cpp @@ -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}, - {"get_current", wrap_hud}, - {"get_current_data", wrap_hud}, - {"get_fall_intencity", wrap_hud}, - {"is_transition", wrap_hud}, + {"change", lua::wrap}, + {"get_current", lua::wrap}, + {"get_current_data", lua::wrap}, + {"get_fall_intensity", lua::wrap}, + {"is_transition", lua::wrap}, {NULL, NULL} }; diff --git a/src/logic/scripting/lua/lua_engine.cpp b/src/logic/scripting/lua/lua_engine.cpp index 251f789b..17ba2806 100644 --- a/src/logic/scripting/lua/lua_engine.cpp +++ b/src/logic/scripting/lua/lua_engine.cpp @@ -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); diff --git a/src/logic/scripting/scripting_hud.cpp b/src/logic/scripting/scripting_hud.cpp index dc7a0339..478b4f9e 100644 --- a/src/logic/scripting/scripting_hud.cpp +++ b/src/logic/scripting/scripting_hud.cpp @@ -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");