Thank you very much, Kinoc for:

* Impelements llInstantMessage
* Reimplements llOwnerSay as llInstantMessage(llGetOWner(),msg).
* Try's to better identify the "True Name" of objects in llDetectedName
 by checking for avatar name, scene Object Part name and entity name.
* Uses similar logic in the llSensor and llSensorRepeat functions.
0.6.0-stable
Charles Krinke 2008-03-01 00:59:23 +00:00
parent c009e2e095
commit 56697133d4
2 changed files with 102 additions and 22 deletions

View File

@ -40,6 +40,7 @@ using OpenSim.Region.Environment.Interfaces;
using OpenSim.Region.Environment.Scenes; using OpenSim.Region.Environment.Scenes;
using OpenSim.Region.ScriptEngine.Common; using OpenSim.Region.ScriptEngine.Common;
using OpenSim.Region.ScriptEngine.Common.ScriptEngineBase; using OpenSim.Region.ScriptEngine.Common.ScriptEngineBase;
using OpenSim.Region.Environment;
//using OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL; //using OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL;
namespace OpenSim.Region.ScriptEngine.Common namespace OpenSim.Region.ScriptEngine.Common
@ -402,23 +403,43 @@ namespace OpenSim.Region.ScriptEngine.Common
// NotImplemented("llSensorRemove"); // NotImplemented("llSensorRemove");
} }
public string resolveName(LLUUID objecUUID)
{
// try avatar username surname
UserProfileData profile = World.CommsManager.UserService.GetUserProfile(objecUUID);
if (profile != null)
{
string avatarname = profile.username + " " + profile.surname;
return avatarname;
}
// try an scene object
SceneObjectPart SOP = World.GetSceneObjectPart(objecUUID);
if (SOP != null)
{
string objectname = SOP.Name;
return objectname;
}
EntityBase SensedObject = null;
lock (World.Entities)
{
World.Entities.TryGetValue(objecUUID, out SensedObject);
}
if (SensedObject == null)
return String.Empty;
return SensedObject.Name;
}
public string llDetectedName(int number) public string llDetectedName(int number)
{ {
m_host.AddScriptLPS(1); m_host.AddScriptLPS(1);
LSL_Types.list SenseList = m_ScriptEngine.m_ASYNCLSLCommandManager.m_SensorRepeat.GetSensorList(m_localID, m_itemID); LSL_Types.list SenseList = m_ScriptEngine.m_ASYNCLSLCommandManager.m_SensorRepeat.GetSensorList(m_localID, m_itemID);
if ((number>0)&&(number <= SenseList.Length)) if ((number>=0)&&(number <= SenseList.Length))
{ {
LLUUID SensedUUID = (LLUUID)SenseList.Data[number]; LLUUID SensedUUID = (LLUUID)SenseList.Data[number];
//ScenePresence SensedObject = World.GetScenePresence(SensedUUID); return resolveName(SensedUUID);
EntityBase SensedObject=null;
lock (World.Entities)
{
World.Entities.TryGetValue(SensedUUID, out SensedObject);
}
if (SensedObject == null)
return String.Empty;
return SensedObject.Name;
} }
else else
return String.Empty; return String.Empty;
@ -464,6 +485,7 @@ namespace OpenSim.Region.ScriptEngine.Common
public string llDetectedOwner(int number) public string llDetectedOwner(int number)
{ {
// returns UUID of owner of object detected
m_host.AddScriptLPS(1); m_host.AddScriptLPS(1);
EntityBase SensedObject = entityDetectedKey(number); EntityBase SensedObject = entityDetectedKey(number);
if (SensedObject ==null) if (SensedObject ==null)
@ -1413,16 +1435,47 @@ namespace OpenSim.Region.ScriptEngine.Common
public void llInstantMessage(string user, string message) public void llInstantMessage(string user, string message)
{ {
m_host.AddScriptLPS(1); m_host.AddScriptLPS(1);
NotImplemented("llInstantMessage");
// We may be able to use ClientView.SendInstantMessage here, but we need a client instance. // We may be able to use ClientView.SendInstantMessage here, but we need a client instance.
// InstantMessageModule.OnInstantMessage searches through a list of scenes for a client matching the toAgent, // InstantMessageModule.OnInstantMessage searches through a list of scenes for a client matching the toAgent,
// but I don't think we have a list of scenes available from here. // but I don't think we have a list of scenes available from here.
// (We also don't want to duplicate the code in OnInstantMessage if we can avoid it.) // (We also don't want to duplicate the code in OnInstantMessage if we can avoid it.)
// user is a UUID
// TODO: figure out values for client, fromSession, and imSessionID // TODO: figure out values for client, fromSession, and imSessionID
// client.SendInstantMessage(m_host.UUID, fromSession, message, user, imSessionID, m_host.Name, AgentManager.InstantMessageDialog.MessageFromAgent, (uint)Util.UnixTimeSinceEpoch()); // client.SendInstantMessage(m_host.UUID, fromSession, message, user, imSessionID, m_host.Name, AgentManager.InstantMessageDialog.MessageFromAgent, (uint)Util.UnixTimeSinceEpoch());
} LLUUID friendTransactionID = LLUUID.Random();
//m_pendingFriendRequests.Add(friendTransactionID, fromAgentID);
GridInstantMessage msg = new GridInstantMessage();
msg.fromAgentID = new System.Guid(m_host.UUID.ToString()); // fromAgentID.UUID;
msg.fromAgentSession = new System.Guid(friendTransactionID.ToString());// fromAgentSession.UUID;
msg.toAgentID = new System.Guid(user); // toAgentID.UUID;
msg.imSessionID = new System.Guid(friendTransactionID.ToString()); // This is the item we're mucking with here
Console.WriteLine("[Scripting IM]: From:" + msg.fromAgentID.ToString() + " To: " + msg.toAgentID.ToString() + " Session:" + msg.imSessionID.ToString() + " Message:" + message);
Console.WriteLine("[Scripting IM]: Filling Session: " + msg.imSessionID.ToString());
msg.timestamp = (uint)Util.UnixTimeSinceEpoch();// timestamp;
//if (client != null)
//{
msg.fromAgentName = m_host.Name;//client.FirstName + " " + client.LastName;// fromAgentName;
//}
//else
//{
// msg.fromAgentName = "(hippos)";// Added for posterity. This means that we can't figure out who sent it
//}
msg.message = message;
msg.dialog = (byte)19; // messgage from script ??? // dialog;
msg.fromGroup = false;// fromGroup;
msg.offline = (byte)0; //offline;
msg.ParentEstateID = 0; //ParentEstateID;
msg.Position = new sLLVector3();// new sLLVector3(m_host.AbsolutePosition);
msg.RegionID = World.RegionInfo.RegionID.UUID;//RegionID.UUID;
msg.binaryBucket = new byte[0];// binaryBucket;
World.TriggerGridInstantMessage(msg, InstantMessageReceiver.IMModule);
// NotImplemented("llInstantMessage");
}
public void llEmail(string address, string subject, string message) public void llEmail(string address, string subject, string message)
{ {
@ -3733,13 +3786,15 @@ namespace OpenSim.Region.ScriptEngine.Common
public void llOwnerSay(string msg) public void llOwnerSay(string msg)
{ {
m_host.AddScriptLPS(1); //m_host.AddScriptLPS(1); // since we reuse llInstantMessage
//temp fix so that lsl wiki examples aren't annoying to use to test other functions //temp fix so that lsl wiki examples aren't annoying to use to test other functions
//should be similar to : llInstantMessage(llGetOwner(),msg) //should be similar to : llInstantMessage(llGetOwner(),msg)
// llGetOwner ==> m_host.ObjectOwner.ToString() // llGetOwner ==> m_host.ObjectOwner.ToString()
World.SimChat(Helpers.StringToField(msg), ChatTypeEnum.Say, 0, m_host.AbsolutePosition, m_host.Name, m_host.UUID); llInstantMessage(m_host.ObjectOwner.ToString(),msg);
IWorldComm wComm = m_ScriptEngine.World.RequestModuleInterface<IWorldComm>();
wComm.DeliverMessage(m_host.UUID.ToString(), ChatTypeEnum.Say, 0, m_host.Name, msg); //World.SimChat(Helpers.StringToField(msg), ChatTypeEnum.Say, 0, m_host.AbsolutePosition, m_host.Name, m_host.UUID);
//IWorldComm wComm = m_ScriptEngine.World.RequestModuleInterface<IWorldComm>();
//wComm.DeliverMessage(m_host.UUID.ToString(), ChatTypeEnum.Say, 0, m_host.Name, msg);
} }
public void llRequestSimulatorData(string simulator, int data) public void llRequestSimulatorData(string simulator, int data)

View File

@ -236,7 +236,7 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase.AsyncCommandPlugin
// Right type too, what about the other params , key and name ? // Right type too, what about the other params , key and name ?
bool keep = true; bool keep = true;
if (ts.arc != Math.PI) if (ts.arc < Math.PI)
{ {
// not omni-directional. Can you see it ? // not omni-directional. Can you see it ?
// vec forward_dir = llRot2Fwd(llGetRot()) // vec forward_dir = llRot2Fwd(llGetRot())
@ -261,15 +261,40 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase.AsyncCommandPlugin
if (ang_obj > ts.arc) keep = false; if (ang_obj > ts.arc) keep = false;
} }
if (keep && (ts.name.Length > 0) && (ts.name != ent.Name))
{
keep = false;
}
if (keep && (ts.keyID != null) && (ts.keyID != LLUUID.Zero) && (ts.keyID != ent.UUID)) if (keep && (ts.keyID != null) && (ts.keyID != LLUUID.Zero) && (ts.keyID != ent.UUID))
{ {
keep = false; keep = false;
} }
if (keep&& (ts.name.Length > 0))
{
string avatarname=null;
string objectname=null;
string entname =ent.Name;
// try avatar username surname
UserProfileData profile = m_CmdManager.m_ScriptEngine.World.CommsManager.UserService.GetUserProfile(ent.UUID);
if (profile != null)
{
avatarname = profile.username + " " + profile.surname;
}
// try an scene object
SceneObjectPart SOP = m_CmdManager.m_ScriptEngine.World.GetSceneObjectPart(ent.UUID);
if (SOP != null)
{
objectname = SOP.Name;
}
if ((ts.name != entname) && (ts.name != avatarname) && (ts.name != objectname))
{
keep = false;
}
}
if (keep == true) SensedObjects.Add(ent.UUID); if (keep == true) SensedObjects.Add(ent.UUID);
} }
} }