OsNpcSetRot
From OpenSimulator
(Difference between revisions)
(Add exemples) |
|||
| Line 6: | Line 6: | ||
|permissions=${OSSL|osslNPC} | |permissions=${OSSL|osslNPC} | ||
|delay=0 | |delay=0 | ||
| − | |ossl_example= | + | |ossl_example=<source lang="lsl"> |
| + | // | ||
| + | // osNpcSetRot Script Exemple | ||
| + | // Authior: 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 | ||
| + | // Authior: 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 | ||
}} | }} | ||
Revision as of 15:19, 1 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 // Authior: 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 // Authior: 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 | |