mirror of
https://github.com/opensim/opensim.git
synced 2026-08-05 00:46:02 +08:00
Implement osNpcGetOwner(key npc):key. This returns the owner for an 'owned' NPC, the npc's own key for an 'unowned' NPC and NULL_KEY is the input key was not an npc.
llGetOwnerKey() could also be extended but this does not allow one to distinguish between an unowned NPC and some other result (e.g. 'no such object' if NULL_KEY is the return. Also, any future extensions to LSL functions by Linden Lab are unpredictable and OpenSim-specific extensions could clash.
This commit is contained in:
@@ -2313,6 +2313,27 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||
}
|
||||
}
|
||||
|
||||
public LSL_Key osNpcGetOwner(LSL_Key npc)
|
||||
{
|
||||
CheckThreatLevel(ThreatLevel.None, "osNpcGetOwner");
|
||||
|
||||
INPCModule npcModule = World.RequestModuleInterface<INPCModule>();
|
||||
if (npcModule != null)
|
||||
{
|
||||
UUID npcId;
|
||||
if (UUID.TryParse(npc.m_string, out npcId))
|
||||
{
|
||||
UUID owner = npcModule.GetOwner(npcId);
|
||||
if (owner != UUID.Zero)
|
||||
return new LSL_Key(owner.ToString());
|
||||
else
|
||||
return npc;
|
||||
}
|
||||
}
|
||||
|
||||
return new LSL_Key(UUID.Zero.ToString());
|
||||
}
|
||||
|
||||
public LSL_Vector osNpcGetPos(LSL_Key npc)
|
||||
{
|
||||
CheckThreatLevel(ThreatLevel.High, "osNpcGetPos");
|
||||
|
||||
Reference in New Issue
Block a user