OsNpcLoadAppearance
From OpenSimulator
(Difference between revisions)
m (Small script improvement) |
m (Small changes in the script) |
||
Line 9: | Line 9: | ||
// | // | ||
// osNpcLoadAppearance Script Exemple | // osNpcLoadAppearance Script Exemple | ||
− | // | + | // Author: djphil |
// | // | ||
+ | |||
+ | integer total; | ||
default | default | ||
Line 16: | Line 18: | ||
state_entry() | state_entry() | ||
{ | { | ||
− | llSay(PUBLIC_CHANNEL, " | + | total = llGetInventoryNumber(INVENTORY_NOTECARD); |
− | llSay(PUBLIC_CHANNEL, " | + | if (total < 1) |
+ | { | ||
+ | llSay(PUBLIC_CHANNEL, "he 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."); | ||
+ | } | ||
} | } | ||
Line 26: | Line 36: | ||
if (osIsNpc(collider)) | 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!"); | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
} | } | ||
Revision as of 13:02, 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 // Author: djphil // integer total; default { state_entry() { total = llGetInventoryNumber(INVENTORY_NOTECARD); if (total < 1) { llSay(PUBLIC_CHANNEL, "he 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. |
See Also:
- osNpcLoadAppearance
- osNpcSaveAppearance