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