diff --git a/apps/openmw/mwlua/weatherbindings.cpp b/apps/openmw/mwlua/weatherbindings.cpp index d67851c3c6..624382b293 100644 --- a/apps/openmw/mwlua/weatherbindings.cpp +++ b/apps/openmw/mwlua/weatherbindings.cpp @@ -1,7 +1,10 @@ #include "weatherbindings.hpp" +#include + #include #include +#include #include "../mwbase/environment.hpp" #include "../mwbase/world.hpp" @@ -25,6 +28,11 @@ namespace } size_t size() const { return MWBase::Environment::get().getWorld()->getAllWeather().size(); } }; + + Misc::Color color(const osg::Vec4f& color) + { + return Misc::Color(color.r(), color.g(), color.b(), color.a()); + } } namespace MWLua @@ -66,39 +74,39 @@ namespace MWLua return result; }); weatherT["sunDiscSunsetColor"] - = sol::readonly_property([](const MWWorld::Weather& w) { return w.mSunDiscSunsetColor; }); + = sol::readonly_property([](const MWWorld::Weather& w) { return color(w.mSunDiscSunsetColor); }); weatherT["ambientLoopSoundID"] = sol::readonly_property([](const MWWorld::Weather& w) { return w.mAmbientLoopSoundID.serializeText(); }); weatherT["ambientColor"] = sol::readonly_property([lua](const MWWorld::Weather& w) { sol::table result(lua, sol::create); - result["sunrise"] = w.mAmbientColor.getSunriseValue(); - result["day"] = w.mAmbientColor.getDayValue(); - result["sunset"] = w.mAmbientColor.getSunsetValue(); - result["night"] = w.mAmbientColor.getNightValue(); + result["sunrise"] = color(w.mAmbientColor.getSunriseValue()); + result["day"] = color(w.mAmbientColor.getDayValue()); + result["sunset"] = color(w.mAmbientColor.getSunsetValue()); + result["night"] = color(w.mAmbientColor.getNightValue()); return result; }); weatherT["fogColor"] = sol::readonly_property([lua](const MWWorld::Weather& w) { sol::table result(lua, sol::create); - result["sunrise"] = w.mFogColor.getSunriseValue(); - result["day"] = w.mFogColor.getDayValue(); - result["sunset"] = w.mFogColor.getSunsetValue(); - result["night"] = w.mFogColor.getNightValue(); + result["sunrise"] = color(w.mFogColor.getSunriseValue()); + result["day"] = color(w.mFogColor.getDayValue()); + result["sunset"] = color(w.mFogColor.getSunsetValue()); + result["night"] = color(w.mFogColor.getNightValue()); return result; }); weatherT["skyColor"] = sol::readonly_property([lua](const MWWorld::Weather& w) { sol::table result(lua, sol::create); - result["sunrise"] = w.mSkyColor.getSunriseValue(); - result["day"] = w.mSkyColor.getDayValue(); - result["sunset"] = w.mSkyColor.getSunsetValue(); - result["night"] = w.mSkyColor.getNightValue(); + result["sunrise"] = color(w.mSkyColor.getSunriseValue()); + result["day"] = color(w.mSkyColor.getDayValue()); + result["sunset"] = color(w.mSkyColor.getSunsetValue()); + result["night"] = color(w.mSkyColor.getNightValue()); return result; }); weatherT["sunColor"] = sol::readonly_property([lua](const MWWorld::Weather& w) { sol::table result(lua, sol::create); - result["sunrise"] = w.mSunColor.getSunriseValue(); - result["day"] = w.mSunColor.getDayValue(); - result["sunset"] = w.mSunColor.getSunsetValue(); - result["night"] = w.mSunColor.getNightValue(); + result["sunrise"] = color(w.mSunColor.getSunriseValue()); + result["day"] = color(w.mSunColor.getDayValue()); + result["sunset"] = color(w.mSunColor.getSunsetValue()); + result["night"] = color(w.mSunColor.getNightValue()); return result; }); weatherT["landFogDepth"] = sol::readonly_property([lua](const MWWorld::Weather& w) { @@ -128,7 +136,8 @@ 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 7feed7843b..7e2f33c638 100644 --- a/files/lua_api/openmw/core.lua +++ b/files/lua_api/openmw/core.lua @@ -1289,9 +1289,9 @@ -- @field #number distantLandFogOffset -- @field openmw.util#Vector4 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" --- @field #table ambientColor A table with the keys "sunrise", "day", "sunset" and "night" --- @field #table fogColor A table with the keys "sunrise", "day", "sunset" and "night" --- @field #table sunColor 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. return nil