aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ScriptEngine
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/ScriptEngine')
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/MOD_Api.cs2
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs176
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs25
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs52
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs14
5 files changed, 266 insertions, 3 deletions
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/MOD_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/MOD_Api.cs
index 84cf6ca..cde2d9f 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/MOD_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/MOD_Api.cs
@@ -310,7 +310,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
310 // ---------- Integer ---------- 310 // ---------- Integer ----------
311 else if (lslparm is LSL_Integer) 311 else if (lslparm is LSL_Integer)
312 { 312 {
313 if (type == typeof(int)) 313 if (type == typeof(int) || type == typeof(float))
314 return (int)(LSL_Integer)lslparm; 314 return (int)(LSL_Integer)lslparm;
315 } 315 }
316 316
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
index 7aacfd4..a44ced4 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
@@ -1682,6 +1682,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1682 return; 1682 return;
1683 } 1683 }
1684 1684
1685 MessageObject(objUUID, message);
1686 }
1687
1688 private void MessageObject(UUID objUUID, string message)
1689 {
1685 object[] resobj = new object[] { new LSL_Types.LSLString(m_host.UUID.ToString()), new LSL_Types.LSLString(message) }; 1690 object[] resobj = new object[] { new LSL_Types.LSLString(m_host.UUID.ToString()), new LSL_Types.LSLString(message) };
1686 1691
1687 SceneObjectPart sceneOP = World.GetSceneObjectPart(objUUID); 1692 SceneObjectPart sceneOP = World.GetSceneObjectPart(objUUID);
@@ -3272,6 +3277,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3272 } 3277 }
3273 } 3278 }
3274 3279
3280 #region Attachment commands
3281
3275 public void osForceAttachToAvatar(int attachmentPoint) 3282 public void osForceAttachToAvatar(int attachmentPoint)
3276 { 3283 {
3277 CheckThreatLevel(ThreatLevel.High, "osForceAttachToAvatar"); 3284 CheckThreatLevel(ThreatLevel.High, "osForceAttachToAvatar");
@@ -3361,6 +3368,175 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3361 ((LSL_Api)m_LSL_Api).DetachFromAvatar(); 3368 ((LSL_Api)m_LSL_Api).DetachFromAvatar();
3362 } 3369 }
3363 3370
3371 public LSL_List osGetNumberOfAttachments(LSL_Key avatar, LSL_List attachmentPoints)
3372 {
3373 CheckThreatLevel(ThreatLevel.Moderate, "osGetNumberOfAttachments");
3374
3375 m_host.AddScriptLPS(1);
3376
3377 UUID targetUUID;
3378 ScenePresence target;
3379 LSL_List resp = new LSL_List();
3380
3381 if (attachmentPoints.Length >= 1 && UUID.TryParse(avatar.ToString(), out targetUUID) && World.TryGetScenePresence(targetUUID, out target))
3382 {
3383 foreach (object point in attachmentPoints.Data)
3384 {
3385 LSL_Integer ipoint = new LSL_Integer(
3386 (point is LSL_Integer || point is int || point is uint) ?
3387 (int)point :
3388 0
3389 );
3390 resp.Add(ipoint);
3391 if (ipoint == 0)
3392 {
3393 // indicates zero attachments
3394 resp.Add(new LSL_Integer(0));
3395 }
3396 else
3397 {
3398 // gets the number of attachments on the attachment point
3399 resp.Add(new LSL_Integer(target.GetAttachments((uint)ipoint).Count));
3400 }
3401 }
3402 }
3403
3404 return resp;
3405 }
3406
3407 public void osMessageAttachments(LSL_Key avatar, string message, LSL_List attachmentPoints, int options)
3408 {
3409 CheckThreatLevel(ThreatLevel.Moderate, "osMessageAttachments");
3410 m_host.AddScriptLPS(1);
3411
3412 UUID targetUUID;
3413 ScenePresence target;
3414
3415 if (attachmentPoints.Length >= 1 && UUID.TryParse(avatar.ToString(), out targetUUID) && World.TryGetScenePresence(targetUUID, out target))
3416 {
3417 List<int> aps = new List<int>();
3418 foreach (object point in attachmentPoints.Data)
3419 {
3420 int ipoint;
3421 if (int.TryParse(point.ToString(), out ipoint))
3422 {
3423 aps.Add(ipoint);
3424 }
3425 }
3426
3427 List<SceneObjectGroup> attachments = new List<SceneObjectGroup>();
3428
3429 bool msgAll = aps.Contains(ScriptBaseClass.OS_ATTACH_MSG_ALL);
3430 bool invertPoints = (options & ScriptBaseClass.OS_ATTACH_MSG_INVERT_POINTS) != 0;
3431
3432 if (msgAll && invertPoints)
3433 {
3434 return;
3435 }
3436 else if (msgAll || invertPoints)
3437 {
3438 attachments = target.GetAttachments();
3439 }
3440 else
3441 {
3442 foreach (int point in aps)
3443 {
3444 if (point > 0)
3445 {
3446 attachments.AddRange(target.GetAttachments((uint)point));
3447 }
3448 }
3449 }
3450
3451 // if we have no attachments at this point, exit now
3452 if (attachments.Count == 0)
3453 {
3454 return;
3455 }
3456
3457 List<SceneObjectGroup> ignoreThese = new List<SceneObjectGroup>();
3458
3459 if (invertPoints)
3460 {
3461 foreach (SceneObjectGroup attachment in attachments)
3462 {
3463 if (aps.Contains((int)attachment.AttachmentPoint))
3464 {
3465 ignoreThese.Add(attachment);
3466 }
3467 }
3468 }
3469
3470 foreach (SceneObjectGroup attachment in ignoreThese)
3471 {
3472 attachments.Remove(attachment);
3473 }
3474 ignoreThese.Clear();
3475
3476 // if inverting removed all attachments to check, exit now
3477 if (attachments.Count < 1)
3478 {
3479 return;
3480 }
3481
3482 if ((options & ScriptBaseClass.OS_ATTACH_MSG_OBJECT_CREATOR) != 0)
3483 {
3484 foreach (SceneObjectGroup attachment in attachments)
3485 {
3486 if (attachment.RootPart.CreatorID != m_host.CreatorID)
3487 {
3488 ignoreThese.Add(attachment);
3489 }
3490 }
3491
3492 foreach (SceneObjectGroup attachment in ignoreThese)
3493 {
3494 attachments.Remove(attachment);
3495 }
3496 ignoreThese.Clear();
3497
3498 // if filtering by same object creator removed all
3499 // attachments to check, exit now
3500 if (attachments.Count == 0)
3501 {
3502 return;
3503 }
3504 }
3505
3506 if ((options & ScriptBaseClass.OS_ATTACH_MSG_SCRIPT_CREATOR) != 0)
3507 {
3508 foreach (SceneObjectGroup attachment in attachments)
3509 {
3510 if (attachment.RootPart.CreatorID != m_item.CreatorID)
3511 {
3512 ignoreThese.Add(attachment);
3513 }
3514 }
3515
3516 foreach (SceneObjectGroup attachment in ignoreThese)
3517 {
3518 attachments.Remove(attachment);
3519 }
3520 ignoreThese.Clear();
3521
3522 // if filtering by object creator must match originating
3523 // script creator removed all attachments to check,
3524 // exit now
3525 if (attachments.Count == 0)
3526 {
3527 return;
3528 }
3529 }
3530
3531 foreach (SceneObjectGroup attachment in attachments)
3532 {
3533 MessageObject(attachment.RootPart.UUID, message);
3534 }
3535 }
3536 }
3537
3538 #endregion
3539
3364 /// <summary> 3540 /// <summary>
3365 /// Checks if thing is a UUID. 3541 /// Checks if thing is a UUID.
3366 /// </summary> 3542 /// </summary>
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs
index 07149b6..0ea363a 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs
@@ -157,7 +157,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces
157 void osAvatarPlayAnimation(string avatar, string animation); 157 void osAvatarPlayAnimation(string avatar, string animation);
158 void osAvatarStopAnimation(string avatar, string animation); 158 void osAvatarStopAnimation(string avatar, string animation);
159 159
160 // Attachment commands 160 #region Attachment commands
161 161
162 /// <summary> 162 /// <summary>
163 /// Attach the object containing this script to the avatar that owns it without asking for PERMISSION_ATTACH 163 /// Attach the object containing this script to the avatar that owns it without asking for PERMISSION_ATTACH
@@ -192,6 +192,29 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces
192 /// <remarks>Nothing happens if the object is not attached.</remarks> 192 /// <remarks>Nothing happens if the object is not attached.</remarks>
193 void osForceDetachFromAvatar(); 193 void osForceDetachFromAvatar();
194 194
195 /// <summary>
196 /// Returns a strided list of the specified attachment points and the number of attachments on those points.
197 /// </summary>
198 /// <param name="avatar">avatar UUID</param>
199 /// <param name="attachmentPoints">list of ATTACH_* constants</param>
200 /// <returns></returns>
201 LSL_List osGetNumberOfAttachments(LSL_Key avatar, LSL_List attachmentPoints);
202
203 /// <summary>
204 /// Sends a specified message to the specified avatar's attachments on
205 /// the specified attachment points.
206 /// </summary>
207 /// <remarks>
208 /// Behaves as osMessageObject(), without the sending script needing to know the attachment keys in advance.
209 /// </remarks>
210 /// <param name="avatar">avatar UUID</param>
211 /// <param name="message">message string</param>
212 /// <param name="attachmentPoints">list of ATTACH_* constants, or -1 for all attachments. If -1 is specified and OS_ATTACH_MSG_INVERT_POINTS is present in flags, no action is taken.</param>
213 /// <param name="flags">flags further constraining the attachments to deliver the message to.</param>
214 void osMessageAttachments(LSL_Key avatar, string message, LSL_List attachmentPoints, int flags);
215
216 #endregion
217
195 //texture draw functions 218 //texture draw functions
196 string osMovePen(string drawList, int x, int y); 219 string osMovePen(string drawList, int x, int y);
197 string osDrawLine(string drawList, int startX, int startY, int endX, int endY); 220 string osDrawLine(string drawList, int startX, int startY, int endX, int endY);
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs
index 05ba222..c788407 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs
@@ -237,6 +237,58 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
237 public const int ATTACH_HUD_BOTTOM = 37; 237 public const int ATTACH_HUD_BOTTOM = 37;
238 public const int ATTACH_HUD_BOTTOM_RIGHT = 38; 238 public const int ATTACH_HUD_BOTTOM_RIGHT = 38;
239 239
240 #region osMessageAttachments constants
241
242 /// <summary>
243 /// Instructs osMessageAttachements to send the message to attachments
244 /// on every point.
245 /// </summary>
246 /// <remarks>
247 /// One might expect this to be named OS_ATTACH_ALL, but then one might
248 /// also expect functions designed to attach or detach or get
249 /// attachments to work with it too. Attaching a no-copy item to
250 /// many attachments could be dangerous.
251 /// when combined with OS_ATTACH_MSG_INVERT_POINTS, will prevent the
252 /// message from being sent.
253 /// if combined with OS_ATTACH_MSG_OBJECT_CREATOR or
254 /// OS_ATTACH_MSG_SCRIPT_CREATOR, could result in no message being
255 /// sent- this is expected behaviour.
256 /// </remarks>
257 public const int OS_ATTACH_MSG_ALL = -65535;
258
259 /// <summary>
260 /// Instructs osMessageAttachements to invert how the attachment points
261 /// list should be treated (e.g. go from inclusive operation to
262 /// exclusive operation).
263 /// </summary>
264 /// <remarks>
265 /// This might be used if you want to deliver a message to one set of
266 /// attachments and a different message to everything else. With
267 /// this flag, you only need to build one explicit list for both calls.
268 /// </remarks>
269 public const int OS_ATTACH_MSG_INVERT_POINTS = 1;
270
271 /// <summary>
272 /// Instructs osMessageAttachments to only send the message to
273 /// attachments with a CreatorID that matches the host object CreatorID
274 /// </summary>
275 /// <remarks>
276 /// This would be used if distributed in an object vendor/updater server.
277 /// </remarks>
278 public const int OS_ATTACH_MSG_OBJECT_CREATOR = 2;
279
280 /// <summary>
281 /// Instructs osMessageAttachments to only send the message to
282 /// attachments with a CreatorID that matches the sending script CreatorID
283 /// </summary>
284 /// <remarks>
285 /// This might be used if the script is distributed independently of a
286 /// containing object.
287 /// </remarks>
288 public const int OS_ATTACH_MSG_SCRIPT_CREATOR = 4;
289
290 #endregion
291
240 public const int LAND_LEVEL = 0; 292 public const int LAND_LEVEL = 0;
241 public const int LAND_RAISE = 1; 293 public const int LAND_RAISE = 1;
242 public const int LAND_LOWER = 2; 294 public const int LAND_LOWER = 2;
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs
index ba1ade2..52ca3da 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs
@@ -289,7 +289,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
289 m_OSSL_Functions.osAvatarStopAnimation(avatar, animation); 289 m_OSSL_Functions.osAvatarStopAnimation(avatar, animation);
290 } 290 }
291 291
292 // Avatar functions 292 #region Attachment commands
293 293
294 public void osForceAttachToAvatar(int attachmentPoint) 294 public void osForceAttachToAvatar(int attachmentPoint)
295 { 295 {
@@ -311,6 +311,18 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
311 m_OSSL_Functions.osForceDetachFromAvatar(); 311 m_OSSL_Functions.osForceDetachFromAvatar();
312 } 312 }
313 313
314 public LSL_List osGetNumberOfAttachments(LSL_Key avatar, LSL_List attachmentPoints)
315 {
316 return m_OSSL_Functions.osGetNumberOfAttachments(avatar, attachmentPoints);
317 }
318
319 public void osMessageAttachments(LSL_Key avatar, string message, LSL_List attachmentPoints, int flags)
320 {
321 m_OSSL_Functions.osMessageAttachments(avatar, message, attachmentPoints, flags);
322 }
323
324 #endregion
325
314 // Texture Draw functions 326 // Texture Draw functions
315 327
316 public string osMovePen(string drawList, int x, int y) 328 public string osMovePen(string drawList, int x, int y)