Difference between revisions of "LlListenRemove"

From Second Life Wiki
Jump to: navigation, search
m
m (<lsl> tag to <source>)
 
(11 intermediate revisions by 6 users not shown)
Line 1: Line 1:
 
{{LSL_Function
 
{{LSL_Function
 +
|inject-2={{LSL Function/handle|handle|listen}}
 
|func_id=27|func_sleep=0.0|func_energy=10.0
 
|func_id=27|func_sleep=0.0|func_energy=10.0
|func=llListenRemove|p1_type=integer|p1_name=number
+
|func=llListenRemove
 +
|p1_type=integer|p1_subtype=handle|p1_name=handle
 
|func_footnote
 
|func_footnote
|func_desc=Removes listen event callback '''number'''
+
|func_desc=Removes listen event callback {{LSLP|handle}}
 
|return_text
 
|return_text
 
|spec
 
|spec
|caveats=*On [[state]] change or script reset all listens are removed.
+
|caveats=*On [[state]] change or [[llResetScript|script reset]] all listens are removed automatically.
 
**A state change can be used as a shortcut to releasing all listens in the script.
 
**A state change can be used as a shortcut to releasing all listens in the script.
 +
*No error is thrown if {{LSLP|handle}} has already been released or is invalid.
 
|constants
 
|constants
|examples=<pre>
+
|examples=<source lang="lsl2">
integer olf;
+
// Listen for one line of chat from the owner, echo it back to them, then stop listening
 +
integer ListenHandle;
 
default
 
default
 
{
 
{
    //Repeats one line of text then stops listening
 
 
     state_entry()
 
     state_entry()
 
     {
 
     {
         olf=llListen(0,"",llGetOwner(),"");
+
         // Start listening on channel 0, for text from owner only
 +
        ListenHandle = llListen(0, "", llGetOwner(), "");
 
     }
 
     }
 
     listen(integer channel, string name, key id, string message)
 
     listen(integer channel, string name, key id, string message)
 
     {
 
     {
         llOwnerSay(message);
+
         llOwnerSay(message);           // Echo the message back to the owner
         llListenRemove(olf);
+
         llListenRemove(ListenHandle);   // Stop listening
 
     }
 
     }
}
+
}</source>
</pre>
+
 
|helpers
 
|helpers
 
|also_functions={{LSL DefineRow||[[llListen]]}}
 
|also_functions={{LSL DefineRow||[[llListen]]}}
Line 31: Line 34:
 
|also_tests
 
|also_tests
 
|also_articles
 
|also_articles
|notes
+
|notes=*It is good practice to remove listeners when they are no longer required, or set them inactive via [[llListenControl]]
 
|permission
 
|permission
 
|negative_index
 
|negative_index

Latest revision as of 11:13, 22 January 2015

Summary

Function: llListenRemove( integer handle );

Removes listen event callback handle

• integer handle handle to control listen event

Caveats

  • On state change or script reset all listens are removed automatically.
    • A state change can be used as a shortcut to releasing all listens in the script.
  • No error is thrown if handle has already been released or is invalid.
All Issues ~ Search JIRA for related Bugs

Examples

// Listen for one line of chat from the owner, echo it back to them, then stop listening
integer ListenHandle;
default
{
    state_entry()
    {
        // Start listening on channel 0, for text from owner only
        ListenHandle = llListen(0, "", llGetOwner(), "");
    }
    listen(integer channel, string name, key id, string message)
    {
        llOwnerSay(message);            // Echo the message back to the owner
        llListenRemove(ListenHandle);   // Stop listening
    }
}

Notes

  • It is good practice to remove listeners when they are no longer required, or set them inactive via llListenControl

See Also

Events

• listen

Functions

•  llListen
•  llListenControl

Deep Notes

Search JIRA for related Issues

Signature

function void llListenRemove( integer handle );