OsNpcSetRot
From OpenSimulator
(Difference between revisions)
m (Added note stating which version of OpenSim introduced this function) |
m (Change See Also) |
||
(4 intermediate revisions by 2 users not shown) | |||
Line 4: | Line 4: | ||
|description=Set the rotation of the avatar. Only setting the rotation in the Z plane in Euler rotation will have any meaningful effect (turning the avatar to point in one direction or another). Setting X or Y Euler values will result in the avatar rotating in an undefined manner. | |description=Set the rotation of the avatar. Only setting the rotation in the Z plane in Euler rotation will have any meaningful effect (turning the avatar to point in one direction or another). Setting X or Y Euler values will result in the avatar rotating in an undefined manner. | ||
|threat_level=High | |threat_level=High | ||
− | |permissions=${ | + | |permissions=${OSSL|osslNPC} |
|delay=0 | |delay=0 | ||
− | |ossl_example= | + | |ossl_example=<source lang="lsl"> |
+ | // | ||
+ | // osNpcSetRot Script Exemple | ||
+ | // Author: djphil | ||
+ | // | ||
+ | |||
+ | key npc; | ||
+ | |||
+ | default | ||
+ | { | ||
+ | state_entry() | ||
+ | { | ||
+ | llSay(PUBLIC_CHANNEL, "Touch to see osNpcSetRot usage."); | ||
+ | } | ||
+ | |||
+ | touch_start(integer number) | ||
+ | { | ||
+ | key toucher = llDetectedKey(0); | ||
+ | vector npcPos = llGetPos() + <1.0, 0.0, 1.0>; | ||
+ | osAgentSaveAppearance(toucher, "appearance"); | ||
+ | npc = osNpcCreate("ImYour", "Clone", npcPos, "appearance"); | ||
+ | state hasNPC; | ||
+ | } | ||
+ | } | ||
+ | |||
+ | state hasNPC | ||
+ | { | ||
+ | state_entry() | ||
+ | { | ||
+ | llSetTimerEvent(5.0); | ||
+ | } | ||
+ | |||
+ | timer() | ||
+ | { | ||
+ | llSetTimerEvent(0.0); | ||
+ | osNpcSay(npc, "Hello world!"); | ||
+ | osNpcSetRot(npc, <0.000000, 0.000000, 1.000000, 0.000000>); | ||
+ | } | ||
+ | |||
+ | touch_start(integer number) | ||
+ | { | ||
+ | osNpcSay(npc, "Goodbye!"); | ||
+ | llSetTimerEvent(0.0); | ||
+ | osNpcRemove(npc); | ||
+ | npc = NULL_KEY; | ||
+ | state default; | ||
+ | } | ||
+ | } | ||
+ | </source> | ||
+ | '''Or with llEuler2Rot''' | ||
+ | <source lang="lsl"> | ||
+ | // | ||
+ | // osNpcSetRot Script Exemple | ||
+ | // Author: djphil | ||
+ | // | ||
+ | |||
+ | key npc; | ||
+ | |||
+ | default | ||
+ | { | ||
+ | state_entry() | ||
+ | { | ||
+ | llSay(PUBLIC_CHANNEL, "Touch to see osNpcSetRot usage."); | ||
+ | } | ||
+ | |||
+ | touch_start(integer number) | ||
+ | { | ||
+ | key toucher = llDetectedKey(0); | ||
+ | vector npcPos = llGetPos() + <1.0, 0.0, 1.0>; | ||
+ | osAgentSaveAppearance(toucher, "appearance"); | ||
+ | npc = osNpcCreate("ImYour", "Clone", npcPos, "appearance"); | ||
+ | state hasNPC; | ||
+ | } | ||
+ | } | ||
+ | |||
+ | state hasNPC | ||
+ | { | ||
+ | state_entry() | ||
+ | { | ||
+ | llSetTimerEvent(5.0); | ||
+ | } | ||
+ | |||
+ | timer() | ||
+ | { | ||
+ | llSetTimerEvent(0.0); | ||
+ | osNpcSay(npc, "Hello world!"); | ||
+ | osNpcSetRot(npc, llEuler2Rot(<0.0, 0.0, PI>)); | ||
+ | } | ||
+ | |||
+ | touch_start(integer number) | ||
+ | { | ||
+ | osNpcSay(npc, "Goodbye!"); | ||
+ | llSetTimerEvent(0.0); | ||
+ | osNpcRemove(npc); | ||
+ | npc = NULL_KEY; | ||
+ | state default; | ||
+ | } | ||
+ | } | ||
+ | </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 | ||
}} | }} | ||
+ | == See Also == | ||
+ | * [[osNpcGetPos]] | ||
+ | * [[osNpcGetRot]] | ||
+ | * [[osNpcSetRot]] | ||
+ | * [[osNpcMoveTo]] | ||
+ | * [[osNpcMoveToTarget]] | ||
+ | * [[osNpcStopMoveToTarget]] |
Latest revision as of 18:54, 5 December 2020
osNpcSetRot(key npc, rotation rot)
| |
Set the rotation of the avatar. Only setting the rotation in the Z plane in Euler rotation will have any meaningful effect (turning the avatar to point in one direction or another). Setting X or Y Euler values will result in the avatar rotating in an undefined manner. | |
Threat Level | High |
Permissions | ${OSSL|osslNPC} |
Extra Delay | 0 seconds |
Example(s) | |
// // osNpcSetRot Script Exemple // Author: djphil // key npc; default { state_entry() { llSay(PUBLIC_CHANNEL, "Touch to see osNpcSetRot usage."); } touch_start(integer number) { key toucher = llDetectedKey(0); vector npcPos = llGetPos() + <1.0, 0.0, 1.0>; osAgentSaveAppearance(toucher, "appearance"); npc = osNpcCreate("ImYour", "Clone", npcPos, "appearance"); state hasNPC; } } state hasNPC { state_entry() { llSetTimerEvent(5.0); } timer() { llSetTimerEvent(0.0); osNpcSay(npc, "Hello world!"); osNpcSetRot(npc, <0.000000, 0.000000, 1.000000, 0.000000>); } touch_start(integer number) { osNpcSay(npc, "Goodbye!"); llSetTimerEvent(0.0); osNpcRemove(npc); npc = NULL_KEY; state default; } } Or with llEuler2Rot // // osNpcSetRot Script Exemple // Author: djphil // key npc; default { state_entry() { llSay(PUBLIC_CHANNEL, "Touch to see osNpcSetRot usage."); } touch_start(integer number) { key toucher = llDetectedKey(0); vector npcPos = llGetPos() + <1.0, 0.0, 1.0>; osAgentSaveAppearance(toucher, "appearance"); npc = osNpcCreate("ImYour", "Clone", npcPos, "appearance"); state hasNPC; } } state hasNPC { state_entry() { llSetTimerEvent(5.0); } timer() { llSetTimerEvent(0.0); osNpcSay(npc, "Hello world!"); osNpcSetRot(npc, llEuler2Rot(<0.0, 0.0, PI>)); } touch_start(integer number) { osNpcSay(npc, "Goodbye!"); llSetTimerEvent(0.0); osNpcRemove(npc); npc = NULL_KEY; state default; } } | |
Notes | |
This function was added in 0.7.2-post-fixes |