From e869eeb0bfc48c769f680970f99e4c67dd5a1a70 Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Tue, 9 Aug 2011 03:51:34 +0100
Subject: Implement first draft functions for saving and loading NPC appearance
from storage.
This works by serializing and deserializing NPC AvatarAppearance to a notecard in the prim inventory and making the required baked textures permanent.
By using notecards, we avoid lots of awkward, technical and user-unfriendly issues concerning retaining asset references and creating a new asset type.
Notecards also allow different appearances to be swapped and manipulated easily.
This also allows stored NPC appearances to work transparently with OARs/IARs since the UUID scan will pick up and store the necessary references from the notecard text.
This works in my basic test but is not at all ready for user use or bug reporting yet.
---
.../Shared/Api/Implementation/LSL_Api.cs | 33 ++++++++++++++++++----
1 file changed, 27 insertions(+), 6 deletions(-)
(limited to 'OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs')
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
index 7c21ba9..86ee28a 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
@@ -10565,9 +10565,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
}
}
- public static string GetLine(UUID assetID, int line, int maxLength)
+ ///
+ /// Get a notecard line.
+ ///
+ ///
+ /// Lines start at index 0
+ ///
+ public static string GetLine(UUID assetID, int lineNumber)
{
- if (line < 0)
+ if (lineNumber < 0)
return "";
string data;
@@ -10579,17 +10585,32 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
{
m_Notecards[assetID].lastRef = DateTime.Now;
- if (line >= m_Notecards[assetID].text.Length)
+ if (lineNumber >= m_Notecards[assetID].text.Length)
return "\n\n\n";
- data = m_Notecards[assetID].text[line];
- if (data.Length > maxLength)
- data = data.Substring(0, maxLength);
+ data = m_Notecards[assetID].text[lineNumber];
return data;
}
}
+ ///
+ /// Get a notecard line.
+ ///
+ ///
+ /// Lines start at index 0
+ /// Maximum length of the returned line. Longer lines will be truncated
+ ///
+ public static string GetLine(UUID assetID, int lineNumber, int maxLength)
+ {
+ string line = GetLine(assetID, lineNumber);
+
+ if (line.Length > maxLength)
+ line = line.Substring(0, maxLength);
+
+ return line;
+ }
+
public static void CacheCheck()
{
foreach (UUID key in new List(m_Notecards.Keys))
--
cgit v1.1