public LSL_Float llGetObjectMass(string id)
{
if (!ScriptProtection.CheckThreatLevel(ThreatLevel.None, "LSL", m_host, "LSL", m_itemID)) return new LSL_Float();
UUID key = new UUID();
if (UUID.TryParse(id, out key))
{
try
{
ISceneChildEntity obj = World.GetSceneObjectPart(key);
if (obj != null)
return obj.GetMass();
// the object is null so the key is for an avatar
IScenePresence avatar = World.GetScenePresence(key);
if (avatar != null)
if (avatar.IsChildAgent)
// reference http://www.lslwiki.net/lslwiki/wakka.php?wakka=llGetObjectMass
// child agents have a mass of 1.0
return 1;
else
return avatar.PhysicsActor.Mass;
}
catch (KeyNotFoundException)
{
return 0; // The Object/Agent not in the region so just return zero
}
}
return 0;
}