OsNpcMoveToTarget
From OpenSimulator
(10 intermediate revisions by 3 users not shown) | |||
Line 2: | Line 2: | ||
|function_syntax=osNpcMoveToTarget(key npc, vector target, integer options) | |function_syntax=osNpcMoveToTarget(key npc, vector target, integer options) | ||
|csharp_syntax= | |csharp_syntax= | ||
− | |description=Move the | + | |description=Move the NPC to a given target over time. How the NPC will get there depends on the following options. |
− | OS_NPC_FLY - Fly the | + | OS_NPC_FLY - Fly the NPC to the given position. The avatar will not land unless the OS_NPC_LAND_AT_TARGET option is also given. |
− | OS_NPC_NO_FLY - Do not fly to the target. The NPC will attempt to walk to the location. If it's up in the air then the | + | OS_NPC_NO_FLY - Do not fly to the target. The NPC will attempt to walk to the location. If it's up in the air then the NPC will keep bouncing hopeless until another move target is given or the move is stopped. |
− | OS_NPC_LAND_AT_TARGET - If given and the | + | OS_NPC_LAND_AT_TARGET - If given and the NPC is flying, then it will land when it reaches the target. If OS_NPC_NO_FLY is given then this option has no effect. |
− | OS_NPC_FLY and OS_NPC_NO_FLY are options that cannot be combined - the | + | OS_NPC_FLY and OS_NPC_NO_FLY are options that cannot be combined - the NPC will end up doing one or the other. If you want the NPC to fly and land at the target, then OS_NPC_LAND_AT_TARGET must be combined with OS_NPC_FLY. |
− | OS_NPC_RUNNING - | + | OS_NPC_RUNNING - make the NPC run to the given position. |
− | |threat_level= | + | |threat_level=High |
+ | |permissions=${OSSL|osslNPC} | ||
+ | |delay=0 | ||
|ossl_example= | |ossl_example= | ||
− | |additional_info= | + | '''With OS_NPC_NO_FLY:''' |
+ | <source lang="lsl"> | ||
+ | // | ||
+ | // osNpcMoveToTarget Script Exemple | ||
+ | // With the use of the option OS_NPC_NO_FLY | ||
+ | // Author: djphil | ||
+ | // | ||
+ | |||
+ | key npc; | ||
+ | |||
+ | default | ||
+ | { | ||
+ | state_entry() | ||
+ | { | ||
+ | llSay(PUBLIC_CHANNEL, "Touch to see osNpcMoveToTarget usage."); | ||
+ | llSay(PUBLIC_CHANNEL, "This with the use of the option OS_NPC_NO_FLY."); | ||
+ | } | ||
+ | |||
+ | touch_start(integer number) | ||
+ | { | ||
+ | key toucher = llDetectedKey(0); | ||
+ | vector npcPos = llGetPos() + <-5.0, -1.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!"); | ||
+ | osNpcMoveToTarget(npc, llGetPos() + <5.0, -1.0, 0.0>, OS_NPC_NO_FLY); | ||
+ | } | ||
+ | |||
+ | touch_start(integer number) | ||
+ | { | ||
+ | llSetTimerEvent(0.0); | ||
+ | osNpcSay(npc, "Goodbye!"); | ||
+ | osNpcRemove(npc); | ||
+ | npc = NULL_KEY; | ||
+ | state default; | ||
+ | } | ||
+ | } | ||
+ | </source> | ||
+ | '''With OS_NPC_FLY:''' | ||
+ | <source lang="lsl"> | ||
+ | // | ||
+ | // osNpcMoveToTarget Script Exemple | ||
+ | // With the use of the option OS_NPC_FLY | ||
+ | // Author: djphil | ||
+ | // | ||
+ | |||
+ | key npc; | ||
+ | |||
+ | default | ||
+ | { | ||
+ | state_entry() | ||
+ | { | ||
+ | llSay(PUBLIC_CHANNEL, "Touch to see osNpcMoveToTarget usage."); | ||
+ | llSay(PUBLIC_CHANNEL, "This with the use of the option OS_NPC_FLY."); | ||
+ | } | ||
+ | |||
+ | touch_start(integer number) | ||
+ | { | ||
+ | key toucher = llDetectedKey(0); | ||
+ | vector npcPos = llGetPos() + <-5.0, -1.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!"); | ||
+ | osNpcMoveToTarget(npc, llGetPos() + <5.0, -1.0, 3.0>, OS_NPC_FLY); | ||
+ | } | ||
+ | |||
+ | touch_start(integer number) | ||
+ | { | ||
+ | llSetTimerEvent(0.0); | ||
+ | osNpcSay(npc, "Goodbye!"); | ||
+ | osNpcRemove(npc); | ||
+ | npc = NULL_KEY; | ||
+ | state default; | ||
+ | } | ||
+ | } | ||
+ | </source> | ||
+ | '''With OS_NPC_FLY and OS_NPC_LAND_AT_TARGET:''' | ||
+ | <source lang="lsl"> | ||
+ | // | ||
+ | // osNpcMoveToTarget Script Exemple | ||
+ | // With the use of the option OS_NPC_FLY and OS_NPC_LAND_AT_TARGET | ||
+ | // Author: djphil | ||
+ | // | ||
+ | |||
+ | key npc; | ||
+ | |||
+ | default | ||
+ | { | ||
+ | state_entry() | ||
+ | { | ||
+ | llSay(PUBLIC_CHANNEL, "Touch to see osNpcMoveToTarget usage."); | ||
+ | llSay(PUBLIC_CHANNEL, "This with the use of the option OS_NPC_FLY and OS_NPC_LAND_AT_TARGET."); | ||
+ | } | ||
+ | |||
+ | touch_start(integer number) | ||
+ | { | ||
+ | key toucher = llDetectedKey(0); | ||
+ | vector npcPos = llGetPos() + <-5.0, -1.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!"); | ||
+ | osNpcMoveToTarget(npc, llGetPos() + <5.0, -1.0, 3.0>, OS_NPC_FLY | OS_NPC_LAND_AT_TARGET); | ||
+ | } | ||
+ | |||
+ | touch_start(integer number) | ||
+ | { | ||
+ | llSetTimerEvent(0.0); | ||
+ | osNpcSay(npc, "Goodbye!"); | ||
+ | osNpcRemove(npc); | ||
+ | npc = NULL_KEY; | ||
+ | state default; | ||
+ | } | ||
+ | } | ||
+ | </source> | ||
+ | '''With OS_NPC_RUNNING:''' | ||
+ | <source lang="lsl"> | ||
+ | // | ||
+ | // osNpcMoveToTarget Script Exemple | ||
+ | // With the use of the option OS_NPC_RUNNING | ||
+ | // Author: djphil | ||
+ | // | ||
+ | |||
+ | key npc; | ||
+ | |||
+ | default | ||
+ | { | ||
+ | state_entry() | ||
+ | { | ||
+ | llSay(PUBLIC_CHANNEL, "Touch to see osNpcMoveToTarget usage."); | ||
+ | llSay(PUBLIC_CHANNEL, "This with the use of the option OS_NPC_RUNNING."); | ||
+ | } | ||
+ | |||
+ | touch_start(integer number) | ||
+ | { | ||
+ | key toucher = llDetectedKey(0); | ||
+ | vector npcPos = llGetPos() + <-5.0, -1.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!"); | ||
+ | osNpcMoveToTarget(npc, llGetPos() + <5.0, -1.0, 0.0>, OS_NPC_RUNNING); | ||
+ | } | ||
+ | |||
+ | touch_start(integer number) | ||
+ | { | ||
+ | llSetTimerEvent(0.0); | ||
+ | osNpcSay(npc, "Goodbye!"); | ||
+ | osNpcRemove(npc); | ||
+ | npc = NULL_KEY; | ||
+ | state default; | ||
+ | } | ||
+ | } | ||
+ | </source> | ||
+ | |additional_info=This function was added in 0.7.2-post-fixes | ||
}} | }} | ||
+ | == See Also == | ||
+ | * [[osNpcMoveTo]] | ||
+ | * [[osNpcMoveToTarget]] | ||
+ | * [[osNpcStopMoveToTarget]] |
Latest revision as of 14:00, 13 September 2021
osNpcMoveToTarget(key npc, vector target, integer options)
| |
Move the NPC to a given target over time. How the NPC will get there depends on the following options.
OS_NPC_FLY - Fly the NPC to the given position. The avatar will not land unless the OS_NPC_LAND_AT_TARGET option is also given. OS_NPC_NO_FLY - Do not fly to the target. The NPC will attempt to walk to the location. If it's up in the air then the NPC will keep bouncing hopeless until another move target is given or the move is stopped. OS_NPC_LAND_AT_TARGET - If given and the NPC is flying, then it will land when it reaches the target. If OS_NPC_NO_FLY is given then this option has no effect. OS_NPC_FLY and OS_NPC_NO_FLY are options that cannot be combined - the NPC will end up doing one or the other. If you want the NPC to fly and land at the target, then OS_NPC_LAND_AT_TARGET must be combined with OS_NPC_FLY. OS_NPC_RUNNING - make the NPC run to the given position. | |
Threat Level | High |
Permissions | ${OSSL|osslNPC} |
Extra Delay | 0 seconds |
Example(s) | |
With OS_NPC_NO_FLY:
// // osNpcMoveToTarget Script Exemple // With the use of the option OS_NPC_NO_FLY // Author: djphil // key npc; default { state_entry() { llSay(PUBLIC_CHANNEL, "Touch to see osNpcMoveToTarget usage."); llSay(PUBLIC_CHANNEL, "This with the use of the option OS_NPC_NO_FLY."); } touch_start(integer number) { key toucher = llDetectedKey(0); vector npcPos = llGetPos() + <-5.0, -1.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!"); osNpcMoveToTarget(npc, llGetPos() + <5.0, -1.0, 0.0>, OS_NPC_NO_FLY); } touch_start(integer number) { llSetTimerEvent(0.0); osNpcSay(npc, "Goodbye!"); osNpcRemove(npc); npc = NULL_KEY; state default; } } With OS_NPC_FLY: // // osNpcMoveToTarget Script Exemple // With the use of the option OS_NPC_FLY // Author: djphil // key npc; default { state_entry() { llSay(PUBLIC_CHANNEL, "Touch to see osNpcMoveToTarget usage."); llSay(PUBLIC_CHANNEL, "This with the use of the option OS_NPC_FLY."); } touch_start(integer number) { key toucher = llDetectedKey(0); vector npcPos = llGetPos() + <-5.0, -1.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!"); osNpcMoveToTarget(npc, llGetPos() + <5.0, -1.0, 3.0>, OS_NPC_FLY); } touch_start(integer number) { llSetTimerEvent(0.0); osNpcSay(npc, "Goodbye!"); osNpcRemove(npc); npc = NULL_KEY; state default; } } With OS_NPC_FLY and OS_NPC_LAND_AT_TARGET: // // osNpcMoveToTarget Script Exemple // With the use of the option OS_NPC_FLY and OS_NPC_LAND_AT_TARGET // Author: djphil // key npc; default { state_entry() { llSay(PUBLIC_CHANNEL, "Touch to see osNpcMoveToTarget usage."); llSay(PUBLIC_CHANNEL, "This with the use of the option OS_NPC_FLY and OS_NPC_LAND_AT_TARGET."); } touch_start(integer number) { key toucher = llDetectedKey(0); vector npcPos = llGetPos() + <-5.0, -1.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!"); osNpcMoveToTarget(npc, llGetPos() + <5.0, -1.0, 3.0>, OS_NPC_FLY | OS_NPC_LAND_AT_TARGET); } touch_start(integer number) { llSetTimerEvent(0.0); osNpcSay(npc, "Goodbye!"); osNpcRemove(npc); npc = NULL_KEY; state default; } } With OS_NPC_RUNNING: // // osNpcMoveToTarget Script Exemple // With the use of the option OS_NPC_RUNNING // Author: djphil // key npc; default { state_entry() { llSay(PUBLIC_CHANNEL, "Touch to see osNpcMoveToTarget usage."); llSay(PUBLIC_CHANNEL, "This with the use of the option OS_NPC_RUNNING."); } touch_start(integer number) { key toucher = llDetectedKey(0); vector npcPos = llGetPos() + <-5.0, -1.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!"); osNpcMoveToTarget(npc, llGetPos() + <5.0, -1.0, 0.0>, OS_NPC_RUNNING); } touch_start(integer number) { llSetTimerEvent(0.0); osNpcSay(npc, "Goodbye!"); osNpcRemove(npc); npc = NULL_KEY; state default; } } | |
Notes | |
This function was added in 0.7.2-post-fixes |
[edit] See Also
- osNpcMoveTo
- osNpcMoveToTarget
- osNpcStopMoveToTarget