OsNpcCreate
From OpenSimulator
(Difference between revisions)
(Changed example to save avatyar appearabnce in notecard first) |
|||
Line 1: | Line 1: | ||
{{osslfunc | {{osslfunc | ||
|threat_level=High | |threat_level=High | ||
− | |function_syntax=key osNpcCreate(string firstname, string lastname, vector position, | + | |function_syntax=key osNpcCreate(string firstname, string lastname, vector position, string notecard) |
|ossl_example=<source lang="lsl"> | |ossl_example=<source lang="lsl"> | ||
− | // touch to create | + | // touch to create a NPC clone of the toucher in front of this emitter |
− | // | + | // NPC will move to the toucher, then will greet them. |
// Touch again to remove the NPC | // Touch again to remove the NPC | ||
Line 15: | Line 15: | ||
{ | { | ||
vector npcPos = llGetPos() + <1,0,0>; | vector npcPos = llGetPos() + <1,0,0>; | ||
− | npc = osNpcCreate("ImYour", "Clone", npcPos, | + | osAgentSaveAppearance(llDetectedKey(0), "appearance"); |
+ | npc = osNpcCreate("ImYour", "Clone", npcPos, "appearance"); | ||
toucherPos = llDetectedPos(0); | toucherPos = llDetectedPos(0); | ||
state hasNPC; | state hasNPC; | ||
Line 25: | Line 26: | ||
state_entry() | state_entry() | ||
{ | { | ||
− | osNpcMoveTo(npc, toucherPos + < | + | osNpcMoveTo(npc, toucherPos + <3,0,0>); |
osNpcSay(npc, "Hi there! My name is " + llKey2Name(npc)); | osNpcSay(npc, "Hi there! My name is " + llKey2Name(npc)); | ||
} | } | ||
Line 39: | Line 40: | ||
</source> | </source> | ||
|description=*Creates a NPC(Non Player Character) clone named '''firstname''' '''lastname''' at '''position''' from an already existing avatar '''cloneFrom'''. | |description=*Creates a NPC(Non Player Character) clone named '''firstname''' '''lastname''' at '''position''' from an already existing avatar '''cloneFrom'''. | ||
− | |||
− | |||
− | |||
− | |||
| | | | ||
}} | }} |
Revision as of 02:31, 16 August 2011
key osNpcCreate(string firstname, string lastname, vector position, string notecard)
| |
| |
Threat Level | High |
Permissions | No permissions specified |
Extra Delay | No function delay specified |
Example(s) | |
// touch to create a NPC clone of the toucher in front of this emitter // NPC will move to the toucher, then will greet them. // Touch again to remove the NPC key npc; vector toucherPos; default { touch_start(integer number) { vector npcPos = llGetPos() + <1,0,0>; osAgentSaveAppearance(llDetectedKey(0), "appearance"); npc = osNpcCreate("ImYour", "Clone", npcPos, "appearance"); toucherPos = llDetectedPos(0); state hasNPC; } } state hasNPC { state_entry() { osNpcMoveTo(npc, toucherPos + <3,0,0>); osNpcSay(npc, "Hi there! My name is " + llKey2Name(npc)); } touch_start(integer number) { osNpcSay(npc, "Good bye!"); osNpcRemove(npc); npc = NULL_KEY; state default; } } |