OsNpcLoadAppearance

From OpenSimulator

(Difference between revisions)
Jump to: navigation, search
m (Add See Also)
m (Small script improvement)
Line 9: Line 9:
 
//
 
//
 
// osNpcLoadAppearance Script Exemple
 
// osNpcLoadAppearance Script Exemple
// Author: djphil
+
// Authior: djphil
 
//
 
//
  
Line 26: Line 26:
 
         if (osIsNpc(collider))
 
         if (osIsNpc(collider))
 
         {
 
         {
             if (llGetInventoryType(llKey2Name(collider)) == INVENTORY_NOTECARD)
+
             string notecard = llKey2Name(collider);
 +
 
 +
            if (llGetInventoryType(notecard) == INVENTORY_NOTECARD)
 
             {
 
             {
                 osNpcLoadAppearance(collider, llDetectedName(0));
+
                 osNpcLoadAppearance(collider, notecard);
 
                 osNpcSay(collider, "Wow cool, i have a new appearance now!");
 
                 osNpcSay(collider, "Wow cool, i have a new appearance now!");
 
             }
 
             }
Line 34: Line 36:
 
             else
 
             else
 
             {
 
             {
                 osNpcSay(collider, "Hmmm, no appearance for me in this primitive ...");
+
                 osNpcSay(collider, "Hmmm, no appearance \"" + notecard + "\" in this primitive ...");
 
             }
 
             }
 
         }
 
         }

Revision as of 13:48, 4 December 2020

osNpcLoadAppearance(key npc, string notecard)
Load appearance from a notecard. This notecard must contain appearance data created with one of the save appearance functions.
Threat Level High
Permissions ${OSSL|osslNPC}
Extra Delay 0 seconds
Example(s)
//
// osNpcLoadAppearance Script Exemple
// Authior: djphil
//
 
default
{
    state_entry()
    {
        llSay(PUBLIC_CHANNEL, "Collide a NPC with this primitive to see osNpcLoadAppearance usage.");
        llSay(PUBLIC_CHANNEL, "This will load the appearance of the npc only if the appearance notecard has the same name as the npc.");
    }
 
    collision_start(integer number)
    {
        key collider = llDetectedKey(0);
 
        if (osIsNpc(collider))
        {
            string notecard = llKey2Name(collider);
 
            if (llGetInventoryType(notecard) == INVENTORY_NOTECARD)
            {
                osNpcLoadAppearance(collider, notecard);
                osNpcSay(collider, "Wow cool, i have a new appearance now!");
            }
 
            else
            {
                osNpcSay(collider, "Hmmm, no appearance \"" + notecard + "\" in this primitive ...");
            }
        }
 
        else
        {
            llSay(PUBLIC_CHANNEL, "Only NPC's can collide with me and load a new appearance ...");
        }
    }
}
Notes
This function was added in 0.7.2-post-fixes

An important hint: This function works only for the npc owner.
You must create the npc with OsNpcCreate and the option OS_NPC_NOT_OWNED to allow all others to change the appearance.


See Also:

Personal tools
General
About This Wiki