From c8aaf538e4b1233e0553eedcd459637be2c078a8 Mon Sep 17 00:00:00 2001 From: Dr Scofield Date: Thu, 26 Mar 2009 12:08:18 +0000 Subject: - adding osGetAgents() which returns a list of all avatars in the region in which the script is running. - found a bag of space characters under my desk, thought i'd donate them to the JSON OSSL function (aka clean up) --- .../Shared/Api/Implementation/OSSL_Api.cs | 119 +++++++++++++-------- 1 file changed, 73 insertions(+), 46 deletions(-) (limited to 'OpenSim/Region/ScriptEngine/Shared/Api/Implementation') diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs index 8776524..c87cc44 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs @@ -582,6 +582,21 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api return ""; } + // Get a list of all the avatars/agents in the region + public LSL_List osGetAgents() + { + // threat level is None as we could get this information with an + // in-world script as well, just not as efficient + CheckThreatLevel(ThreatLevel.None, "osGetAgents"); + + LSL_List result = new LSL_List(); + foreach (ScenePresence avatar in World.GetAvatars()) + { + result.Add(avatar.Name); + } + return result; + } + // Adam's super super custom animation functions public void osAvatarPlayAnimation(string avatar, string animation) { @@ -595,7 +610,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api ScenePresence target = (ScenePresence)World.Entities[avatarID]; if (target != null) { - UUID animID=UUID.Zero; + UUID animID=UUID.Zero; lock (m_host.TaskInventory) { foreach (KeyValuePair inv in m_host.TaskInventory) @@ -626,9 +641,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api if (World.Entities.ContainsKey(avatarID) && World.Entities[avatarID] is ScenePresence) { ScenePresence target = (ScenePresence)World.Entities[avatarID]; - if (target != null) - { - UUID animID=UUID.Zero; + if (target != null) + { + UUID animID=UUID.Zero; lock (m_host.TaskInventory) { foreach (KeyValuePair inv in m_host.TaskInventory) @@ -645,7 +660,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api target.RemoveAnimation(animation); else target.RemoveAnimation(animID); - } + } } } @@ -998,16 +1013,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api // see http://www.json.org/ for more details on JSON - string currentKey=null; + string currentKey = null; Stack objectStack = new Stack(); // objects in JSON can be nested so we need to keep a track of this Hashtable jsondata = new Hashtable(); // the hashtable to be returned - int i=0; + int i = 0; try { // iterate through the serialised stream of tokens and store at the right depth in the hashtable // the top level hashtable may contain more nested hashtables within it each containing an objects representation - for (i=0;i