Difference between revisions of "Dialog Message"

From Second Life Wiki
Jump to navigation Jump to search
(In the future only post scripts that WORK.)
m (<lsl> tag to <source>)
 
(2 intermediate revisions by 2 users not shown)
Line 11: Line 11:
|}
|}


<pre>
<source lang="lsl2">
integer channel = 1000;
integer channel = 1000;


list keys;
string token;
string token;
string data;
string data;
Line 32: Line 31:
     sensor(integer num_detected)
     sensor(integer num_detected)
     {  
     {  
        list keys = [];
        integer i = 0;
        for (; i < num_detected; ++i)
            keys += llDetectedKey(i);
         if(token == "dialog")
         if(token == "dialog")
         {
         {
             integer len = llGetListLength(names);
             integer i = 0;
             for(s = 0; s < len; ++s)
             for(; i < num_detected; ++i)
                 llDialog(llList2Key(keys, s), data, [], channel );
                 llDialog(llDetectedKey(i), data, [], channel );
         }
         }
     }
     }
Line 58: Line 51:
     }
     }
}
}
</pre>
</source>


{{LSLC|Examples}}
{{LSLC|Examples}}

Latest revision as of 13:47, 24 January 2015

A simple script thats lets anyone say a messages over a dialog instead of using llSay or llShout.

Usage: /channel dialog message

• integer channel channel number the script is listening on
• string message message to display
integer channel = 1000;

string token;
string data;

default
{
    state_entry()
    {
        llListen(channel, "", "", "");
    }
    
    on_rez(integer start_param)
    {
        llResetScript();
    }
        
    sensor(integer num_detected)
    { 
        if(token == "dialog")
        {
            integer i = 0;
            for(; i < num_detected; ++i)
                llDialog(llDetectedKey(i), data, [], channel );
        }
    }
    
    listen(integer chan, string name, key id, string command)
    {
        integer s = llSubStringIndex(command," ");
        if (~s)
        {
            token = llDeleteSubString(command, s, -1);
            data = llDeleteSubString(command, 0, s);
            if(token == "dialog")
                llSensor( "", "", AGENT, 32, PI );
        }
    }
}