public LSL_String llGetNotecardLine(string name, int line)
{
m_host.AddScriptLPS(1);
UUID assetID = UUID.Zero;
if (!UUID.TryParse(name, out assetID))
{
TaskInventoryItem item = m_host.Inventory.GetInventoryItem(name);
if (item != null && item.Type == 7)
assetID = item.AssetID;
}
if (assetID == UUID.Zero)
{
// => complain loudly, as specified by the LSL docs
Error("llGetNotecardLine", "Can't find notecard '" + name + "'");
return UUID.Zero.ToString();
}
string reqIdentifier = UUID.Random().ToString();
// was: UUID tid = tid = AsyncCommands.
UUID tid = AsyncCommands.DataserverPlugin.RegisterRequest(m_host.LocalId, m_item.ItemID, reqIdentifier);
if (NotecardCache.IsCached(assetID))
{
AsyncCommands.DataserverPlugin.DataserverReply(
reqIdentifier, NotecardCache.GetLine(assetID, line, m_notecardLineReadCharsMax));
ScriptSleep(m_sleepMsOnGetNotecardLine);
return tid.ToString();
}
WithNotecard(assetID, delegate (UUID id, AssetBase a)
{
if (a == null || a.Type != 7)
{
Error("llGetNotecardLine", "Can't find notecard '" + name + "'");
return;
}
string data = Encoding.UTF8.GetString(a.Data);
//m_log.Debug(data);
NotecardCache.Cache(id, a.Data);
AsyncCommands.DataserverPlugin.DataserverReply(
reqIdentifier, NotecardCache.GetLine(assetID, line, m_notecardLineReadCharsMax));
});
ScriptSleep(m_sleepMsOnGetNotecardLine);
return tid.ToString();
}