a few changes to llGetNotecardLineSync

This commit is contained in:
UbitUmarov
2024-07-04 00:04:15 +01:00
parent 3a5892421f
commit 73a9462ef8

View File

@@ -14987,23 +14987,25 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
public LSL_String llGetNotecardLineSync(string name, int line)
{
if (line < 0)
return ScriptBaseClass.NAK;
if (!UUID.TryParse(name, out UUID assetID))
{
TaskInventoryItem item = m_host.Inventory.GetInventoryItem(name);
TaskInventoryItem item = m_host.Inventory.GetInventoryItem(name, 7);
if (item != null && item.Type == 7)
assetID = item.AssetID;
else
if (item is null)
{
Error("llGetNotecardLineSync", "Can't find notecard '" + name + "'");
return ScriptBaseClass.NAK;
}
assetID = item.AssetID;
}
if (NotecardCache.IsCached(assetID))
{
return NotecardCache.GetLine(assetID, line, m_notecardLineReadCharsMax);
return NotecardCache.GetllLine(assetID, line, 1024);
}
else
{
@@ -18862,6 +18864,18 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
return "";
}
public static string GetllLine(UUID assetID, int lineNumber, int maxLength)
{
if (m_Notecards.TryGetValue(assetID, 30000, out string[] text))
{
if (lineNumber >= text.Length)
return "\n\n\n";
return text[lineNumber].Length < maxLength ? text[lineNumber] : text[lineNumber][..maxLength];
}
return ScriptBaseClass.NAK;
}
/// <summary>
/// Get a notecard line.
/// </summary>