aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ScriptEngine/Shared/Api
diff options
context:
space:
mode:
authorJustin Clark-Casey (justincc)2011-08-09 22:05:47 +0100
committerJustin Clark-Casey (justincc)2011-08-09 22:05:47 +0100
commit795c8e6c22d4174d942ad56e70a0acbe507e2ec7 (patch)
treeb5eef28c55c1eeeb9d20c52d320de6f1037880bd /OpenSim/Region/ScriptEngine/Shared/Api
parentMerge branch 'master' of ssh://opensimulator.org/var/git/opensim (diff)
downloadopensim-SC-795c8e6c22d4174d942ad56e70a0acbe507e2ec7.zip
opensim-SC-795c8e6c22d4174d942ad56e70a0acbe507e2ec7.tar.gz
opensim-SC-795c8e6c22d4174d942ad56e70a0acbe507e2ec7.tar.bz2
opensim-SC-795c8e6c22d4174d942ad56e70a0acbe507e2ec7.tar.xz
Add osOwnerSaveAppearance() to help with setting up NPC appearances. Not yet ready for user use.
Adds regression test.
Diffstat (limited to 'OpenSim/Region/ScriptEngine/Shared/Api')
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs51
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs2
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs5
3 files changed, 48 insertions, 10 deletions
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
index 07b36de..a05c623 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
@@ -2147,14 +2147,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2147 return new LSL_Key(UUID.Zero.ToString()); 2147 return new LSL_Key(UUID.Zero.ToString());
2148 } 2148 }
2149 2149
2150 /// <summary>
2151 /// Save the current appearance of the NPC permanently to the named notecard.
2152 /// </summary>
2153 /// <param name="avatar"></param>
2154 /// <param name="notecardName">The name of the notecard to which to save the appearance.</param>
2155 /// <returns>The asset ID of the notecard saved.</returns>
2150 public LSL_Key osNpcSaveAppearance(string avatar, string notecardName) 2156 public LSL_Key osNpcSaveAppearance(string avatar, string notecardName)
2151 { 2157 {
2152 CheckThreatLevel(ThreatLevel.High, "osNpcSaveAppearance"); 2158 CheckThreatLevel(ThreatLevel.High, "osNpcSaveAppearance");
2153 2159
2154 INPCModule npcModule = World.RequestModuleInterface<INPCModule>(); 2160 INPCModule npcModule = World.RequestModuleInterface<INPCModule>();
2155 IAvatarFactory appearanceModule = World.RequestModuleInterface<IAvatarFactory>();
2156 2161
2157 if (npcModule != null && appearanceModule != null) 2162 if (npcModule != null)
2158 { 2163 {
2159 UUID avatarId = UUID.Zero; 2164 UUID avatarId = UUID.Zero;
2160 if (!UUID.TryParse(avatar, out avatarId)) 2165 if (!UUID.TryParse(avatar, out avatarId))
@@ -2163,14 +2168,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2163 if (!npcModule.IsNPC(avatarId, m_host.ParentGroup.Scene)) 2168 if (!npcModule.IsNPC(avatarId, m_host.ParentGroup.Scene))
2164 return new LSL_Key(UUID.Zero.ToString()); 2169 return new LSL_Key(UUID.Zero.ToString());
2165 2170
2166 appearanceModule.SaveBakedTextures(avatarId); 2171 return SaveAppearanceToNotecard(avatarId, notecardName);
2167 ScenePresence sp = m_host.ParentGroup.Scene.GetScenePresence(avatarId);
2168 OSDMap appearancePacked = sp.Appearance.Pack();
2169
2170 TaskInventoryItem item
2171 = SaveNotecard(notecardName, "Avatar Appearance", Util.GetFormattedXml(appearancePacked as OSD), true);
2172
2173 return new LSL_Key(item.AssetID.ToString());
2174 } 2172 }
2175 2173
2176 return new LSL_Key(UUID.Zero.ToString()); 2174 return new LSL_Key(UUID.Zero.ToString());
@@ -2236,6 +2234,39 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2236 module.DeleteNPC(new UUID(npc.m_string), World); 2234 module.DeleteNPC(new UUID(npc.m_string), World);
2237 } 2235 }
2238 } 2236 }
2237
2238 /// <summary>
2239 /// Save the current appearance of the script owner permanently to the named notecard.
2240 /// </summary>
2241 /// <param name="notecardName">The name of the notecard to which to save the appearance.</param>
2242 /// <returns>The asset ID of the notecard saved.</returns>
2243 public LSL_Key osOwnerSaveAppearance(string notecardName)
2244 {
2245 CheckThreatLevel(ThreatLevel.High, "osOwnerSaveAppearance");
2246
2247 return SaveAppearanceToNotecard(m_host.OwnerID, notecardName);
2248 }
2249
2250 protected LSL_Key SaveAppearanceToNotecard(UUID avatarId, string notecardName)
2251 {
2252 IAvatarFactory appearanceModule = World.RequestModuleInterface<IAvatarFactory>();
2253
2254 if (appearanceModule != null)
2255 {
2256 appearanceModule.SaveBakedTextures(m_host.OwnerID);
2257 ScenePresence sp = m_host.ParentGroup.Scene.GetScenePresence(m_host.OwnerID);
2258 OSDMap appearancePacked = sp.Appearance.Pack();
2259
2260 TaskInventoryItem item
2261 = SaveNotecard(notecardName, "Avatar Appearance", Util.GetFormattedXml(appearancePacked as OSD), true);
2262
2263 return new LSL_Key(item.AssetID.ToString());
2264 }
2265 else
2266 {
2267 return new LSL_Key(UUID.Zero.ToString());
2268 }
2269 }
2239 2270
2240 /// <summary> 2271 /// <summary>
2241 /// Get current region's map texture UUID 2272 /// Get current region's map texture UUID
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs
index 868af27..92473ae 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs
@@ -176,6 +176,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces
176 void osNpcSay(key npc, string message); 176 void osNpcSay(key npc, string message);
177 void osNpcRemove(key npc); 177 void osNpcRemove(key npc);
178 178
179 LSL_Key osOwnerSaveAppearance(string notecardName);
180
179 key osGetMapTexture(); 181 key osGetMapTexture();
180 key osGetRegionMapTexture(string regionName); 182 key osGetRegionMapTexture(string regionName);
181 LSL_List osGetRegionStats(); 183 LSL_List osGetRegionStats();
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs
index 959b5d5..4b21c88 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs
@@ -508,6 +508,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
508 m_OSSL_Functions.osNpcRemove(npc); 508 m_OSSL_Functions.osNpcRemove(npc);
509 } 509 }
510 510
511 public LSL_Key osOwnerSaveAppearance(string notecardName)
512 {
513 return m_OSSL_Functions.osOwnerSaveAppearance(notecardName);
514 }
515
511 public OSSLPrim Prim; 516 public OSSLPrim Prim;
512 517
513 [Serializable] 518 [Serializable]