public LSL_String llGetLinkName(int linknum)
{
if (!ScriptProtection.CheckThreatLevel(ThreatLevel.None, "LSL", m_host, "LSL", m_itemID)) return "";
// simplest case, this prims link number
if (m_host.LinkNum == linknum)
return m_host.Name;
// Single prim
if (m_host.LinkNum == 0)
{
if (linknum == 1)
return m_host.Name;
IEntity entity = m_host.ParentEntity.GetLinkNumPart(linknum);
if (entity != null)
return entity.Name;
return UUID.Zero.ToString();
}
// Link set
IEntity part = null;
part = m_host.LinkNum == 1 ? m_host.ParentEntity.GetLinkNumPart(linknum < 0 ? 2 : linknum) : m_host.ParentEntity.GetLinkNumPart(linknum < 2 ? 1 : linknum);
if (part != null)
return part.Name;
return UUID.Zero.ToString();
}