Difference between revisions of "LlListenControl"

From Second Life Wiki
Jump to navigation Jump to search
m (Replaced <source> with <syntaxhighlight>)
 
(16 intermediate revisions by 4 users not shown)
Line 1: Line 1:
{{LSL_Function
{{LSL_Function
|inject-2={{LSL Function/handle|handle|listen|control=*}}
{{LSL Function/boolean|active|td=activates|fd=deactivates|default=true}}
|func_id=26|func_sleep=0.0|func_energy=10.0
|func_id=26|func_sleep=0.0|func_energy=10.0
|func=llListenControl|p1_type=integer|p1_name=number|p2_type=integer|p2_name=active
|func=llListenControl
|p1_type=integer|p1_subtype=handle|p1_name=handle
|p2_type=integer|p2_subtype=boolean|p2_name=active
|func_footnote
|func_footnote
|func_desc=makes a listen event callback active or inactive
|func_desc=Makes [[listen]] event callback {{LSLP|handle}} active or inactive
|return_text
|return_text
|spec
|spec
|caveats
|caveats=*On [[state]] change or [[llResetScript|script reset]] all listens are removed automaticaly.
|constants
|constants
|examples
|examples=a small example of an on and off switchable listen by use of llListenControl()
<syntaxhighlight lang="lsl2">
integer handle;
integer toggle;
default
{
    state_entry()
    {
        handle = llListen(5, "", NULL_KEY, "");    // Establish a listener to listen to anything on channel 5 ...
        llListenControl(handle, FALSE);            // ... but make the listener inactive for now
        llSetText("not listening", <0.0,0.0,0.0>, 1.0);
    }
 
    touch_start(integer total_number)
    {
        toggle = !toggle;
        llListenControl(handle, toggle);          // Make the listener active or inactive as required
 
        if(toggle)
        {
            llSay(0, "now listening on channel 5");
            llSetText("listening on ch 5", <1.0,0.0,0.0>, 1.0);
        }
        else
        {
            llSay(0, "not listening any more");
            llSetText("not listening", <0.0,0.0,0.0>, 1.0);
        }   
    }
   
    listen(integer channel, string name, key id, string message)
    {
        llSay(0, name + " just said " + message);
    }
}
</syntaxhighlight>
|helpers
|helpers
|also_functions=*{{LSLG|llListen}}
|also_functions={{LSL DefineRow||[[llListen]]}}
|also_events=*{{LSLG|listen}}
{{LSL DefineRow||[[llListenRemove]]}}
|also_events={{LSL DefineRow||[[listen]]}}
|also_tests
|also_tests
|also_articles
|also_articles
Line 17: Line 57:
|permission
|permission
|negative_index
|negative_index
|sort=ListenControl
|cat1=Communications
|cat1=Communications
|cat2=Chat
|cat2=Chat

Latest revision as of 04:40, 23 April 2022

Summary

Function: llListenControl( integer handle, integer active );
0.0 Forced Delay
10.0 Energy

Makes listen event callback handle active or inactive

• integer handle handle to control listen event
• integer active TRUE (default) activates, FALSE deactivates

Caveats

Examples

a small example of an on and off switchable listen by use of llListenControl()

integer handle;
integer toggle;
default
{
    state_entry()
    {
        handle = llListen(5, "", NULL_KEY, "");    // Establish a listener to listen to anything on channel 5 ...
        llListenControl(handle, FALSE);            // ... but make the listener inactive for now
        llSetText("not listening", <0.0,0.0,0.0>, 1.0);
    }

    touch_start(integer total_number)
    {
        toggle = !toggle;
        llListenControl(handle, toggle);           // Make the listener active or inactive as required

        if(toggle)
        {
            llSay(0, "now listening on channel 5");
            llSetText("listening on ch 5", <1.0,0.0,0.0>, 1.0);
        }
        else
        {
            llSay(0, "not listening any more");
            llSetText("not listening", <0.0,0.0,0.0>, 1.0);
        }     
    }
    
    listen(integer channel, string name, key id, string message)
    {
        llSay(0, name + " just said " + message);
    }
}

See Also

Events

•  listen

Functions

•  llListen
•  llListenRemove

Deep Notes

Signature

function void llListenControl( integer handle, integer active );