mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-08-03 23:36:59 -04:00
adjusments to weatherbindings
- return nil for not existing effects - also use currectTexturePath for cloud texture - corrections for docs
This commit is contained in:
parent
855b236ee8
commit
95fc66bccd
@ -5,6 +5,8 @@
|
|||||||
#include <components/esm3/loadregn.hpp>
|
#include <components/esm3/loadregn.hpp>
|
||||||
#include <components/lua/util.hpp>
|
#include <components/lua/util.hpp>
|
||||||
#include <components/misc/color.hpp>
|
#include <components/misc/color.hpp>
|
||||||
|
#include <components/misc/resourcehelpers.hpp>
|
||||||
|
#include <components/resource/resourcesystem.hpp>
|
||||||
|
|
||||||
#include "../mwbase/environment.hpp"
|
#include "../mwbase/environment.hpp"
|
||||||
#include "../mwbase/world.hpp"
|
#include "../mwbase/world.hpp"
|
||||||
@ -42,13 +44,16 @@ namespace MWLua
|
|||||||
sol::state_view lua = context.sol();
|
sol::state_view lua = context.sol();
|
||||||
sol::table api(lua, sol::create);
|
sol::table api(lua, sol::create);
|
||||||
|
|
||||||
|
auto vfs = MWBase::Environment::get().getResourceSystem()->getVFS();
|
||||||
auto weatherT = lua.new_usertype<MWWorld::Weather>("Weather");
|
auto weatherT = lua.new_usertype<MWWorld::Weather>("Weather");
|
||||||
weatherT[sol::meta_function::to_string]
|
weatherT[sol::meta_function::to_string]
|
||||||
= [](const MWWorld::Weather& w) -> std::string { return "Weather[" + w.mName + "]"; };
|
= [](const MWWorld::Weather& w) -> std::string { return "Weather[" + w.mName + "]"; };
|
||||||
weatherT["name"] = sol::readonly_property([](const MWWorld::Weather& w) { return 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["windSpeed"] = sol::readonly_property([](const MWWorld::Weather& w) { return w.mWindSpeed; });
|
||||||
weatherT["cloudSpeed"] = sol::readonly_property([](const MWWorld::Weather& w) { return w.mCloudSpeed; });
|
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"]
|
weatherT["cloudsMaximumPercent"]
|
||||||
= sol::readonly_property([](const MWWorld::Weather& w) { return w.mCloudsMaximumPercent; });
|
= sol::readonly_property([](const MWWorld::Weather& w) { return w.mCloudsMaximumPercent; });
|
||||||
weatherT["isStorm"] = sol::readonly_property([](const MWWorld::Weather& w) { return w.mIsStorm; });
|
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["rainSpeed"] = sol::readonly_property([](const MWWorld::Weather& w) { return w.mRainSpeed; });
|
||||||
weatherT["rainEntranceSpeed"]
|
weatherT["rainEntranceSpeed"]
|
||||||
= sol::readonly_property([](const MWWorld::Weather& w) { return w.mRainEntranceSpeed; });
|
= 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<std::string> {
|
||||||
|
if (w.mRainEffect.empty())
|
||||||
|
return sol::nullopt;
|
||||||
|
return w.mRainEffect;
|
||||||
|
});
|
||||||
weatherT["rainMaxRaindrops"]
|
weatherT["rainMaxRaindrops"]
|
||||||
= sol::readonly_property([](const MWWorld::Weather& w) { return w.mRainMaxRaindrops; });
|
= sol::readonly_property([](const MWWorld::Weather& w) { return w.mRainMaxRaindrops; });
|
||||||
weatherT["rainDiameter"] = sol::readonly_property([](const MWWorld::Weather& w) { return w.mRainDiameter; });
|
weatherT["rainDiameter"] = sol::readonly_property([](const MWWorld::Weather& w) { return w.mRainDiameter; });
|
||||||
@ -118,7 +127,11 @@ namespace MWLua
|
|||||||
return result;
|
return result;
|
||||||
});
|
});
|
||||||
weatherT["particleEffect"]
|
weatherT["particleEffect"]
|
||||||
= sol::readonly_property([](const MWWorld::Weather& w) { return w.mParticleEffect; });
|
= sol::readonly_property([](const MWWorld::Weather& w) -> sol::optional<std::string> {
|
||||||
|
if (w.mParticleEffect.empty())
|
||||||
|
return sol::nullopt;
|
||||||
|
return w.mParticleEffect;
|
||||||
|
});
|
||||||
weatherT["distantLandFogFactor"]
|
weatherT["distantLandFogFactor"]
|
||||||
= sol::readonly_property([](const MWWorld::Weather& w) { return w.mDL.FogFactor; });
|
= sol::readonly_property([](const MWWorld::Weather& w) { return w.mDL.FogFactor; });
|
||||||
weatherT["distantLandFogOffset"]
|
weatherT["distantLandFogOffset"]
|
||||||
@ -136,8 +149,7 @@ namespace MWLua
|
|||||||
MWBase::Environment::get().getESMStore()->get<ESM::Region>().find(region);
|
MWBase::Environment::get().getESMStore()->get<ESM::Region>().find(region);
|
||||||
MWBase::Environment::get().getWorld()->changeWeather(region, weather.mId);
|
MWBase::Environment::get().getWorld()->changeWeather(region, weather.mId);
|
||||||
};
|
};
|
||||||
{
|
|
||||||
}
|
|
||||||
sol::usertype<WeatherStore> storeT = lua.new_usertype<WeatherStore>("WeatherWorldStore");
|
sol::usertype<WeatherStore> storeT = lua.new_usertype<WeatherStore>("WeatherWorldStore");
|
||||||
storeT[sol::meta_function::to_string]
|
storeT[sol::meta_function::to_string]
|
||||||
= [](const WeatherStore& store) { return "{" + std::to_string(store.size()) + " Weather records}"; };
|
= [](const WeatherStore& store) { return "{" + std::to_string(store.size()) + " Weather records}"; };
|
||||||
|
@ -1276,7 +1276,7 @@
|
|||||||
-- @field #number glareView
|
-- @field #number glareView
|
||||||
-- @field #number rainSpeed
|
-- @field #number rainSpeed
|
||||||
-- @field #number rainEntranceSpeed
|
-- @field #number rainEntranceSpeed
|
||||||
-- @field #string rainEffect
|
-- @field #string rainEffect Will return nil if weather has no rainEffect
|
||||||
-- @field #number rainMaxRaindrops
|
-- @field #number rainMaxRaindrops
|
||||||
-- @field #number rainDiameter
|
-- @field #number rainDiameter
|
||||||
-- @field #number rainMaxHeight
|
-- @field #number rainMaxHeight
|
||||||
@ -1284,14 +1284,14 @@
|
|||||||
-- @field #string rainLoopSoundID
|
-- @field #string rainLoopSoundID
|
||||||
-- @field #table thunderSoundID An array containing the recordIds of the thunder sounds
|
-- @field #table thunderSoundID An array containing the recordIds of the thunder sounds
|
||||||
-- @field #string ambientLoopSoundID
|
-- @field #string ambientLoopSoundID
|
||||||
-- @field #number particleEffect
|
-- @field #string particleEffect Will return nil if weather has no particleEffect
|
||||||
-- @field #number distantLandFogFactor
|
-- @field #number distantLandFogFactor
|
||||||
-- @field #number distantLandFogOffset
|
-- @field #number distantLandFogOffset
|
||||||
-- @field openmw.util#Color sunDiscSunsetColor
|
-- @field openmw.util#Color sunDiscSunsetColor
|
||||||
-- @field #table landFogDepth A table with the keys "sunrise", "day", "sunset" and "night"
|
-- @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 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 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 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 sunColor A table with the keys "sunrise", "day", "sunset" and "night". Each is a @{openmw.util#Color}.
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
Loading…
x
Reference in New Issue
Block a user