* Fleshes more of NPCModule out.

* Implements some OSSL commands:
        key osNpcCreate(string user, string name, vector position, key cloneFrom);
        void osNpcMoveTo(key npc, vector position);
        void osNpcSay(key npc, string message);
        void osNpcRemove(key npc);
* Untested. Requires ThreatLevel.High.
This commit is contained in:
Adam Frisby
2009-08-21 11:14:55 +10:00
parent e83b00a3df
commit 01f394d203
4 changed files with 90 additions and 13 deletions

View File

@@ -37,6 +37,7 @@ using OpenSim;
using OpenSim.Framework;
using OpenSim.Framework.Communications.Cache;
using OpenSim.Framework.Console;
using OpenSim.Region.CoreModules.Avatar.NPC;
using OpenSim.Region.Framework.Interfaces;
using OpenSim.Region.Framework.Scenes;
using OpenSim.Region.Framework.Scenes.Hypergrid;
@@ -1762,5 +1763,56 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
return retVal;
}
public LSL_Key osNpcCreate(string firstname, string lastname, LSL_Vector position, LSL_Key cloneFrom)
{
CheckThreatLevel(ThreatLevel.High, "osNpcCreate");
INPCModule module = World.RequestModuleInterface<INPCModule>();
if (module != null)
{
UUID x = module.CreateNPC(firstname,
lastname,
new Vector3((float) position.x, (float) position.y, (float) position.z),
World,
new UUID(cloneFrom));
return new LSL_Key(x.ToString());
}
return new LSL_Key(UUID.Zero.ToString());
}
public void osNpcMoveTo(LSL_Key npc, LSL_Vector position)
{
CheckThreatLevel(ThreatLevel.High, "osNpcMoveTo");
INPCModule module = World.RequestModuleInterface<INPCModule>();
if (module != null)
{
Vector3 pos = new Vector3((float) position.x, (float) position.y, (float) position.z);
module.Autopilot(new UUID(npc.m_string), World, pos);
}
}
public void osNpcSay(LSL_Key npc, string message)
{
CheckThreatLevel(ThreatLevel.High, "osNpcSay");
INPCModule module = World.RequestModuleInterface<INPCModule>();
if (module != null)
{
module.Say(new UUID(npc.m_string), World, message);
}
}
public void osNpcRemove(LSL_Key npc)
{
CheckThreatLevel(ThreatLevel.High, "osNpcRemove");
INPCModule module = World.RequestModuleInterface<INPCModule>();
if (module != null)
{
module.DeleteNPC(new UUID(npc.m_string), World);
}
}
}
}