Description | Hello :)
I have created new OSSL function : osNpcSetTitle(key npc, string title);
That allows for setting any string title to existing NPC in a dynamical way.
OSSL Example:
key npc = NULL_KEY;
default
{
touch_start(integer num)
{
if(npc == NULL_KEY)
{
osOwnerSaveAppearance("MyClone");
llSetTimerEvent(2);
}
else
{
osNpcRemove(npc);
npc = NULL_KEY;
llRemoveInventory("MyClone");
}
}
timer()
{
llSetTimerEvent(0);
npc = osNpcCreate("John","Smith",llGetPos()+<0,0,2>,"MyClone");
state title;
}
state_exit()
{
llSetTimerEvent(8);
}
}
state title
{
timer()
{
llSetTimerEvent(0);
osNpcSetTitle(npc,"I'm the Bot");
state default;
}
} |
Attached Files | 0001-New-OSSL-function-osNpcSetTitle-key-npc-string-title.patch [^] (6,176 bytes) 2016-07-24 08:24 [Show Content] [Hide Content]From 6c6277b9029a3e064e2eaffec573f9706ba1cd2d Mon Sep 17 00:00:00 2001
From: Mandarinka Tasty <mandarinka.tasty@gmail.com>
Date: Sun, 24 Jul 2016 17:02:01 +0200
Subject: [PATCH] New OSSL function: osNpcSetTitle(key npc, string title);
Signed-off-by: Mandarinka Tasty <mandarinka.tasty@gmail.com>
---
OpenSim/Region/Framework/Interfaces/INPCModule.cs | 12 +++++++++++
.../Region/OptionalModules/World/NPC/NPCModule.cs | 16 +++++++++++++++
.../Shared/Api/Implementation/OSSL_Api.cs | 23 ++++++++++++++++++++++
.../ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs | 1 +
.../ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs | 5 +++++
bin/config-include/osslEnable.ini | 1 +
6 files changed, 58 insertions(+)
diff --git a/OpenSim/Region/Framework/Interfaces/INPCModule.cs b/OpenSim/Region/Framework/Interfaces/INPCModule.cs
index 58ea309..7ed2dc2 100644
--- a/OpenSim/Region/Framework/Interfaces/INPCModule.cs
+++ b/OpenSim/Region/Framework/Interfaces/INPCModule.cs
@@ -298,6 +298,18 @@ namespace OpenSim.Region.Framework.Interfaces
/// agent, the agent is unowned or the agent was not an NPC.
/// </returns>
UUID GetOwner(UUID agentID);
+
+ /// <summary>
+ /// Set the title of a NPC
+ /// </summary>
+ /// <param name="agentID">The UUID of the NPC</param>
+ /// <param name="scene"></param>
+ /// <param name="title"></param>
+ /// <returns>
+ /// True if the operation succeeded, false if there was no such agent
+ /// or the agent was not an NPC.
+ /// </returns>
+ bool SetNPCTitle(UUID agentID, Scene scene, string title);
NPCOptionsFlags NPCOptionFlags {get;}
}
diff --git a/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs b/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs
index 8462661..7f9d731 100644
--- a/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs
+++ b/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs
@@ -481,5 +481,21 @@ namespace OpenSim.Region.OptionalModules.World.NPC
return callerID == UUID.Zero || av.OwnerID == UUID.Zero ||
av.OwnerID == callerID || av.AgentId == callerID;
}
+
+ public bool SetNPCTitle(UUID agentID, Scene scene, string title)
+ {
+ lock (m_avatars)
+ {
+ ScenePresence sp;
+ if (scene.TryGetScenePresence(agentID, out sp))
+ {
+ sp.Grouptitle = title;
+
+ return true;
+ }
+ }
+
+ return false;
+ }
}
}
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
index c3cc1e0..cbc4110 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
@@ -3192,6 +3192,29 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
}
}
+ public void osNpcSetTitle(LSL_Key npc, string title)
+ {
+ CheckThreatLevel(ThreatLevel.High, "osNpcSetTitle");
+ m_host.AddScriptLPS(1);
+
+ INPCModule module = World.RequestModuleInterface<INPCModule>();
+ if (module != null)
+ {
+ UUID npcId = new UUID(npc.m_string);
+
+ if (!module.CheckPermissions(npcId, m_host.OwnerID))
+ return;
+
+ module.SetNPCTitle(npcId, World, title);
+
+ ScenePresence sp;
+ if (World.TryGetScenePresence(npcId, out sp))
+ {
+ sp.SendAvatarDataToAllAgents();
+ }
+ }
+ }
+
/// <summary>
/// Save the current appearance of the script owner permanently to the named notecard.
/// </summary>
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs
index cc6e620..b5ed028 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs
@@ -355,6 +355,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces
void osNpcStopAnimation(LSL_Key npc, string animation);
void osNpcTouch(LSL_Key npcLSL_Key, LSL_Key object_key, LSL_Integer link_num);
void osNpcWhisper(key npc, int channel, string message);
+ void osNpcSetTitle(key npc, string title);
LSL_Key osOwnerSaveAppearance(string notecard);
LSL_Key osAgentSaveAppearance(key agentId, string notecard);
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs
index 78d28c6..a57b921 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs
@@ -698,6 +698,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
m_OSSL_Functions.osNpcTouch(npcLSL_Key, object_key, link_num);
}
+ public void osNpcSetTitle(key npc, string title)
+ {
+ m_OSSL_Functions.osNpcSetTitle(npc, title);
+ }
+
public LSL_Key osOwnerSaveAppearance(string notecard)
{
return m_OSSL_Functions.osOwnerSaveAppearance(notecard);
diff --git a/bin/config-include/osslEnable.ini b/bin/config-include/osslEnable.ini
index 0a03d4c..d8c2e83 100644
--- a/bin/config-include/osslEnable.ini
+++ b/bin/config-include/osslEnable.ini
@@ -189,6 +189,7 @@
Allow_osNpcStopMoveToTarget = ${XEngine|osslNPC}
Allow_osNpcTouch = ${XEngine|osslNPC}
Allow_osNpcWhisper = ${XEngine|osslNPC}
+ Allow_osNpcSetTitle = ${XEngine|osslNPC}
Allow_osOwnerSaveAppearance = ${XEngine|osslParcelO}ESTATE_MANAGER,ESTATE_OWNER
Allow_osParcelJoin = ESTATE_MANAGER,ESTATE_OWNER
Allow_osParcelSubdivide = ESTATE_MANAGER,ESTATE_OWNER
--
2.8.3.windows.1
|