aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
authorTeravus Ovares2008-01-17 02:23:48 +0000
committerTeravus Ovares2008-01-17 02:23:48 +0000
commitc2863df49d3bd1f4f7c2f4c17d897d9f66b36b26 (patch)
tree8d2c29d6623d9e5c61634e8f7a742858eee2a5db /OpenSim
parent* Fixed standing up so that you're at the new position of the prim if you mov... (diff)
downloadopensim-SC-c2863df49d3bd1f4f7c2f4c17d897d9f66b36b26.zip
opensim-SC-c2863df49d3bd1f4f7c2f4c17d897d9f66b36b26.tar.gz
opensim-SC-c2863df49d3bd1f4f7c2f4c17d897d9f66b36b26.tar.bz2
opensim-SC-c2863df49d3bd1f4f7c2f4c17d897d9f66b36b26.tar.xz
* Added and implemented the LSL changed event.
* An example changed event syntax is at: http://opensimulator.org/wiki/Changed_Event_Example * You can use this to trigger actions in your script if someone sits on your object_rez * You can use this to figure out all of the CHANGED_ constants except for CHANGED_REGION, CHANGED_TELEPORT, and CHANGED_ALLOW_DROP
Diffstat (limited to 'OpenSim')
-rw-r--r--OpenSim/Region/Environment/Scenes/Scene.cs7
-rw-r--r--OpenSim/Region/Environment/Scenes/SceneEvents.cs8
-rw-r--r--OpenSim/Region/Environment/Scenes/SceneObjectPart.Inventory.cs6
-rw-r--r--OpenSim/Region/Environment/Scenes/SceneObjectPart.cs59
-rw-r--r--OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/EventManager.cs7
5 files changed, 81 insertions, 6 deletions
diff --git a/OpenSim/Region/Environment/Scenes/Scene.cs b/OpenSim/Region/Environment/Scenes/Scene.cs
index 449e1d2..3a0e1b9 100644
--- a/OpenSim/Region/Environment/Scenes/Scene.cs
+++ b/OpenSim/Region/Environment/Scenes/Scene.cs
@@ -1249,6 +1249,7 @@ namespace OpenSim.Region.Environment.Scenes
1249 return avatar; 1249 return avatar;
1250 } 1250 }
1251 1251
1252
1252 protected void GetAvatarAppearance(IClientAPI client, out AvatarAppearance appearance) 1253 protected void GetAvatarAppearance(IClientAPI client, out AvatarAppearance appearance)
1253 { 1254 {
1254 if (m_AvatarFactory == null || 1255 if (m_AvatarFactory == null ||
@@ -2190,6 +2191,12 @@ namespace OpenSim.Region.Environment.Scenes
2190 scriptEngine.InitializeEngine(this, logger); 2191 scriptEngine.InitializeEngine(this, logger);
2191 } 2192 }
2192 2193
2194 public void TriggerObjectChanged(uint localID, uint change)
2195 {
2196
2197 m_eventManager.TriggerOnScriptChangedEvent(localID, change);
2198 }
2199
2193 #endregion 2200 #endregion
2194 2201
2195 #region InnerScene wrapper methods 2202 #region InnerScene wrapper methods
diff --git a/OpenSim/Region/Environment/Scenes/SceneEvents.cs b/OpenSim/Region/Environment/Scenes/SceneEvents.cs
index 739f86d..4e9a258 100644
--- a/OpenSim/Region/Environment/Scenes/SceneEvents.cs
+++ b/OpenSim/Region/Environment/Scenes/SceneEvents.cs
@@ -125,7 +125,15 @@ namespace OpenSim.Region.Environment.Scenes
125 125
126 public event NewGridInstantMessage OnGridInstantMessageToGroupsModule; 126 public event NewGridInstantMessage OnGridInstantMessageToGroupsModule;
127 127
128 public delegate void ScriptChangedEvent(uint localID, uint change);
129
130 public event ScriptChangedEvent OnScriptChangedEvent;
128 131
132 public void TriggerOnScriptChangedEvent(uint localID, uint change)
133 {
134 if (OnScriptChangedEvent != null)
135 OnScriptChangedEvent(localID,change);
136 }
129 137
130 public void TriggerOnClientMovement(ScenePresence avatar) 138 public void TriggerOnClientMovement(ScenePresence avatar)
131 { 139 {
diff --git a/OpenSim/Region/Environment/Scenes/SceneObjectPart.Inventory.cs b/OpenSim/Region/Environment/Scenes/SceneObjectPart.Inventory.cs
index be2ddae..1a9e6c4 100644
--- a/OpenSim/Region/Environment/Scenes/SceneObjectPart.Inventory.cs
+++ b/OpenSim/Region/Environment/Scenes/SceneObjectPart.Inventory.cs
@@ -203,6 +203,7 @@ namespace OpenSim.Region.Environment.Scenes
203 lock (m_taskInventory) 203 lock (m_taskInventory)
204 { 204 {
205 m_taskInventory.Add(item.ItemID, item); 205 m_taskInventory.Add(item.ItemID, item);
206 TriggerScriptChangedEvent(Changed.INVENTORY);
206 } 207 }
207 208
208 m_inventorySerial++; 209 m_inventorySerial++;
@@ -220,6 +221,7 @@ namespace OpenSim.Region.Environment.Scenes
220 foreach (TaskInventoryItem item in items) 221 foreach (TaskInventoryItem item in items)
221 { 222 {
222 m_taskInventory.Add(item.ItemID, item); 223 m_taskInventory.Add(item.ItemID, item);
224 TriggerScriptChangedEvent(Changed.INVENTORY);
223 } 225 }
224 } 226 }
225 227
@@ -265,7 +267,8 @@ namespace OpenSim.Region.Environment.Scenes
265 { 267 {
266 m_taskInventory[item.ItemID] = item; 268 m_taskInventory[item.ItemID] = item;
267 m_inventorySerial++; 269 m_inventorySerial++;
268 270 TriggerScriptChangedEvent(Changed.INVENTORY);
271
269 return true; 272 return true;
270 } 273 }
271 else 274 else
@@ -295,6 +298,7 @@ namespace OpenSim.Region.Environment.Scenes
295 int type = m_taskInventory[itemID].InvType; 298 int type = m_taskInventory[itemID].InvType;
296 m_taskInventory.Remove(itemID); 299 m_taskInventory.Remove(itemID);
297 m_inventorySerial++; 300 m_inventorySerial++;
301 TriggerScriptChangedEvent(Changed.INVENTORY);
298 302
299 return type; 303 return type;
300 } 304 }
diff --git a/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs b/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs
index 7866739..0cb4ae7 100644
--- a/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs
+++ b/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs
@@ -42,6 +42,23 @@ using OpenSim.Region.Physics.Manager;
42 42
43namespace OpenSim.Region.Environment.Scenes 43namespace OpenSim.Region.Environment.Scenes
44{ 44{
45 // I don't really know where to put this except here.
46 // Can't access the OpenSim.Region.ScriptEngine.Common.LSL_BaseClass.Changed constants
47
48 [Flags]
49 public enum Changed : uint
50 {
51 INVENTORY = 1,
52 COLOR = 2,
53 SHAPE = 4,
54 SCALE = 8,
55 TEXTURE = 16,
56 LINK = 32,
57 ALLOWED_DROP = 64,
58 OWNER = 128
59 }
60
61
45 public partial class SceneObjectPart : IScriptHost 62 public partial class SceneObjectPart : IScriptHost
46 { 63 {
47 private const PermissionMask OBJFULL_MASK_GENERAL = 64 private const PermissionMask OBJFULL_MASK_GENERAL =
@@ -94,7 +111,7 @@ namespace OpenSim.Region.Environment.Scenes
94 private byte m_updateFlag; 111 private byte m_updateFlag;
95 112
96 #region Properties 113 #region Properties
97 114
98 public LLUUID CreatorID; 115 public LLUUID CreatorID;
99 116
100 public LLUUID ObjectCreator 117 public LLUUID ObjectCreator
@@ -160,7 +177,7 @@ namespace OpenSim.Region.Environment.Scenes
160 /// <returns>A Linked Child Prim objects position in world</returns> 177 /// <returns>A Linked Child Prim objects position in world</returns>
161 public LLVector3 GetWorldPosition() 178 public LLVector3 GetWorldPosition()
162 { 179 {
163 180
164 Quaternion parentRot = new Quaternion( 181 Quaternion parentRot = new Quaternion(
165 ParentGroup.RootPart.RotationOffset.W, 182 ParentGroup.RootPart.RotationOffset.W,
166 ParentGroup.RootPart.RotationOffset.X, 183 ParentGroup.RootPart.RotationOffset.X,
@@ -186,6 +203,7 @@ namespace OpenSim.Region.Environment.Scenes
186 /// <returns></returns> 203 /// <returns></returns>
187 public LLQuaternion GetWorldRotation() 204 public LLQuaternion GetWorldRotation()
188 { 205 {
206
189 Quaternion newRot; 207 Quaternion newRot;
190 208
191 if (this.LinkNum == 0) 209 if (this.LinkNum == 0)
@@ -277,6 +295,7 @@ namespace OpenSim.Region.Environment.Scenes
277 { 295 {
278 // Hack to get the child prim to update world positions in the physics engine 296 // Hack to get the child prim to update world positions in the physics engine
279 ParentGroup.ResetChildPrimPhysicsPositions(); 297 ParentGroup.ResetChildPrimPhysicsPositions();
298
280 } 299 }
281 catch (System.NullReferenceException) 300 catch (System.NullReferenceException)
282 { 301 {
@@ -427,6 +446,8 @@ namespace OpenSim.Region.Environment.Scenes
427 set 446 set
428 { 447 {
429 m_color = value; 448 m_color = value;
449 TriggerScriptChangedEvent(Changed.COLOR);
450
430 /* ScheduleFullUpdate() need not be called b/c after 451 /* ScheduleFullUpdate() need not be called b/c after
431 * setting the color, the text will be set, so then 452 * setting the color, the text will be set, so then
432 * ScheduleFullUpdate() will be called. */ 453 * ScheduleFullUpdate() will be called. */
@@ -477,7 +498,12 @@ namespace OpenSim.Region.Environment.Scenes
477 public int LinkNum 498 public int LinkNum
478 { 499 {
479 get { return m_linkNum; } 500 get { return m_linkNum; }
480 set { m_linkNum = value; } 501 set
502 {
503 m_linkNum = value;
504 TriggerScriptChangedEvent(Changed.LINK);
505
506 }
481 } 507 }
482 508
483 private byte m_clickAction = 0; 509 private byte m_clickAction = 0;
@@ -494,16 +520,35 @@ namespace OpenSim.Region.Environment.Scenes
494 520
495 protected PrimitiveBaseShape m_shape; 521 protected PrimitiveBaseShape m_shape;
496 522
523 public void TriggerScriptChangedEvent(Changed val)
524 {
525 if (m_parentGroup != null)
526 {
527 if (m_parentGroup.Scene != null)
528 m_parentGroup.Scene.TriggerObjectChanged(LocalID, (uint)val);
529 }
530
531 }
532
497 public PrimitiveBaseShape Shape 533 public PrimitiveBaseShape Shape
498 { 534 {
499 get { return m_shape; } 535 get { return m_shape; }
500 set { m_shape = value; } 536 set
537 {
538
539 m_shape = value;
540 TriggerScriptChangedEvent(Changed.SHAPE);
541 }
501 } 542 }
502 543
503 public LLVector3 Scale 544 public LLVector3 Scale
504 { 545 {
505 set { m_shape.Scale = value; }
506 get { return m_shape.Scale; } 546 get { return m_shape.Scale; }
547 set
548 {
549 m_shape.Scale = value;
550 TriggerScriptChangedEvent(Changed.SCALE);
551 }
507 } 552 }
508 553
509 public bool Stopped 554 public bool Stopped
@@ -692,6 +737,8 @@ namespace OpenSim.Region.Environment.Scenes
692 { 737 {
693 BaseMask = NextOwnerMask; 738 BaseMask = NextOwnerMask;
694 OwnerMask = NextOwnerMask; 739 OwnerMask = NextOwnerMask;
740 TriggerScriptChangedEvent(Changed.OWNER);
741
695 } 742 }
696 743
697 public void ApplySanePermissions() 744 public void ApplySanePermissions()
@@ -918,6 +965,7 @@ namespace OpenSim.Region.Environment.Scenes
918 public void SetAvatarOnSitTarget(LLUUID avatarID) 965 public void SetAvatarOnSitTarget(LLUUID avatarID)
919 { 966 {
920 m_SitTargetAvatar = avatarID; 967 m_SitTargetAvatar = avatarID;
968 TriggerScriptChangedEvent(Changed.LINK);
921 } 969 }
922 970
923 public LLUUID GetAvatarOnSitTarget() 971 public LLUUID GetAvatarOnSitTarget()
@@ -1328,6 +1376,7 @@ namespace OpenSim.Region.Environment.Scenes
1328 public void UpdateTextureEntry(byte[] textureEntry) 1376 public void UpdateTextureEntry(byte[] textureEntry)
1329 { 1377 {
1330 m_shape.TextureEntry = textureEntry; 1378 m_shape.TextureEntry = textureEntry;
1379 TriggerScriptChangedEvent(Changed.TEXTURE);
1331 ScheduleFullUpdate(); 1380 ScheduleFullUpdate();
1332 } 1381 }
1333 1382
diff --git a/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/EventManager.cs b/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/EventManager.cs
index 0a8f7ea..a32a132 100644
--- a/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/EventManager.cs
+++ b/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/EventManager.cs
@@ -68,10 +68,17 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase
68 myScriptEngine.World.EventManager.OnObjectGrab += touch_start; 68 myScriptEngine.World.EventManager.OnObjectGrab += touch_start;
69 myScriptEngine.World.EventManager.OnRezScript += OnRezScript; 69 myScriptEngine.World.EventManager.OnRezScript += OnRezScript;
70 myScriptEngine.World.EventManager.OnRemoveScript += OnRemoveScript; 70 myScriptEngine.World.EventManager.OnRemoveScript += OnRemoveScript;
71 myScriptEngine.World.EventManager.OnScriptChangedEvent += changed;
71 // TODO: HOOK ALL EVENTS UP TO SERVER! 72 // TODO: HOOK ALL EVENTS UP TO SERVER!
72 } 73 }
73 } 74 }
74 75
76 public void changed(uint localID, uint change)
77 {
78 // Add to queue for all scripts in localID, Object pass change.
79 myScriptEngine.m_EventQueueManager.AddToObjectQueue(localID,"changed", new object[] {(int) change});
80 }
81
75 public void touch_start(uint localID, LLVector3 offsetPos, IClientAPI remoteClient) 82 public void touch_start(uint localID, LLVector3 offsetPos, IClientAPI remoteClient)
76 { 83 {
77 // Add to queue for all scripts in ObjectID object 84 // Add to queue for all scripts in ObjectID object