Difference between revisions of "User:Jana Kamachi/tut email"
Jump to navigation
Jump to search
Jana Kamachi (talk | contribs) (New page: This is a simple two part system. One of them, the master script, controls sending out the messages while the slaves actually '''do''' the work. Its much faster and efficent compared to al...) |
Jana Kamachi (talk | contribs) |
||
Line 1: | Line 1: | ||
This is a simple two part system. One of them, the master script, controls sending out the messages while the slaves actually '''do''' the work. Its much faster and efficent compared to alot of the ones out there. | This is a simple two part system. One of them, the master script, controls sending out the messages while the slaves actually '''do''' the work. Its much faster and efficent compared to alot of the ones out there. | ||
Part one: Master script. | ===Part one: Master script.=== | ||
This is the control script. It takes a key on channel 50, and sends messages typed on channel 4. | |||
<pre> | |||
key target; | |||
list used = [0,0,0,0, | |||
0,0,0,0, | |||
0,0,0,0, | |||
0,0,0,0, | |||
0,0,0,0 | |||
]; | |||
_send(string subj, string msg){ | |||
integer i=0; | |||
for(i=0;i<20;i++){ | |||
if(llList2Integer(used,i) == 0){ | |||
llSetObjectDesc(subj); | |||
llMessageLinked(LINK_SET,i,msg,target); | |||
used = llListReplaceList(used,[20],i,i); | |||
//llOwnerSay((string)i + "::" + (string)msg); | |||
if(subj == "msg"){ | |||
llSetObjectName(llKey2Name(llGetOwner())); | |||
llOwnerSay(msg); | |||
} | |||
return; | |||
} | |||
} | |||
} | |||
Part Two: Slave script. | default | ||
{ | |||
state_entry() | |||
{ | |||
llListen(50,"",llGetOwner(),""); | |||
llListen(4,"",llGetOwner(),""); | |||
llOwnerSay("/50 <key> - where to send to"); | |||
llOwnerSay("/4 <message> - what to send"); | |||
llSetTimerEvent(1); | |||
} | |||
listen(integer c, string name, key id, string msg){ | |||
if(c == 50){ | |||
target = (key)msg; | |||
} | |||
if(c == 4){ | |||
_send("msg",msg); | |||
} | |||
} | |||
timer(){ | |||
integer i; | |||
for(i=0;i<20;i++){ | |||
if(llList2Integer(used,i) > 0){ | |||
used = llListReplaceList(used,(list)(llList2Integer(used,i) - 1),i,i); | |||
} | |||
} | |||
} | |||
} | |||
</pre> | |||
===Part Two: Slave script.=== | |||
This part can be a bit tricky. Since it uses its name to decide when its supposed to do the work, it must be named properly. make 20 of these, named "t 0", "t 1", "t 2", ect. until you reach "t 19". Heres the code: | This part can be a bit tricky. Since it uses its name to decide when its supposed to do the work, it must be named properly. make 20 of these, named "t 0", "t 1", "t 2", ect. until you reach "t 19". Heres the code: | ||
<pre> | <pre> |
Revision as of 23:36, 16 October 2007
This is a simple two part system. One of them, the master script, controls sending out the messages while the slaves actually do the work. Its much faster and efficent compared to alot of the ones out there.
Part one: Master script.
This is the control script. It takes a key on channel 50, and sends messages typed on channel 4.
key target; list used = [0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0 ]; _send(string subj, string msg){ integer i=0; for(i=0;i<20;i++){ if(llList2Integer(used,i) == 0){ llSetObjectDesc(subj); llMessageLinked(LINK_SET,i,msg,target); used = llListReplaceList(used,[20],i,i); //llOwnerSay((string)i + "::" + (string)msg); if(subj == "msg"){ llSetObjectName(llKey2Name(llGetOwner())); llOwnerSay(msg); } return; } } } default { state_entry() { llListen(50,"",llGetOwner(),""); llListen(4,"",llGetOwner(),""); llOwnerSay("/50 <key> - where to send to"); llOwnerSay("/4 <message> - what to send"); llSetTimerEvent(1); } listen(integer c, string name, key id, string msg){ if(c == 50){ target = (key)msg; } if(c == 4){ _send("msg",msg); } } timer(){ integer i; for(i=0;i<20;i++){ if(llList2Integer(used,i) > 0){ used = llListReplaceList(used,(list)(llList2Integer(used,i) - 1),i,i); } } } }
Part Two: Slave script.
This part can be a bit tricky. Since it uses its name to decide when its supposed to do the work, it must be named properly. make 20 of these, named "t 0", "t 1", "t 2", ect. until you reach "t 19". Heres the code:
default { link_message(integer s_n,integer num, string str, key id){ if("t " + (string)num == llGetScriptName()){ llEmail((string)id + "@lsl.secondlife.com",llGetObjectDesc(),str); } } }