From c6da0fda58ec2c0ff200cb0167c0cbcc76a8985e Mon Sep 17 00:00:00 2001
From: Melanie Thielker
Date: Fri, 20 Mar 2009 22:42:21 +0000
Subject: Thank you, mcortez, for patch to add functionality to the sun module.
Fixes Mantis #3313
---
.../Shared/Api/Implementation/OSSL_Api.cs | 88 ++++++++++++++++++++++
1 file changed, 88 insertions(+)
(limited to 'OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs')
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
index f4be267..8776524 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
@@ -807,6 +807,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
//World.Permissions.GenericEstatePermission(
if (World.Permissions.IsGod(m_host.OwnerID))
{
+ while (sunHour > 24.0)
+ sunHour -= 24.0;
+
+ while (sunHour < 0)
+ sunHour += 24.0;
+
+
World.RegionInfo.RegionSettings.UseEstateSun = useEstateSun;
World.RegionInfo.RegionSettings.SunPosition = sunHour + 6; // LL Region Sun Hour is 6 to 30
World.RegionInfo.RegionSettings.FixedSun = sunFixed;
@@ -816,6 +823,87 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
}
}
+ ///
+ /// Changes the Estate Sun Settings, then Triggers a Sun Update
+ ///
+ /// True to keep the sun stationary, false to use global time
+ /// The "Sun Hour" that is desired, 0...24, with 0 just after SunRise
+ public void osSetEstateSunSettings(bool sunFixed, double sunHour)
+ {
+ CheckThreatLevel(ThreatLevel.Nuisance, "osSetEstateSunSettings");
+
+ m_host.AddScriptLPS(1);
+ //Check to make sure that the script's owner is the estate manager/master
+ //World.Permissions.GenericEstatePermission(
+ if (World.Permissions.IsGod(m_host.OwnerID))
+ {
+ while (sunHour > 24.0)
+ sunHour -= 24.0;
+
+ while (sunHour < 0)
+ sunHour += 24.0;
+
+ World.RegionInfo.EstateSettings.UseGlobalTime = !sunFixed;
+ World.RegionInfo.EstateSettings.SunPosition = sunHour;
+ World.RegionInfo.EstateSettings.FixedSun = sunFixed;
+ World.RegionInfo.EstateSettings.Save();
+
+ World.EventManager.TriggerEstateToolsSunUpdate(World.RegionInfo.RegionHandle, sunFixed, World.RegionInfo.RegionSettings.UseEstateSun, (float)sunHour);
+ }
+ }
+
+ ///
+ /// Return the current Sun Hour 0...24, with 0 being roughly sun-rise
+ ///
+ ///
+ public double osGetCurrentSunHour()
+ {
+ CheckThreatLevel(ThreatLevel.None, "osGetCurrentSunHour");
+
+ m_host.AddScriptLPS(1);
+
+ // Must adjust for the fact that Region Sun Settings are still LL offset
+ double sunHour = World.RegionInfo.RegionSettings.SunPosition - 6;
+
+ // See if the sun module has registered itself, if so it's authoritative
+ ISunModule module = World.RequestModuleInterface();
+ if (module != null)
+ {
+ sunHour = module.GetCurrentSunHour();
+ }
+
+ return sunHour;
+ }
+
+ public double osSunGetParam(string param)
+ {
+ CheckThreatLevel(ThreatLevel.None, "osSunGetParam");
+ m_host.AddScriptLPS(1);
+
+ double value = 0.0;
+
+ ISunModule module = World.RequestModuleInterface();
+ if (module != null)
+ {
+ value = module.GetSunParameter(param);
+ }
+
+ return value;
+ }
+
+ public void osSunSetParam(string param, double value)
+ {
+ CheckThreatLevel(ThreatLevel.None, "osSunSetParam");
+ m_host.AddScriptLPS(1);
+
+ ISunModule module = World.RequestModuleInterface();
+ if (module != null)
+ {
+ module.SetSunParameter(param, value);
+ }
+
+ }
+
--
cgit v1.1