OpenSim.Region.ScriptEngine.Shared.Api.OSSL_Api.osNpcCreate C# (CSharp) Method

osNpcCreate() public method

public osNpcCreate ( string firstname, string lastname, OpenSim.Region.ScriptEngine.Shared.LSL_Types.Vector3 position, string notecard ) : OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLString
firstname string
lastname string
position OpenSim.Region.ScriptEngine.Shared.LSL_Types.Vector3
notecard string
return OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLString
        public LSL_Key osNpcCreate(string firstname, string lastname, LSL_Vector position, string notecard)
        {
            CheckThreatLevel(ThreatLevel.High, "osNpcCreate");
            m_host.AddScriptLPS(1);
            
            // have to get the npc module also here to set the default Not Owned
            INPCModule module = World.RequestModuleInterface<INPCModule>();
            if(module == null)
                return new LSL_Key(UUID.Zero.ToString());
            
            bool owned = (module.NPCOptionFlags & NPCOptionsFlags.AllowNotOwned) == 0;

            return NpcCreate(firstname, lastname, position, notecard, owned, false, false);
        }

Same methods

OSSL_Api::osNpcCreate ( string firstname, string lastname, OpenSim.Region.ScriptEngine.Shared.LSL_Types.Vector3 position, string notecard, int options ) : OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLString

Usage Example

        public void TestOsNpcCreateUsingAppearanceFromNotecard()
        {
            TestHelpers.InMethod();

            // Store an avatar with a different height from default in a notecard.
            UUID userId = TestHelpers.ParseTail(0x1);
            float newHeight = 1.9f;

            ScenePresence sp = SceneHelpers.AddScenePresence(m_scene, userId);
            sp.Appearance.AvatarHeight = newHeight;
            SceneObjectGroup so = SceneHelpers.CreateSceneObject(1, userId, 0x10);
            SceneObjectPart part = so.RootPart;
            m_scene.AddSceneObject(so);

            OSSL_Api osslApi = new OSSL_Api();
            osslApi.Initialize(m_engine, part, null, null);

            string notecardName = "appearanceNc";
            osslApi.osOwnerSaveAppearance(notecardName);

            // Try creating a bot using the appearance in the notecard.
            string npcRaw = osslApi.osNpcCreate("Jane", "Doe", new LSL_Types.Vector3(128, 128, 128), notecardName);
            Assert.That(npcRaw, Is.Not.Null);

            UUID npcId = new UUID(npcRaw);
            ScenePresence npc = m_scene.GetScenePresence(npcId);
            Assert.That(npc, Is.Not.Null);
            Assert.That(npc.Appearance.AvatarHeight, Is.EqualTo(newHeight));
        }
All Usage Examples Of OpenSim.Region.ScriptEngine.Shared.Api.OSSL_Api::osNpcCreate
OSSL_Api