mirror of
https://github.com/opensim/opensim.git
synced 2026-08-06 01:06:30 +08:00
Merge branch 'master' into careminster
Conflicts: OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs OpenSim/Region/Framework/Scenes/Scene.cs
This commit is contained in:
@@ -116,6 +116,115 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||
wComm.DeliverMessage(ChatTypeEnum.Shout, ScriptBaseClass.DEBUG_CHANNEL, m_host.Name, m_host.UUID, message);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="fname">The name of the function to invoke</param>
|
||||
/// <param name="fname">List of parameters</param>
|
||||
/// <returns>string result of the invocation</returns>
|
||||
public string modInvokeS(string fname, params object[] parms)
|
||||
{
|
||||
Type returntype = m_comms.LookupReturnType(fname);
|
||||
if (returntype != typeof(string))
|
||||
MODError(String.Format("return type mismatch for {0}",fname));
|
||||
|
||||
return (string)modInvoke(fname,parms);
|
||||
}
|
||||
|
||||
public int modInvokeI(string fname, params object[] parms)
|
||||
{
|
||||
Type returntype = m_comms.LookupReturnType(fname);
|
||||
if (returntype != typeof(int))
|
||||
MODError(String.Format("return type mismatch for {0}",fname));
|
||||
|
||||
return (int)modInvoke(fname,parms);
|
||||
}
|
||||
|
||||
public float modInvokeF(string fname, params object[] parms)
|
||||
{
|
||||
Type returntype = m_comms.LookupReturnType(fname);
|
||||
if (returntype != typeof(float))
|
||||
MODError(String.Format("return type mismatch for {0}",fname));
|
||||
|
||||
return (float)modInvoke(fname,parms);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Invokes a preregistered function through the ScriptModuleComms class
|
||||
/// </summary>
|
||||
/// <param name="fname">The name of the function to invoke</param>
|
||||
/// <param name="fname">List of parameters</param>
|
||||
/// <returns>string result of the invocation</returns>
|
||||
protected object modInvoke(string fname, params object[] parms)
|
||||
{
|
||||
if (!m_MODFunctionsEnabled)
|
||||
{
|
||||
MODShoutError("Module command functions not enabled");
|
||||
return "";
|
||||
}
|
||||
|
||||
Type[] signature = m_comms.LookupTypeSignature(fname);
|
||||
if (signature.Length != parms.Length)
|
||||
MODError(String.Format("wrong number of parameters to function {0}",fname));
|
||||
|
||||
object[] convertedParms = new object[parms.Length];
|
||||
|
||||
for (int i = 0; i < parms.Length; i++)
|
||||
{
|
||||
if (parms[i] is LSL_String)
|
||||
{
|
||||
if (signature[i] != typeof(string))
|
||||
MODError(String.Format("parameter type mismatch in {0}; expecting {1}",fname,signature[i].Name));
|
||||
|
||||
convertedParms[i] = (string)(LSL_String)parms[i];
|
||||
}
|
||||
else if (parms[i] is LSL_Integer)
|
||||
{
|
||||
if (signature[i] != typeof(int))
|
||||
MODError(String.Format("parameter type mismatch in {0}; expecting {1}",fname,signature[i].Name));
|
||||
|
||||
convertedParms[i] = (int)(LSL_Integer)parms[i];
|
||||
}
|
||||
else if (parms[i] is LSL_Float)
|
||||
{
|
||||
if (signature[i] != typeof(float))
|
||||
MODError(String.Format("parameter type mismatch in {0}; expecting {1}",fname,signature[i].Name));
|
||||
|
||||
convertedParms[i] = (float)(LSL_Float)parms[i];
|
||||
}
|
||||
else if (parms[i] is LSL_Key)
|
||||
{
|
||||
if (signature[i] != typeof(string))
|
||||
MODError(String.Format("parameter type mismatch in {0}; expecting {1}",fname,signature[i].Name));
|
||||
|
||||
convertedParms[i] = (string)(LSL_Key)parms[i];
|
||||
}
|
||||
else if (parms[i] is LSL_Rotation)
|
||||
{
|
||||
if (signature[i] != typeof(string))
|
||||
MODError(String.Format("parameter type mismatch in {0}; expecting {1}",fname,signature[i].Name));
|
||||
|
||||
convertedParms[i] = (string)(LSL_Rotation)parms[i];
|
||||
}
|
||||
else if (parms[i] is LSL_Vector)
|
||||
{
|
||||
if (signature[i] != typeof(string))
|
||||
MODError(String.Format("parameter type mismatch in {0}; expecting {1}",fname,signature[i].Name));
|
||||
|
||||
convertedParms[i] = (string)(LSL_Vector)parms[i];
|
||||
}
|
||||
else
|
||||
{
|
||||
if (signature[i] != parms[i].GetType())
|
||||
MODError(String.Format("parameter type mismatch in {0}; expecting {1}",fname,signature[i].Name));
|
||||
|
||||
convertedParms[i] = parms[i];
|
||||
}
|
||||
}
|
||||
|
||||
return m_comms.InvokeOperation(m_itemID,fname,convertedParms);
|
||||
}
|
||||
|
||||
public string modSendCommand(string module, string command, string k)
|
||||
{
|
||||
if (!m_MODFunctionsEnabled)
|
||||
|
||||
@@ -3003,5 +3003,28 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||
|
||||
return date.ToString("yyyy-MM-ddTHH:mm:ss.fffffffZ");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the description from an inventory item
|
||||
/// </summary>
|
||||
/// <param name="inventoryName"></param>
|
||||
/// <returns>Item description</returns>
|
||||
public LSL_String osGetInventoryDesc(string item)
|
||||
{
|
||||
m_host.AddScriptLPS(1);
|
||||
|
||||
lock (m_host.TaskInventory)
|
||||
{
|
||||
foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory)
|
||||
{
|
||||
if (inv.Value.Name == item)
|
||||
{
|
||||
return inv.Value.Description.ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return String.Empty;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,6 +40,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces
|
||||
{
|
||||
public interface IMOD_Api
|
||||
{
|
||||
// Invocation functions
|
||||
string modInvokeS(string fname, params object[] parms);
|
||||
int modInvokeI(string fname, params object[] parms);
|
||||
float modInvokeF(string fname, params object[] parms);
|
||||
// vector modInvokeV(string fname, params object[] parms);
|
||||
// rotation modInvokeV(string fname, params object[] parms);
|
||||
// key modInvokeK(string fname, params object[] parms);
|
||||
// list modInvokeL(string fname, params object[] parms);
|
||||
|
||||
//Module functions
|
||||
string modSendCommand(string modules, string command, string k);
|
||||
}
|
||||
|
||||
@@ -229,5 +229,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces
|
||||
LSL_List osGetAvatarList();
|
||||
|
||||
LSL_String osUnixTimeToTimestamp(long time);
|
||||
|
||||
LSL_String osGetInventoryDesc(string item);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -58,6 +58,21 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
|
||||
m_MOD_Functions = (IMOD_Api)api;
|
||||
}
|
||||
|
||||
public string modInvokeS(string fname, params object[] parms)
|
||||
{
|
||||
return m_MOD_Functions.modInvokeS(fname, parms);
|
||||
}
|
||||
|
||||
public int modInvokeI(string fname, params object[] parms)
|
||||
{
|
||||
return m_MOD_Functions.modInvokeI(fname, parms);
|
||||
}
|
||||
|
||||
public float modInvokeF(string fname, params object[] parms)
|
||||
{
|
||||
return m_MOD_Functions.modInvokeF(fname, parms);
|
||||
}
|
||||
|
||||
public string modSendCommand(string module, string command, string k)
|
||||
{
|
||||
return m_MOD_Functions.modSendCommand(module, command, k);
|
||||
|
||||
@@ -863,5 +863,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
|
||||
{
|
||||
return m_OSSL_Functions.osUnixTimeToTimestamp(time);
|
||||
}
|
||||
|
||||
public LSL_String osGetInventoryDesc(string item)
|
||||
{
|
||||
return m_OSSL_Functions.osGetInventoryDesc(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user