diff options
Diffstat (limited to '')
5 files changed, 182 insertions, 8 deletions
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index 2dbbf70..16dd834 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | |||
@@ -1978,6 +1978,32 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1978 | return new LSL_Rotation(q.X, q.Y, q.Z, q.W); | 1978 | return new LSL_Rotation(q.X, q.Y, q.Z, q.W); |
1979 | } | 1979 | } |
1980 | 1980 | ||
1981 | private LSL_Rotation GetPartRot(SceneObjectPart part) | ||
1982 | { | ||
1983 | Quaternion q; | ||
1984 | if (part.LinkNum == 0 || part.LinkNum == 1) // unlinked or root prim | ||
1985 | { | ||
1986 | if (part.ParentGroup.RootPart.AttachmentPoint != 0) | ||
1987 | { | ||
1988 | ScenePresence avatar = World.GetScenePresence(part.AttachedAvatar); | ||
1989 | if (avatar != null) | ||
1990 | { | ||
1991 | if ((avatar.AgentControlFlags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_MOUSELOOK) != 0) | ||
1992 | q = avatar.CameraRotation; // Mouselook | ||
1993 | else | ||
1994 | q = avatar.Rotation; // Currently infrequently updated so may be inaccurate | ||
1995 | } | ||
1996 | else | ||
1997 | q = part.ParentGroup.GroupRotation; // Likely never get here but just in case | ||
1998 | } | ||
1999 | else | ||
2000 | q = part.ParentGroup.GroupRotation; // just the group rotation | ||
2001 | return new LSL_Rotation(q.X, q.Y, q.Z, q.W); | ||
2002 | } | ||
2003 | q = part.GetWorldRotation(); | ||
2004 | return new LSL_Rotation(q.X, q.Y, q.Z, q.W); | ||
2005 | } | ||
2006 | |||
1981 | public LSL_Rotation llGetLocalRot() | 2007 | public LSL_Rotation llGetLocalRot() |
1982 | { | 2008 | { |
1983 | m_host.AddScriptLPS(1); | 2009 | m_host.AddScriptLPS(1); |
@@ -7299,7 +7325,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
7299 | break; | 7325 | break; |
7300 | 7326 | ||
7301 | case (int)ScriptBaseClass.PRIM_ROTATION: | 7327 | case (int)ScriptBaseClass.PRIM_ROTATION: |
7302 | res.Add(llGetRot()); | 7328 | res.Add(GetPartRot(part)); |
7303 | break; | 7329 | break; |
7304 | 7330 | ||
7305 | case (int)ScriptBaseClass.PRIM_TYPE: | 7331 | case (int)ScriptBaseClass.PRIM_TYPE: |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs index 6e3a3ab..b1c357c 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs | |||
@@ -31,12 +31,14 @@ using System.Collections.Generic; | |||
31 | using System.Runtime.Remoting.Lifetime; | 31 | using System.Runtime.Remoting.Lifetime; |
32 | using System.Text; | 32 | using System.Text; |
33 | using System.Net; | 33 | using System.Net; |
34 | using System.Threading; | ||
34 | using OpenMetaverse; | 35 | using OpenMetaverse; |
35 | using Nini.Config; | 36 | using Nini.Config; |
36 | using OpenSim; | 37 | using OpenSim; |
37 | using OpenSim.Framework; | 38 | using OpenSim.Framework; |
38 | using OpenSim.Framework.Communications.Cache; | 39 | using OpenSim.Framework.Communications.Cache; |
39 | using OpenSim.Framework.Console; | 40 | using OpenSim.Framework.Console; |
41 | using OpenSim.Region.CoreModules.Avatar.NPC; | ||
40 | using OpenSim.Region.Framework.Interfaces; | 42 | using OpenSim.Region.Framework.Interfaces; |
41 | using OpenSim.Region.Framework.Scenes; | 43 | using OpenSim.Region.Framework.Scenes; |
42 | using OpenSim.Region.Framework.Scenes.Hypergrid; | 44 | using OpenSim.Region.Framework.Scenes.Hypergrid; |
@@ -831,6 +833,25 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
831 | return drawList; | 833 | return drawList; |
832 | } | 834 | } |
833 | 835 | ||
836 | public string osDrawFilledPolygon(string drawList, LSL_List x, LSL_List y) | ||
837 | { | ||
838 | CheckThreatLevel(ThreatLevel.None, "osDrawFilledPolygon"); | ||
839 | |||
840 | m_host.AddScriptLPS(1); | ||
841 | |||
842 | if (x.Length != y.Length || x.Length < 3) | ||
843 | { | ||
844 | return ""; | ||
845 | } | ||
846 | drawList += "FillPolygon " + x.GetLSLStringItem(0) + "," + y.GetLSLStringItem(0); | ||
847 | for (int i = 1; i < x.Length; i++) | ||
848 | { | ||
849 | drawList += "," + x.GetLSLStringItem(i) + "," + y.GetLSLStringItem(i); | ||
850 | } | ||
851 | drawList += "; "; | ||
852 | return drawList; | ||
853 | } | ||
854 | |||
834 | public string osSetFontSize(string drawList, int fontSize) | 855 | public string osSetFontSize(string drawList, int fontSize) |
835 | { | 856 | { |
836 | CheckThreatLevel(ThreatLevel.None, "osSetFontSize"); | 857 | CheckThreatLevel(ThreatLevel.None, "osSetFontSize"); |
@@ -858,6 +879,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
858 | return drawList; | 879 | return drawList; |
859 | } | 880 | } |
860 | 881 | ||
882 | public string osSetPenCap(string drawList, string direction, string type) | ||
883 | { | ||
884 | CheckThreatLevel(ThreatLevel.None, "osSetPenColour"); | ||
885 | |||
886 | m_host.AddScriptLPS(1); | ||
887 | drawList += "PenCap " + direction + "," + type + "; "; | ||
888 | return drawList; | ||
889 | } | ||
890 | |||
861 | public string osDrawImage(string drawList, int width, int height, string imageUrl) | 891 | public string osDrawImage(string drawList, int width, int height, string imageUrl) |
862 | { | 892 | { |
863 | CheckThreatLevel(ThreatLevel.None, "osDrawImage"); | 893 | CheckThreatLevel(ThreatLevel.None, "osDrawImage"); |
@@ -1762,5 +1792,57 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1762 | return retVal; | 1792 | return retVal; |
1763 | } | 1793 | } |
1764 | 1794 | ||
1795 | public LSL_Key osNpcCreate(string firstname, string lastname, LSL_Vector position, LSL_Key cloneFrom) | ||
1796 | { | ||
1797 | CheckThreatLevel(ThreatLevel.High, "osNpcCreate"); | ||
1798 | //QueueUserWorkItem | ||
1799 | |||
1800 | INPCModule module = World.RequestModuleInterface<INPCModule>(); | ||
1801 | if (module != null) | ||
1802 | { | ||
1803 | UUID x = module.CreateNPC(firstname, | ||
1804 | lastname, | ||
1805 | new Vector3((float) position.x, (float) position.y, (float) position.z), | ||
1806 | World, | ||
1807 | new UUID(cloneFrom)); | ||
1808 | |||
1809 | return new LSL_Key(x.ToString()); | ||
1810 | } | ||
1811 | return new LSL_Key(UUID.Zero.ToString()); | ||
1812 | } | ||
1813 | |||
1814 | public void osNpcMoveTo(LSL_Key npc, LSL_Vector position) | ||
1815 | { | ||
1816 | CheckThreatLevel(ThreatLevel.High, "osNpcMoveTo"); | ||
1817 | |||
1818 | INPCModule module = World.RequestModuleInterface<INPCModule>(); | ||
1819 | if (module != null) | ||
1820 | { | ||
1821 | Vector3 pos = new Vector3((float) position.x, (float) position.y, (float) position.z); | ||
1822 | module.Autopilot(new UUID(npc.m_string), World, pos); | ||
1823 | } | ||
1824 | } | ||
1825 | |||
1826 | public void osNpcSay(LSL_Key npc, string message) | ||
1827 | { | ||
1828 | CheckThreatLevel(ThreatLevel.High, "osNpcSay"); | ||
1829 | |||
1830 | INPCModule module = World.RequestModuleInterface<INPCModule>(); | ||
1831 | if (module != null) | ||
1832 | { | ||
1833 | module.Say(new UUID(npc.m_string), World, message); | ||
1834 | } | ||
1835 | } | ||
1836 | |||
1837 | public void osNpcRemove(LSL_Key npc) | ||
1838 | { | ||
1839 | CheckThreatLevel(ThreatLevel.High, "osNpcRemove"); | ||
1840 | |||
1841 | INPCModule module = World.RequestModuleInterface<INPCModule>(); | ||
1842 | if (module != null) | ||
1843 | { | ||
1844 | module.DeleteNPC(new UUID(npc.m_string), World); | ||
1845 | } | ||
1846 | } | ||
1765 | } | 1847 | } |
1766 | } | 1848 | } |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs index 0be29f2..2365bee 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs | |||
@@ -97,9 +97,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces | |||
97 | string osDrawEllipse(string drawList, int width, int height); | 97 | string osDrawEllipse(string drawList, int width, int height); |
98 | string osDrawRectangle(string drawList, int width, int height); | 98 | string osDrawRectangle(string drawList, int width, int height); |
99 | string osDrawFilledRectangle(string drawList, int width, int height); | 99 | string osDrawFilledRectangle(string drawList, int width, int height); |
100 | string osDrawFilledPolygon(string drawList, LSL_List x, LSL_List y); | ||
100 | string osSetFontSize(string drawList, int fontSize); | 101 | string osSetFontSize(string drawList, int fontSize); |
101 | string osSetPenSize(string drawList, int penSize); | 102 | string osSetPenSize(string drawList, int penSize); |
102 | string osSetPenColour(string drawList, string colour); | 103 | string osSetPenColour(string drawList, string colour); |
104 | string osSetPenCap(string drawList, string direction, string type); | ||
103 | string osDrawImage(string drawList, int width, int height, string imageUrl); | 105 | string osDrawImage(string drawList, int width, int height, string imageUrl); |
104 | vector osGetDrawStringSize(string contentType, string text, string fontName, int fontSize); | 106 | vector osGetDrawStringSize(string contentType, string text, string fontName, int fontSize); |
105 | void osSetStateEvents(int events); | 107 | void osSetStateEvents(int events); |
@@ -149,5 +151,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces | |||
149 | 151 | ||
150 | LSL_List osGetLinkPrimitiveParams(int linknumber, LSL_List rules); | 152 | LSL_List osGetLinkPrimitiveParams(int linknumber, LSL_List rules); |
151 | 153 | ||
154 | |||
155 | key osNpcCreate(string user, string name, vector position, key cloneFrom); | ||
156 | void osNpcMoveTo(key npc, vector position); | ||
157 | void osNpcSay(key npc, string message); | ||
158 | void osNpcRemove(key npc); | ||
159 | |||
152 | } | 160 | } |
153 | } | 161 | } |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs index abdba05..f877acb 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs | |||
@@ -267,6 +267,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase | |||
267 | return m_OSSL_Functions.osDrawFilledRectangle(drawList, width, height); | 267 | return m_OSSL_Functions.osDrawFilledRectangle(drawList, width, height); |
268 | } | 268 | } |
269 | 269 | ||
270 | public string osDrawFilledPolygon(string drawList, LSL_List x, LSL_List y) | ||
271 | { | ||
272 | return m_OSSL_Functions.osDrawFilledPolygon(drawList, x, y); | ||
273 | } | ||
274 | |||
270 | public string osSetFontSize(string drawList, int fontSize) | 275 | public string osSetFontSize(string drawList, int fontSize) |
271 | { | 276 | { |
272 | return m_OSSL_Functions.osSetFontSize(drawList, fontSize); | 277 | return m_OSSL_Functions.osSetFontSize(drawList, fontSize); |
@@ -277,6 +282,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase | |||
277 | return m_OSSL_Functions.osSetPenSize(drawList, penSize); | 282 | return m_OSSL_Functions.osSetPenSize(drawList, penSize); |
278 | } | 283 | } |
279 | 284 | ||
285 | public string osSetPenCap(string drawList, string direction, string type) | ||
286 | { | ||
287 | return m_OSSL_Functions.osSetPenCap(drawList, direction, type); | ||
288 | } | ||
289 | |||
280 | public string osSetPenColour(string drawList, string colour) | 290 | public string osSetPenColour(string drawList, string colour) |
281 | { | 291 | { |
282 | return m_OSSL_Functions.osSetPenColour(drawList, colour); | 292 | return m_OSSL_Functions.osSetPenColour(drawList, colour); |
@@ -393,6 +403,25 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase | |||
393 | return m_OSSL_Functions.osGetLinkPrimitiveParams(linknumber, rules); | 403 | return m_OSSL_Functions.osGetLinkPrimitiveParams(linknumber, rules); |
394 | } | 404 | } |
395 | 405 | ||
406 | public key osNpcCreate(string user, string name, vector position, key cloneFrom) | ||
407 | { | ||
408 | return m_OSSL_Functions.osNpcCreate(user, name, position, cloneFrom); | ||
409 | } | ||
410 | |||
411 | public void osNpcMoveTo(key npc, vector position) | ||
412 | { | ||
413 | m_OSSL_Functions.osNpcMoveTo(npc, position); | ||
414 | } | ||
415 | |||
416 | public void osNpcSay(key npc, string message) | ||
417 | { | ||
418 | m_OSSL_Functions.osNpcSay(npc, message); | ||
419 | } | ||
420 | |||
421 | public void osNpcRemove(key npc) | ||
422 | { | ||
423 | m_OSSL_Functions.osNpcRemove(npc); | ||
424 | } | ||
396 | 425 | ||
397 | public OSSLPrim Prim; | 426 | public OSSLPrim Prim; |
398 | 427 | ||
diff --git a/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs b/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs index bdacf8b..2842f6b 100644 --- a/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs +++ b/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs | |||
@@ -439,6 +439,13 @@ namespace OpenSim.Region.ScriptEngine.Shared | |||
439 | 439 | ||
440 | set {m_data = value; } | 440 | set {m_data = value; } |
441 | } | 441 | } |
442 | // Function to obtain LSL type from an index. This is needed | ||
443 | // because LSL lists allow for multiple types, and safely | ||
444 | // iterating in them requires a type check. | ||
445 | public Type GetLSLListItemType(int itemIndex) | ||
446 | { | ||
447 | return m_data[itemIndex].GetType(); | ||
448 | } | ||
442 | 449 | ||
443 | // Member functions to obtain item as specific types. | 450 | // Member functions to obtain item as specific types. |
444 | // For cases where implicit conversions would apply if items | 451 | // For cases where implicit conversions would apply if items |
@@ -465,6 +472,10 @@ namespace OpenSim.Region.ScriptEngine.Shared | |||
465 | { | 472 | { |
466 | return new LSL_Types.LSLFloat((Double)m_data[itemIndex]); | 473 | return new LSL_Types.LSLFloat((Double)m_data[itemIndex]); |
467 | } | 474 | } |
475 | else if (m_data[itemIndex] is LSL_Types.LSLString) | ||
476 | { | ||
477 | return new LSL_Types.LSLFloat(m_data[itemIndex].ToString()); | ||
478 | } | ||
468 | else | 479 | else |
469 | { | 480 | { |
470 | return (LSL_Types.LSLFloat)m_data[itemIndex]; | 481 | return (LSL_Types.LSLFloat)m_data[itemIndex]; |
@@ -481,20 +492,32 @@ namespace OpenSim.Region.ScriptEngine.Shared | |||
481 | { | 492 | { |
482 | return new LSL_Types.LSLString((string)m_data[itemIndex]); | 493 | return new LSL_Types.LSLString((string)m_data[itemIndex]); |
483 | } | 494 | } |
495 | else if (m_data[itemIndex] is LSL_Types.LSLFloat) | ||
496 | { | ||
497 | return new LSL_Types.LSLString((LSLFloat)m_data[itemIndex]); | ||
498 | } | ||
499 | else if (m_data[itemIndex] is LSL_Types.LSLInteger) | ||
500 | { | ||
501 | return new LSL_Types.LSLString((LSLInteger)m_data[itemIndex]); | ||
502 | } | ||
484 | else | 503 | else |
485 | { | 504 | { |
486 | return (LSL_Types.LSLString)m_data[itemIndex]; | 505 | return (LSL_Types.LSLString)m_data[itemIndex]; |
487 | } | 506 | } |
488 | } | 507 | } |
489 | 508 | ||
490 | public LSL_Types.LSLInteger GetLSLIntegerItem(int itemIndex) | 509 | public LSL_Types.LSLInteger GetLSLIntegerItem(int itemIndex) |
491 | { | 510 | { |
492 | if (m_data[itemIndex] is LSL_Types.LSLInteger) | 511 | if (m_data[itemIndex] is LSL_Types.LSLInteger) |
493 | return (LSL_Types.LSLInteger)m_data[itemIndex]; | 512 | return (LSL_Types.LSLInteger)m_data[itemIndex]; |
494 | else if (m_data[itemIndex] is Int32) | 513 | if (m_data[itemIndex] is LSL_Types.LSLFloat) |
495 | return new LSLInteger((int)m_data[itemIndex]); | 514 | return new LSLInteger((int)m_data[itemIndex]); |
496 | else | 515 | else if (m_data[itemIndex] is Int32) |
497 | throw new InvalidCastException(); | 516 | return new LSLInteger((int)m_data[itemIndex]); |
517 | else if (m_data[itemIndex] is LSL_Types.LSLString) | ||
518 | return new LSLInteger((string)m_data[itemIndex]); | ||
519 | else | ||
520 | throw new InvalidCastException(); | ||
498 | } | 521 | } |
499 | 522 | ||
500 | public LSL_Types.Vector3 GetVector3Item(int itemIndex) | 523 | public LSL_Types.Vector3 GetVector3Item(int itemIndex) |
@@ -1331,6 +1354,12 @@ namespace OpenSim.Region.ScriptEngine.Shared | |||
1331 | m_string=s; | 1354 | m_string=s; |
1332 | } | 1355 | } |
1333 | 1356 | ||
1357 | public LSLString(LSLInteger i) | ||
1358 | { | ||
1359 | string s = String.Format("{0}", i); | ||
1360 | m_string = s; | ||
1361 | } | ||
1362 | |||
1334 | #endregion | 1363 | #endregion |
1335 | 1364 | ||
1336 | #region Operators | 1365 | #region Operators |