aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Environment/Scenes/Scripting/ScriptInterpretedAPI.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/Environment/Scenes/Scripting/ScriptInterpretedAPI.cs')
-rw-r--r--OpenSim/Region/Environment/Scenes/Scripting/ScriptInterpretedAPI.cs266
1 files changed, 266 insertions, 0 deletions
diff --git a/OpenSim/Region/Environment/Scenes/Scripting/ScriptInterpretedAPI.cs b/OpenSim/Region/Environment/Scenes/Scripting/ScriptInterpretedAPI.cs
new file mode 100644
index 0000000..284ae74
--- /dev/null
+++ b/OpenSim/Region/Environment/Scenes/Scripting/ScriptInterpretedAPI.cs
@@ -0,0 +1,266 @@
1using System;
2using System.Collections.Generic;
3using System.Text;
4using Key = libsecondlife.LLUUID;
5using Rotation = libsecondlife.LLQuaternion;
6using Vector = libsecondlife.LLVector3;
7using LSLList = System.Collections.Generic.List<string>;
8
9using OpenSim.Region.Environment.Scenes;
10using OpenSim.Region.Environment.LandManagement;
11
12namespace OpenSim.Region.Scripting
13{
14 /// <summary>
15 /// A class inteded to act as an API for LSL-styled interpreted languages
16 /// </summary>
17 /// <remarks>Avoid at all costs. This should ONLY be used for LSL.</remarks>
18 class ScriptInterpretedAPI
19 {
20 protected libsecondlife.LLUUID m_object;
21 protected Scene m_scene;
22
23 /// <summary>
24 /// The scene in which this script is acting
25 /// </summary>
26 public Scene World
27 {
28 get { return m_scene; }
29 }
30
31 /// <summary>
32 /// The id of the object our script is supposed to be acting in
33 /// </summary>
34 public Key ObjectID
35 {
36 get { return m_object; }
37 }
38
39 /// <summary>
40 /// The object our script is supposed to be in
41 /// </summary>
42 public SceneObject Task
43 {
44 get { return World.Objects[ObjectID]; }
45 }
46
47 /// <summary>
48 /// Creates a new ScriptInterpretedAPI for a specified object
49 /// </summary>
50 /// <param name="world">The scene the object is located in</param>
51 /// <param name="member">The specific member being 'occupied' by the script</param>
52 public ScriptInterpretedAPI(Scene world, libsecondlife.LLUUID member)
53 {
54 m_scene = world;
55 m_object = member;
56 }
57
58 /// <summary>
59 /// Returns the absolute number of a integer value.
60 /// </summary>
61 /// <param name="val">Input</param>
62 /// <returns>Absolute number of input</returns>
63 public int osAbs(int val)
64 {
65 return Math.Abs(val);
66 }
67
68 public float osAcos(float val)
69 {
70 return (float)Math.Acos(val);
71 }
72
73 [Obsolete("Unimplemented")]
74 public void osAddToLandPassList(Key avatar, float hours)
75 {
76 Vector myPosition = Task.Pos;
77 Land myParcel = World.LandManager.getLandObject(myPosition.X, myPosition.Y);
78
79 OpenSim.Framework.Console.MainLog.Instance.Warn("script", "Unimplemented function called by script: osAddToLandPassList(Key avatar, float hours)");
80 return;
81 }
82
83 [Obsolete("Unimplemented")]
84 public void osAdjustSoundVolume(float volume)
85 {
86 OpenSim.Framework.Console.MainLog.Instance.Warn("script", "Unimplemented function called by script: osAdjustSoundVolume(float volume)");
87 return;
88 }
89
90 [Obsolete("Unimplemented")]
91 public void osAllowInventoryDrop(int add)
92 {
93 return;
94 }
95
96 [Obsolete("Unimplemented")]
97 public float osAngleBetween(Rotation a, Rotation b)
98 {
99 Axiom.Math.Quaternion axA = new Axiom.Math.Quaternion(a.W, a.X, a.Y, a.Z);
100 Axiom.Math.Quaternion axB = new Axiom.Math.Quaternion(b.W, b.X, b.Y, b.Z);
101
102 return 0;
103 }
104
105 [Obsolete("Unimplemented")]
106 public void osApplyImpulse(Vector force, int local)
107 {
108 return;
109 }
110
111 [Obsolete("Unimplemented")]
112 public void osApplyRotationalImpulse(Vector force, int local)
113 {
114 return;
115 }
116
117 public float osAsin(float val)
118 {
119 return (float)Math.Asin(val);
120 }
121
122 public float osAtan2(float x, float y)
123 {
124 return (float)Math.Atan2(x, y);
125 }
126
127 [Obsolete("Unimplemented")]
128 public void osAttachToAvatar(Key avatar, int attachmentPoint)
129 {
130 return;
131 }
132
133 [Obsolete("Unimplemented")]
134 public Key osAvatarOnSitTarget()
135 {
136 //TODO: Follow this as Children is chanced to be of type entity to support ScenePresences
137 /*
138 foreach (KeyValuePair<Key, EntityBase> Child in Task.Children)
139 {
140 if (Child.Value is ScenePresence)
141 {
142 return Child.Value.uuid;
143 }
144 }
145 */
146
147 return Key.Zero;
148 }
149
150 public Rotation osAxes2Rot(Vector fwd, Vector left, Vector up)
151 {
152 Axiom.Math.Quaternion axQ = new Axiom.Math.Quaternion();
153 Axiom.Math.Vector3 axFwd = new Axiom.Math.Vector3(fwd.X, fwd.Y, fwd.Z);
154 Axiom.Math.Vector3 axLeft = new Axiom.Math.Vector3(left.X, left.Y, left.Z);
155 Axiom.Math.Vector3 axUp = new Axiom.Math.Vector3(up.X, up.Y, up.Z);
156
157 axQ.FromAxes(axFwd, axLeft, axUp);
158
159 return new Rotation(axQ.x, axQ.y, axQ.z, axQ.w);
160 }
161
162 public Rotation osAxisAngle2Rot(Vector axis, float angle)
163 {
164 Axiom.Math.Quaternion axQ = Axiom.Math.Quaternion.FromAngleAxis(angle, new Axiom.Math.Vector3(axis.X, axis.Y, axis.Z));
165
166 return new Rotation(axQ.x, axQ.y, axQ.z, axQ.w);
167 }
168
169 public string osBase64ToString(string str)
170 {
171 Encoding enc = System.Text.Encoding.UTF8;
172 return enc.GetString(Convert.FromBase64String(str));
173 }
174
175 [Obsolete("Unimplemented")]
176 public void osBreakAllLinks()
177 {
178 return;
179 }
180
181 [Obsolete("Unimplemented")]
182 public void osBreakLink()
183 {
184 return;
185 }
186
187 public LSLList osCSV2List(string src)
188 {
189 LSLList retVal = new LSLList();
190 retVal.AddRange(src.Split(','));
191
192 return retVal;
193 }
194
195 public int osCeil(float val)
196 {
197 return (int)Math.Ceiling(val);
198 }
199
200 [Obsolete("Unimplemented")]
201 public void osCloseRemoteDataChannel(Key channel)
202 {
203 return;
204 }
205
206 [Obsolete("Unimplemented")]
207 public float osCloud(Vector offset)
208 {
209 return 0.0f;
210 }
211
212 [Obsolete("Unimplemented")]
213 public void osCollisionFilter(string name, Key id, int accept)
214 {
215 return;
216 }
217
218 [Obsolete("Unimplemented")]
219 public void osCollisionSprite(string impact_sprite)
220 {
221 return;
222 }
223
224 public float osCos(float theta)
225 {
226 return (float)Math.Cos(theta);
227 }
228
229 public void osCreateLink(Key target, int parent)
230 {
231 if(World.Entities[target] is SceneObject)
232 Task.AddNewChildPrims((SceneObject)World.Entities[target]);
233
234 return;
235 }
236
237 [Obsolete("Partially Unimplemented")]
238 public LSLList osDeleteSubList(LSLList src, int start, int end)
239 {
240 if (start < 0 || end < 0)
241 {
242 throw new Exception("Unsupported at this time.");
243 }
244
245 src.RemoveRange(start, start - end + 1);
246 return src;
247 }
248
249 [Obsolete("Partially Unimplemented")]
250 public string osDeleteSubString(string src, int start, int end)
251 {
252 if (start < 0 || end < 0)
253 {
254 throw new Exception("Unsupported at this time.");
255 }
256
257 return src.Remove(start, start - end + 1);
258 }
259
260 [Obsolete("Unimplemented")]
261 public void osDetachFromAvatar(Key avatar)
262 {
263 return;
264 }
265 }
266}