Difference between revisions of "Dialog Message"
Jump to navigation
Jump to search
(Clean up your code before you post it.) |
(In the future only post scripts that WORK.) |
||
Line 1: | Line 1: | ||
{{LSL Header}} | {{LSL Header}}{{#vardefine:p_channel_desc|channel number the script is listening on | ||
}}{{#vardefine:p_message_desc|message to display | |||
}} | |||
A simple script thats lets anyone say a messages over a dialog instead of using [[llSay]] or [[llShout]]. | |||
===Usage: /{{LSL Param|channel}} dialog {{LSL Param|message}}=== | |||
{| | |||
{{LSL DefineRow|integer|channel|{{#var:p_channel_desc}}}} | |||
{{LSL DefineRow|string|message|{{#var:p_message_desc}}}} | |||
|} | |||
<pre> | <pre> | ||
integer channel = 1000; | integer channel = 1000; | ||
list keys; | |||
string token; | |||
string data; | |||
default | default | ||
{ | { | ||
state_entry() | state_entry() | ||
{ | { | ||
llListen(channel,"", "",""); | llListen(channel, "", "", ""); | ||
} | } | ||
Line 29: | Line 28: | ||
{ | { | ||
llResetScript(); | llResetScript(); | ||
} | } | ||
sensor(integer num_detected) | sensor(integer num_detected) | ||
{ | { | ||
list keys = []; | |||
integer i = 0; | |||
for (; i < num_detected; ++i) | |||
for ( | keys += llDetectedKey(i); | ||
if(token == "dialog") | |||
{ | { | ||
names = | integer len = llGetListLength(names); | ||
for(s = 0; s < len; ++s) | |||
llDialog(llList2Key(keys, s), data, [], channel ); | |||
} | } | ||
} | } | ||
listen(integer chan, string name, key id, string command) | listen(integer chan, string name, key id, string command) | ||
{ | { | ||
integer s = llSubStringIndex(command," "); | |||
if (~s) | |||
if ( | |||
{ | { | ||
token = llDeleteSubString(command, s, -1); | |||
data = llDeleteSubString(command, 0, s); | |||
if(token == "dialog") | |||
llSensor( "", "", AGENT, 32, PI ); | |||
} | } | ||
} | } | ||
Line 122: | Line 60: | ||
</pre> | </pre> | ||
{{LSLC|Examples}} | |||
Revision as of 13:29, 3 September 2007
LSL Portal | Functions | Events | Types | Operators | Constants | Flow Control | Script Library | Categorized Library | Tutorials |
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; list keys; string token; string data; default { state_entry() { llListen(channel, "", "", ""); } on_rez(integer start_param) { llResetScript(); } sensor(integer num_detected) { list keys = []; integer i = 0; for (; i < num_detected; ++i) keys += llDetectedKey(i); if(token == "dialog") { integer len = llGetListLength(names); for(s = 0; s < len; ++s) llDialog(llList2Key(keys, s), 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 ); } } }