diff --git a/apps/openmw/mwlua/weatherbindings.cpp b/apps/openmw/mwlua/weatherbindings.cpp index 0024cbdfa1..daabd08620 100644 --- a/apps/openmw/mwlua/weatherbindings.cpp +++ b/apps/openmw/mwlua/weatherbindings.cpp @@ -5,6 +5,8 @@ #include #include #include +#include +#include #include "../mwbase/environment.hpp" #include "../mwbase/world.hpp" @@ -42,13 +44,16 @@ namespace MWLua sol::state_view lua = context.sol(); sol::table api(lua, sol::create); + auto vfs = MWBase::Environment::get().getResourceSystem()->getVFS(); auto weatherT = lua.new_usertype("Weather"); weatherT[sol::meta_function::to_string] = [](const MWWorld::Weather& w) -> std::string { return "Weather[" + w.mName + "]"; }; weatherT["name"] = sol::readonly_property([](const MWWorld::Weather& w) { return w.mName; }); weatherT["windSpeed"] = sol::readonly_property([](const MWWorld::Weather& w) { return w.mWindSpeed; }); weatherT["cloudSpeed"] = sol::readonly_property([](const MWWorld::Weather& w) { return w.mCloudSpeed; }); - weatherT["cloudTexture"] = sol::readonly_property([](const MWWorld::Weather& w) { return w.mCloudTexture; }); + weatherT["cloudTexture"] = sol::readonly_property([vfs](const MWWorld::Weather& w) { + return Misc::ResourceHelpers::correctTexturePath(w.mCloudTexture, vfs); + }); weatherT["cloudsMaximumPercent"] = sol::readonly_property([](const MWWorld::Weather& w) { return w.mCloudsMaximumPercent; }); weatherT["isStorm"] = sol::readonly_property([](const MWWorld::Weather& w) { return w.mIsStorm; }); @@ -58,7 +63,11 @@ namespace MWLua weatherT["rainSpeed"] = sol::readonly_property([](const MWWorld::Weather& w) { return w.mRainSpeed; }); weatherT["rainEntranceSpeed"] = sol::readonly_property([](const MWWorld::Weather& w) { return w.mRainEntranceSpeed; }); - weatherT["rainEffect"] = sol::readonly_property([](const MWWorld::Weather& w) { return w.mRainEffect; }); + weatherT["rainEffect"] = sol::readonly_property([](const MWWorld::Weather& w) -> sol::optional { + if (w.mRainEffect.empty()) + return sol::nullopt; + return w.mRainEffect; + }); weatherT["rainMaxRaindrops"] = sol::readonly_property([](const MWWorld::Weather& w) { return w.mRainMaxRaindrops; }); weatherT["rainDiameter"] = sol::readonly_property([](const MWWorld::Weather& w) { return w.mRainDiameter; }); @@ -118,7 +127,11 @@ namespace MWLua return result; }); weatherT["particleEffect"] - = sol::readonly_property([](const MWWorld::Weather& w) { return w.mParticleEffect; }); + = sol::readonly_property([](const MWWorld::Weather& w) -> sol::optional { + if (w.mParticleEffect.empty()) + return sol::nullopt; + return w.mParticleEffect; + }); weatherT["distantLandFogFactor"] = sol::readonly_property([](const MWWorld::Weather& w) { return w.mDL.FogFactor; }); weatherT["distantLandFogOffset"] @@ -136,8 +149,7 @@ namespace MWLua MWBase::Environment::get().getESMStore()->get().find(region); MWBase::Environment::get().getWorld()->changeWeather(region, weather.mId); }; - { - } + sol::usertype storeT = lua.new_usertype("WeatherWorldStore"); storeT[sol::meta_function::to_string] = [](const WeatherStore& store) { return "{" + std::to_string(store.size()) + " Weather records}"; }; diff --git a/files/lua_api/openmw/core.lua b/files/lua_api/openmw/core.lua index 7b1ac8fb76..dc38922d6f 100644 --- a/files/lua_api/openmw/core.lua +++ b/files/lua_api/openmw/core.lua @@ -1276,7 +1276,7 @@ -- @field #number glareView -- @field #number rainSpeed -- @field #number rainEntranceSpeed --- @field #string rainEffect +-- @field #string rainEffect Will return nil if weather has no rainEffect -- @field #number rainMaxRaindrops -- @field #number rainDiameter -- @field #number rainMaxHeight @@ -1284,14 +1284,14 @@ -- @field #string rainLoopSoundID -- @field #table thunderSoundID An array containing the recordIds of the thunder sounds -- @field #string ambientLoopSoundID --- @field #number particleEffect +-- @field #string particleEffect Will return nil if weather has no particleEffect -- @field #number distantLandFogFactor -- @field #number distantLandFogOffset -- @field openmw.util#Color sunDiscSunsetColor -- @field #table landFogDepth A table with the keys "sunrise", "day", "sunset" and "night" --- @field #table skyColor A table with the keys "sunrise", "day", "sunset" and "night". Each is a openmw.util#Color. --- @field #table ambientColor A table with the keys "sunrise", "day", "sunset" and "night". Each is a openmw.util#Color. --- @field #table fogColor A table with the keys "sunrise", "day", "sunset" and "night". Each is a openmw.util#Color. --- @field #table sunColor A table with the keys "sunrise", "day", "sunset" and "night". Each is a openmw.util#Color. +-- @field #table skyColor A table with the keys "sunrise", "day", "sunset" and "night". Each is a #{openmw.util#Color}. +-- @field #table ambientColor A table with the keys "sunrise", "day", "sunset" and "night". Each is a #{openmw.util#Color}. +-- @field #table fogColor A table with the keys "sunrise", "day", "sunset" and "night". Each is a @{openmw.util#Color}. +-- @field #table sunColor A table with the keys "sunrise", "day", "sunset" and "night". Each is a @{openmw.util#Color}. return nil