public LSL_Key llGetNotecardLine(string name, int line)
{
if (!ScriptProtection.CheckThreatLevel(ThreatLevel.None, "LSL", m_host, "LSL", m_itemID)) return "";
TaskInventoryDictionary itemsDictionary = (TaskInventoryDictionary)m_host.TaskInventory.Clone();
UUID assetID = UUID.Zero;
if (!UUID.TryParse(name, out assetID))
{
foreach (TaskInventoryItem item in itemsDictionary.Values)
{
if (item.Type == 7 && item.Name == name)
{
assetID = item.AssetID;
break;
}
}
}
if (assetID == UUID.Zero)
{
// => complain loudly, as specified by the LSL docs
ShoutError("Notecard '" + name + "' could not be found.");
return UUID.Zero.ToString();
}
// was: UUID tid = tid = m_ScriptEngine.
UUID rq = UUID.Random();
DataserverPlugin dataserverPlugin = (DataserverPlugin)m_ScriptEngine.GetScriptPlugin("Dataserver");
UUID tid = dataserverPlugin.RegisterRequest(m_host.UUID, m_itemID, rq.ToString());
if (NotecardCache.IsCached(assetID))
{
dataserverPlugin.AddReply(rq.ToString(),
NotecardCache.GetLine(assetID, line, m_notecardLineReadCharsMax), 100);
ScriptSleep(100);
return tid.ToString();
}
WithNotecard(assetID, delegate(UUID id, AssetBase a)
{
if (a == null || a.Type != 7)
{
ShoutError("Notecard '" + name + "' could not be found.");
}
else
{
UTF8Encoding enc =
new UTF8Encoding();
string data = enc.GetString(a.Data);
NotecardCache.Cache(id, data);
dataserverPlugin.AddReply(rq.ToString(),
NotecardCache.GetLine(id, line, m_notecardLineReadCharsMax), 100);
}
});
ScriptSleep(100);
return tid.ToString();
}