OsNpcLoadAppearance

From OpenSimulator

(Difference between revisions)
Jump to: navigation, search
m (Added note stating which version of OpenSim introduced this function)
m (Change See Also)
 
(11 intermediate revisions by 2 users not shown)
Line 4: Line 4:
 
|description=Load appearance from a notecard. This notecard must contain appearance data created with one of the save appearance functions.
 
|description=Load appearance from a notecard. This notecard must contain appearance data created with one of the save appearance functions.
 
|threat_level=High
 
|threat_level=High
|permissions=${XEngine|osslNPC}
+
|permissions=${OSSL|osslNPC}
 
|delay=0
 
|delay=0
 
|ossl_example=<source lang="lsl">
 
|ossl_example=<source lang="lsl">
//Load an appearance notecard on the collided npc with the same name like the npc.
+
//
 +
// osNpcLoadAppearance Script Exemple
 +
// Author: djphil
 +
//
 +
 
 +
integer total;
  
 
default
 
default
 
{
 
{
     collision_start(integer num) //On Collision
+
     state_entry()
 
     {
 
     {
         if(osIsNpc(llDetectedKey(0))) //Check is the the agent an npc
+
        total = llGetInventoryNumber(INVENTORY_NOTECARD);
 +
 
 +
         if (total < 1)
 
         {
 
         {
             if(llGetInventoryType(llDetectedName(0)) == INVENTORY_NOTECARD) //is the notecard available
+
             llSay(PUBLIC_CHANNEL, "The inventory of this primitive must contain at least one appearance notecard for npc.");
            {
+
        }
                osNpcLoadAppearance(llDetectedKey(0), llDetectedName(0)); //load the new appearance
+
       
            }
+
        else
 +
        {
 +
            llSay(PUBLIC_CHANNEL, "Collide a NPC with this primitive to see osNpcLoadAppearance usage.");
 +
        }
 +
    }
 +
 
 +
    collision_start(integer number)
 +
    {
 +
        key collider = llDetectedKey(0);
 +
 
 +
        if (osIsNpc(collider))
 +
        {
 +
            integer random = llFloor(llFrand((float)total));
 +
            string notecard = llGetInventoryName(INVENTORY_ALL, random);
 +
            osNpcLoadAppearance(collider, notecard);
 +
            osNpcSay(collider, "Wow cool, i have a new appearance now!");
 +
        }
 +
 
 +
        else
 +
        {
 +
            llSay(PUBLIC_CHANNEL, "Only NPC's can collide with me and load a new appearance ...");
 
         }
 
         }
 
     }
 
     }
Line 24: Line 51:
 
</source>
 
</source>
 
|additional_info=This function was added in 0.7.2-post-fixes
 
|additional_info=This function was added in 0.7.2-post-fixes
'''An important hint:'''
+
'''An important hint:''' This function works only for the npc owner.<br>
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.
 
You must create the npc with [[OsNpcCreate]] and the option OS_NPC_NOT_OWNED to allow all others to change the appearance.
 
}}
 
}}
 +
== See Also ==
 +
* [[osNpcLoadAppearance]]
 +
* [[osNpcSaveAppearance]]
 +
* [[osAgentSaveAppearance]]

Latest revision as of 18:51, 5 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
// Author: djphil
//
 
integer total;
 
default
{
    state_entry()
    {
        total = llGetInventoryNumber(INVENTORY_NOTECARD);
 
        if (total < 1)
        {
            llSay(PUBLIC_CHANNEL, "The inventory of this primitive must contain at least one appearance notecard for npc.");
        }
 
        else
        {
            llSay(PUBLIC_CHANNEL, "Collide a NPC with this primitive to see osNpcLoadAppearance usage.");
        }
    }
 
    collision_start(integer number)
    {
        key collider = llDetectedKey(0);
 
        if (osIsNpc(collider))
        {
            integer random = llFloor(llFrand((float)total));
            string notecard = llGetInventoryName(INVENTORY_ALL, random);
            osNpcLoadAppearance(collider, notecard);
            osNpcSay(collider, "Wow cool, i have a new appearance now!");
        }
 
        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.


[edit] See Also

Personal tools
General
About This Wiki