aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ScriptEngine/Shared/Api/Implementation
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/ScriptEngine/Shared/Api/Implementation')
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs5
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/MOD_Api.cs134
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs91
3 files changed, 202 insertions, 28 deletions
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
index 0f01c36..fc17808 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
@@ -2163,7 +2163,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2163 public LSL_Vector llGetOmega() 2163 public LSL_Vector llGetOmega()
2164 { 2164 {
2165 m_host.AddScriptLPS(1); 2165 m_host.AddScriptLPS(1);
2166 return new LSL_Vector(m_host.RotationalVelocity.X, m_host.RotationalVelocity.Y, m_host.RotationalVelocity.Z); 2166 return new LSL_Vector(m_host.AngularVelocity.X, m_host.AngularVelocity.Y, m_host.AngularVelocity.Z);
2167 } 2167 }
2168 2168
2169 public LSL_Float llGetTimeOfDay() 2169 public LSL_Float llGetTimeOfDay()
@@ -3163,7 +3163,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3163 public void llTargetOmega(LSL_Vector axis, double spinrate, double gain) 3163 public void llTargetOmega(LSL_Vector axis, double spinrate, double gain)
3164 { 3164 {
3165 m_host.AddScriptLPS(1); 3165 m_host.AddScriptLPS(1);
3166 m_host.RotationalVelocity = new Vector3((float)(axis.x * spinrate), (float)(axis.y * spinrate), (float)(axis.z * spinrate));
3167 m_host.AngularVelocity = new Vector3((float)(axis.x * spinrate), (float)(axis.y * spinrate), (float)(axis.z * spinrate)); 3166 m_host.AngularVelocity = new Vector3((float)(axis.x * spinrate), (float)(axis.y * spinrate), (float)(axis.z * spinrate));
3168 m_host.ScheduleTerseUpdate(); 3167 m_host.ScheduleTerseUpdate();
3169 m_host.SendTerseUpdateToAllClients(); 3168 m_host.SendTerseUpdateToAllClients();
@@ -3821,7 +3820,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3821 { 3820 {
3822 case 1: // DATA_ONLINE (0|1) 3821 case 1: // DATA_ONLINE (0|1)
3823 // TODO: implement fetching of this information 3822 // TODO: implement fetching of this information
3824 if (userProfile.CurrentAgent.AgentOnline) 3823 if (userProfile.CurrentAgent!=null && userProfile.CurrentAgent.AgentOnline)
3825 reply = "1"; 3824 reply = "1";
3826 else 3825 else
3827 reply = "0"; 3826 reply = "0";
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/MOD_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/MOD_Api.cs
new file mode 100644
index 0000000..d4facdd
--- /dev/null
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/MOD_Api.cs
@@ -0,0 +1,134 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using System.Reflection;
30using System.Collections;
31using System.Collections.Generic;
32using System.Runtime.Remoting.Lifetime;
33using OpenMetaverse;
34using Nini.Config;
35using OpenSim;
36using OpenSim.Framework;
37using OpenSim.Region.Framework.Interfaces;
38using OpenSim.Region.Framework.Scenes;
39using OpenSim.Region.ScriptEngine.Shared;
40using OpenSim.Region.ScriptEngine.Shared.Api.Plugins;
41using OpenSim.Region.ScriptEngine.Shared.ScriptBase;
42using OpenSim.Region.ScriptEngine.Interfaces;
43using OpenSim.Region.ScriptEngine.Shared.Api.Interfaces;
44
45using LSL_Float = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLFloat;
46using LSL_Integer = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLInteger;
47using LSL_Key = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLString;
48using LSL_List = OpenSim.Region.ScriptEngine.Shared.LSL_Types.list;
49using LSL_Rotation = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Quaternion;
50using LSL_String = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLString;
51using LSL_Vector = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Vector3;
52
53namespace OpenSim.Region.ScriptEngine.Shared.Api
54{
55 [Serializable]
56 public class MOD_Api : MarshalByRefObject, IMOD_Api, IScriptApi
57 {
58 internal IScriptEngine m_ScriptEngine;
59 internal SceneObjectPart m_host;
60 internal uint m_localID;
61 internal UUID m_itemID;
62 internal bool m_MODFunctionsEnabled = false;
63 internal IScriptModuleComms m_comms = null;
64
65 public void Initialize(IScriptEngine ScriptEngine, SceneObjectPart host, uint localID, UUID itemID)
66 {
67 m_ScriptEngine = ScriptEngine;
68 m_host = host;
69 m_localID = localID;
70 m_itemID = itemID;
71
72 if (m_ScriptEngine.Config.GetBoolean("AllowMODFunctions", false))
73 m_MODFunctionsEnabled = true;
74
75 m_comms = m_ScriptEngine.World.RequestModuleInterface<IScriptModuleComms>();
76 if (m_comms == null)
77 m_MODFunctionsEnabled = false;
78 }
79
80 public override Object InitializeLifetimeService()
81 {
82 ILease lease = (ILease)base.InitializeLifetimeService();
83
84 if (lease.CurrentState == LeaseState.Initial)
85 {
86 lease.InitialLeaseTime = TimeSpan.FromMinutes(0);
87// lease.RenewOnCallTime = TimeSpan.FromSeconds(10.0);
88// lease.SponsorshipTimeout = TimeSpan.FromMinutes(1.0);
89 }
90 return lease;
91 }
92
93 public Scene World
94 {
95 get { return m_ScriptEngine.World; }
96 }
97
98 internal void MODError(string msg)
99 {
100 throw new Exception("MOD Runtime Error: " + msg);
101 }
102
103 //
104 //Dumps an error message on the debug console.
105 //
106
107 internal void MODShoutError(string message)
108 {
109 if (message.Length > 1023)
110 message = message.Substring(0, 1023);
111
112 World.SimChat(Utils.StringToBytes(message),
113 ChatTypeEnum.Shout, ScriptBaseClass.DEBUG_CHANNEL, m_host.ParentGroup.RootPart.AbsolutePosition, m_host.Name, m_host.UUID, true);
114
115 IWorldComm wComm = m_ScriptEngine.World.RequestModuleInterface<IWorldComm>();
116 wComm.DeliverMessage(ChatTypeEnum.Shout, ScriptBaseClass.DEBUG_CHANNEL, m_host.Name, m_host.UUID, message);
117 }
118
119 public string modSendCommand(string module, string command, string k)
120 {
121 if (!m_MODFunctionsEnabled)
122 {
123 MODShoutError("Module command functions not enabled");
124 return UUID.Zero.ToString();;
125 }
126
127 UUID req = UUID.Random();
128
129 m_comms.RaiseEvent(m_itemID, req.ToString(), module, command, k);
130
131 return req.ToString();
132 }
133 }
134}
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
index 52396b6..3ffcff0 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
@@ -199,7 +199,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
199 //Dumps an error message on the debug console. 199 //Dumps an error message on the debug console.
200 // 200 //
201 201
202 internal void OSSLShoutError(string message) 202 internal void OSSLShoutError(string message)
203 { 203 {
204 if (message.Length > 1023) 204 if (message.Length > 1023)
205 message = message.Substring(0, 1023); 205 message = message.Substring(0, 1023);
@@ -384,7 +384,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
384 m_host.AddScriptLPS(1); 384 m_host.AddScriptLPS(1);
385 if (World.Entities.ContainsKey(target)) 385 if (World.Entities.ContainsKey(target))
386 { 386 {
387 World.Entities[target].Rotation = rotation; 387 EntityBase entity;
388 if (World.Entities.TryGetValue(target, out entity))
389 {
390 if (entity is SceneObjectGroup)
391 ((SceneObjectGroup)entity).Rotation = rotation;
392 else if (entity is ScenePresence)
393 ((ScenePresence)entity).Rotation = rotation;
394 }
388 } 395 }
389 else 396 else
390 { 397 {
@@ -1169,7 +1176,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1169 1176
1170 land.SetMediaUrl(url); 1177 land.SetMediaUrl(url);
1171 } 1178 }
1172 1179
1173 public void osSetParcelSIPAddress(string SIPAddress) 1180 public void osSetParcelSIPAddress(string SIPAddress)
1174 { 1181 {
1175 // What actually is the difference to the LL function? 1182 // What actually is the difference to the LL function?
@@ -1177,7 +1184,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1177 CheckThreatLevel(ThreatLevel.VeryLow, "osSetParcelMediaURL"); 1184 CheckThreatLevel(ThreatLevel.VeryLow, "osSetParcelMediaURL");
1178 1185
1179 m_host.AddScriptLPS(1); 1186 m_host.AddScriptLPS(1);
1180 1187
1181 1188
1182 ILandObject land 1189 ILandObject land
1183 = World.LandChannel.GetLandObject(m_host.AbsolutePosition.X, m_host.AbsolutePosition.Y); 1190 = World.LandChannel.GetLandObject(m_host.AbsolutePosition.X, m_host.AbsolutePosition.Y);
@@ -1187,16 +1194,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1187 OSSLError("osSetParcelSIPAddress: Sorry, you need to own the land to use this function"); 1194 OSSLError("osSetParcelSIPAddress: Sorry, you need to own the land to use this function");
1188 return; 1195 return;
1189 } 1196 }
1190 1197
1191 // get the voice module 1198 // get the voice module
1192 IVoiceModule voiceModule = World.RequestModuleInterface<IVoiceModule>(); 1199 IVoiceModule voiceModule = World.RequestModuleInterface<IVoiceModule>();
1193 1200
1194 if (voiceModule != null) 1201 if (voiceModule != null)
1195 voiceModule.setLandSIPAddress(SIPAddress,land.LandData.GlobalID); 1202 voiceModule.setLandSIPAddress(SIPAddress,land.LandData.GlobalID);
1196 else 1203 else
1197 OSSLError("osSetParcelSIPAddress: No voice module enabled for this land"); 1204 OSSLError("osSetParcelSIPAddress: No voice module enabled for this land");
1198 1205
1199 1206
1200 } 1207 }
1201 1208
1202 public string osGetScriptEngineName() 1209 public string osGetScriptEngineName()
@@ -1476,12 +1483,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1476 m_host.AddScriptLPS(1); 1483 m_host.AddScriptLPS(1);
1477 1484
1478 // Create new asset 1485 // Create new asset
1479 AssetBase asset = new AssetBase(); 1486 AssetBase asset = new AssetBase(UUID.Random(), notecardName, (sbyte)AssetType.Notecard);
1480 asset.Name = notecardName;
1481 asset.Description = "Script Generated Notecard"; 1487 asset.Description = "Script Generated Notecard";
1482 asset.Type = 7; 1488 string notecardData = String.Empty;
1483 asset.FullID = UUID.Random();
1484 string notecardData = "";
1485 1489
1486 for (int i = 0; i < contents.Length; i++) { 1490 for (int i = 0; i < contents.Length; i++) {
1487 notecardData += contents.GetLSLStringItem(i) + "\n"; 1491 notecardData += contents.GetLSLStringItem(i) + "\n";
@@ -1521,10 +1525,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1521 } 1525 }
1522 1526
1523 1527
1524 /*Instead of using the LSL Dataserver event to pull notecard data, 1528 /*Instead of using the LSL Dataserver event to pull notecard data,
1525 this will simply read the requested line and return its data as a string. 1529 this will simply read the requested line and return its data as a string.
1526 1530
1527 Warning - due to the synchronous method this function uses to fetch assets, its use 1531 Warning - due to the synchronous method this function uses to fetch assets, its use
1528 may be dangerous and unreliable while running in grid mode. 1532 may be dangerous and unreliable while running in grid mode.
1529 */ 1533 */
1530 public string osGetNotecardLine(string name, int line) 1534 public string osGetNotecardLine(string name, int line)
@@ -1572,10 +1576,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1572 1576
1573 } 1577 }
1574 1578
1575 /*Instead of using the LSL Dataserver event to pull notecard data line by line, 1579 /*Instead of using the LSL Dataserver event to pull notecard data line by line,
1576 this will simply read the entire notecard and return its data as a string. 1580 this will simply read the entire notecard and return its data as a string.
1577 1581
1578 Warning - due to the synchronous method this function uses to fetch assets, its use 1582 Warning - due to the synchronous method this function uses to fetch assets, its use
1579 may be dangerous and unreliable while running in grid mode. 1583 may be dangerous and unreliable while running in grid mode.
1580 */ 1584 */
1581 1585
@@ -1630,10 +1634,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1630 1634
1631 } 1635 }
1632 1636
1633 /*Instead of using the LSL Dataserver event to pull notecard data, 1637 /*Instead of using the LSL Dataserver event to pull notecard data,
1634 this will simply read the number of note card lines and return this data as an integer. 1638 this will simply read the number of note card lines and return this data as an integer.
1635 1639
1636 Warning - due to the synchronous method this function uses to fetch assets, its use 1640 Warning - due to the synchronous method this function uses to fetch assets, its use
1637 may be dangerous and unreliable while running in grid mode. 1641 may be dangerous and unreliable while running in grid mode.
1638 */ 1642 */
1639 1643
@@ -1833,7 +1837,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1833 1837
1834 return World.RegionInfo.RegionSettings.LoadedCreationID; 1838 return World.RegionInfo.RegionSettings.LoadedCreationID;
1835 } 1839 }
1836 1840
1837 // Threat level is 'Low' because certain users could possibly be tricked into 1841 // Threat level is 'Low' because certain users could possibly be tricked into
1838 // dropping an unverified script into one of their own objects, which could 1842 // dropping an unverified script into one of their own objects, which could
1839 // then gather the physical construction details of the object and transmit it 1843 // then gather the physical construction details of the object and transmit it
@@ -1857,7 +1861,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1857 public LSL_Key osNpcCreate(string firstname, string lastname, LSL_Vector position, LSL_Key cloneFrom) 1861 public LSL_Key osNpcCreate(string firstname, string lastname, LSL_Vector position, LSL_Key cloneFrom)
1858 { 1862 {
1859 CheckThreatLevel(ThreatLevel.High, "osNpcCreate"); 1863 CheckThreatLevel(ThreatLevel.High, "osNpcCreate");
1860 //QueueUserWorkItem 1864 //QueueUserWorkItem
1861 1865
1862 INPCModule module = World.RequestModuleInterface<INPCModule>(); 1866 INPCModule module = World.RequestModuleInterface<INPCModule>();
1863 if (module != null) 1867 if (module != null)
@@ -1906,5 +1910,42 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1906 module.DeleteNPC(new UUID(npc.m_string), World); 1910 module.DeleteNPC(new UUID(npc.m_string), World);
1907 } 1911 }
1908 } 1912 }
1913
1914 /// <summary>
1915 /// Get current region's map texture UUID
1916 /// </summary>
1917 /// <returns></returns>
1918 public LSL_Key osGetMapTexture()
1919 {
1920 CheckThreatLevel(ThreatLevel.None, "osGetMapTexture");
1921 return m_ScriptEngine.World.RegionInfo.RegionSettings.TerrainImageID.ToString();
1922 }
1923
1924 /// <summary>
1925 /// Get a region's map texture UUID by region UUID or name.
1926 /// </summary>
1927 /// <param name="regionName"></param>
1928 /// <returns></returns>
1929 public LSL_Key osGetRegionMapTexture(string regionName)
1930 {
1931 CheckThreatLevel(ThreatLevel.High, "osGetRegionMapTexture");
1932 Scene scene = m_ScriptEngine.World;
1933 UUID key = UUID.Zero;
1934 GridRegion region;
1935
1936 //If string is a key, use it. Otherwise, try to locate region by name.
1937 if (UUID.TryParse(regionName, out key))
1938 region = scene.GridService.GetRegionByUUID(UUID.Zero, key);
1939 else
1940 region = scene.GridService.GetRegionByName(UUID.Zero, regionName);
1941
1942 // If region was found, return the regions map texture key.
1943 if (region != null)
1944 key = region.TerrainImage;
1945
1946 ScriptSleep(1000);
1947
1948 return key.ToString();
1949 }
1909 } 1950 }
1910} 1951}