diff options
Diffstat (limited to 'OpenSim/Region/ScriptEngine/Shared/Api')
-rw-r--r-- | OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index f40b1a5..ced5452 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | |||
@@ -7167,9 +7167,27 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
7167 | { | 7167 | { |
7168 | m_host.AddScriptLPS(1); | 7168 | m_host.AddScriptLPS(1); |
7169 | UUID key = new UUID(); | 7169 | UUID key = new UUID(); |
7170 | if (UUID.TryParse(id,out key)) | 7170 | if (UUID.TryParse(id, out key)) |
7171 | { | 7171 | { |
7172 | return (double)World.GetSceneObjectPart(World.Entities[key].LocalId).GetMass(); | 7172 | try |
7173 | { | ||
7174 | SceneObjectPart obj = World.GetSceneObjectPart(World.Entities[key].LocalId); | ||
7175 | if (obj != null) | ||
7176 | return (double)obj.GetMass(); | ||
7177 | // the object is null so the key is for an avatar | ||
7178 | ScenePresence avatar = World.GetScenePresence(key); | ||
7179 | if (avatar != null) | ||
7180 | if (avatar.IsChildAgent) | ||
7181 | // reference http://www.lslwiki.net/lslwiki/wakka.php?wakka=llGetObjectMass | ||
7182 | // child agents have a mass of 1.0 | ||
7183 | return 1; | ||
7184 | else | ||
7185 | return (double)avatar.PhysicsActor.Mass; | ||
7186 | } | ||
7187 | catch (KeyNotFoundException) | ||
7188 | { | ||
7189 | return 0; // The Object/Agent not in the region so just return zero | ||
7190 | } | ||
7173 | } | 7191 | } |
7174 | return 0; | 7192 | return 0; |
7175 | } | 7193 | } |