OsNpcGetOwner
From OpenSimulator
(Difference between revisions)
												
			 (Add exemples)  | 
			|||
| Line 7: | Line 7: | ||
|delay=0  | |delay=0  | ||
|ossl_example=  | |ossl_example=  | ||
| + | '''With OS_NPC_CREATOR_OWNED:'''  | ||
| + | <source lang="lsl">  | ||
| + | //  | ||
| + | // osNpcGetOwner Script Exemple  | ||
| + | // With the use of the option OS_NPC_CREATOR_OWNED  | ||
| + | // Authior: djphil  | ||
| + | //  | ||
| + | |||
| + | key npc;  | ||
| + | |||
| + | default  | ||
| + | {  | ||
| + |     state_entry()  | ||
| + |     {  | ||
| + |         llSay(PUBLIC_CHANNEL, "Touch to see osNpcGetOwner usage.");  | ||
| + |         llSay(PUBLIC_CHANNEL, "This with the use of the option OS_NPC_CREATOR_OWNED.");  | ||
| + |     }  | ||
| + | |||
| + |     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", OS_NPC_CREATOR_OWNED);  | ||
| + |         state hasNPC;  | ||
| + |     }  | ||
| + | }  | ||
| + | |||
| + | state hasNPC  | ||
| + | {  | ||
| + |     state_entry()  | ||
| + |     {  | ||
| + |         llSetTimerEvent(5.0);  | ||
| + |     }  | ||
| + | |||
| + |     timer()  | ||
| + |     {  | ||
| + |         llSetTimerEvent(0.0);  | ||
| + |         key npc_owner = osNpcGetOwner(npc);  | ||
| + |         osNpcSay(npc, "Hello world!");  | ||
| + |         osNpcSay(npc, "My owner is: " + (string)npc_owner + " (" + llKey2Name(npc_owner) + ")");  | ||
| + |     }  | ||
| + | |||
| + |     touch_start(integer number)  | ||
| + |     {  | ||
| + |         osNpcSay(npc, "Goodbye!");  | ||
| + |         llSetTimerEvent(0.0);  | ||
| + |         osNpcRemove(npc);  | ||
| + |         npc = NULL_KEY;  | ||
| + |         state default;  | ||
| + |     }  | ||
| + | }  | ||
| + | </source>  | ||
| + | '''With OS_NPC_NOT_OWNED:'''  | ||
| + | <source lang="lsl">  | ||
| + | //  | ||
| + | // osNpcGetOwner Script Exemple  | ||
| + | // With the use of the option OS_NPC_NOT_OWNED  | ||
| + | // Authior: djphil  | ||
| + | //  | ||
| + | |||
| + | key npc;  | ||
| + | |||
| + | default  | ||
| + | {  | ||
| + |     state_entry()  | ||
| + |     {  | ||
| + |         llSay(PUBLIC_CHANNEL, "Touch to see osNpcGetOwner usage.");  | ||
| + |         llSay(PUBLIC_CHANNEL, "This with the use of the option OS_NPC_NOT_OWNED.");  | ||
| + |     }  | ||
| + | |||
| + |     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", OS_NPC_NOT_OWNED);  | ||
| + |         state hasNPC;  | ||
| + |     }  | ||
| + | }  | ||
| + | |||
| + | state hasNPC  | ||
| + | {  | ||
| + |     state_entry()  | ||
| + |     {  | ||
| + |         llSetTimerEvent(5.0);  | ||
| + |     }  | ||
| + | |||
| + |     timer()  | ||
| + |     {  | ||
| + |         llSetTimerEvent(0.0);  | ||
| + |         key npc_owner = osNpcGetOwner(npc);  | ||
| + |         osNpcSay(npc, "Hello world!");  | ||
| + |         osNpcSay(npc, "My owner is: " + (string)npc_owner + " (" + llKey2Name(npc_owner) + ")");  | ||
| + | |||
| + |     }  | ||
| + | |||
| + |     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.3-post-fixes  | |additional_info=This function was added in 0.7.3-post-fixes  | ||
}}  | }}  | ||
Revision as of 13:21, 1 December 2020
key osNpcGetOwner(key npc)
 
 | |
| Gets the NPC's owner's UUID | |
| Threat Level | None | 
| Permissions | ${OSSL|osslNPC} | 
| Extra Delay | 0 seconds | 
| Example(s) | |
With OS_NPC_CREATOR_OWNED:
// // osNpcGetOwner Script Exemple // With the use of the option OS_NPC_CREATOR_OWNED // Authior: djphil // key npc; default { state_entry() { llSay(PUBLIC_CHANNEL, "Touch to see osNpcGetOwner usage."); llSay(PUBLIC_CHANNEL, "This with the use of the option OS_NPC_CREATOR_OWNED."); } 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", OS_NPC_CREATOR_OWNED); state hasNPC; } } state hasNPC { state_entry() { llSetTimerEvent(5.0); } timer() { llSetTimerEvent(0.0); key npc_owner = osNpcGetOwner(npc); osNpcSay(npc, "Hello world!"); osNpcSay(npc, "My owner is: " + (string)npc_owner + " (" + llKey2Name(npc_owner) + ")"); } touch_start(integer number) { osNpcSay(npc, "Goodbye!"); llSetTimerEvent(0.0); osNpcRemove(npc); npc = NULL_KEY; state default; } } With OS_NPC_NOT_OWNED: // // osNpcGetOwner Script Exemple // With the use of the option OS_NPC_NOT_OWNED // Authior: djphil // key npc; default { state_entry() { llSay(PUBLIC_CHANNEL, "Touch to see osNpcGetOwner usage."); llSay(PUBLIC_CHANNEL, "This with the use of the option OS_NPC_NOT_OWNED."); } 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", OS_NPC_NOT_OWNED); state hasNPC; } } state hasNPC { state_entry() { llSetTimerEvent(5.0); } timer() { llSetTimerEvent(0.0); key npc_owner = osNpcGetOwner(npc); osNpcSay(npc, "Hello world!"); osNpcSay(npc, "My owner is: " + (string)npc_owner + " (" + llKey2Name(npc_owner) + ")"); } 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.3-post-fixes | |