An easier way to redirect multiple channels
|
|
MadamG Zagato
means business
Join date: 17 Sep 2005
Posts: 1,402
|
03-09-2006 05:09
Is there an easier way to do a channel redirect other that writing out each command? I want any command that is said on channel 2 to redirect to channel10. Something like this integer input = 2; // channel that switch is sending on default { state_entry() { llListen(input,"","",""); } listen(integer channel, string name, key id, string message) { if(message == "eat more cherry pie") { llSay(10, "eat more cherry pie"); } if(message == "eat more apple pie") { llSay(10, "eat more apple pie"); } //...and so on and so forth...
See I do not want to have to write out a separate if statement for each flavor of pie if I do not have to. If there is a way to just redirect any command on channel 2 to channel 10 it would be nice. Thanks
|
|
Ordinal Malaprop
really very ordinary
Join date: 9 Sep 2005
Posts: 4,607
|
03-09-2006 05:11
Why not just "llSay(10, message);"?
|
|
MadamG Zagato
means business
Join date: 17 Sep 2005
Posts: 1,402
|
03-09-2006 05:22
I am adding permissions to a big set of scripts LOL. They are in multiple prims which are linked, and some not. They all were listening on channel 2, so I want to keep using /2 for my commands,but I have added a user list via notecard. So if I want to keep from adding the user list script and notecard to each prim... I would have to have this script in 1 prim alongside the notecard it needs to read for the users list. So now, if I say /2 eat more apple pie All of those other prims will hear /2 eat more apple pie AND the users list will work in that 1 prim. If the person is not on the users list, then the commands will not respond. (follow me? I'm a little drowsy, but I think I explained it correctly. LOL)
|
|
Yumi Murakami
DoIt!AttachTheEarOfACat!
Join date: 27 Sep 2005
Posts: 6,860
|
03-09-2006 05:48
From: MadamG Zagato So if I want to keep from adding the user list script and notecard to each prim... I would have to have this script in 1 prim alongside the notecard it needs to read for the users list. All of those other prims will hear /2 eat more apple pie AND the users list will work in that 1 prim. If the person is not on the users list, then the commands will not respond.
integer input = 2; // channel that switch is sending on default { state_entry() { llListen(input,"","",""); } listen(integer channel, string name, key id, string message) { if(userHasPermission(id)) { // Might as well use a negative hard to guess channel llSay(-4938932,message); // You mentioned some were linked and some were not.. ones that // WERE linked won't hear the same object's Say, so.. llMessageLinked(LINK_SET,0,message,NULL_KEY); } }
Of course you'd have to make sure that the unlinked parts of the object were only listening to the part that does the permissions ( ie, llListen(-4938932,"",keyOfThePrimWithThePermissionStuffInIt,""  ; )
|
|
MadamG Zagato
means business
Join date: 17 Sep 2005
Posts: 1,402
|
03-09-2006 05:58
You rock Yumi!!! Thanks a Mad-illion!
|
|
MadamG Zagato
means business
Join date: 17 Sep 2005
Posts: 1,402
|
03-09-2006 08:28
The channels are working... but when I add my name or a friends name to the list, it says they are not on the list. So I reveresed the if statement and then it worked. So I took my name and friends name off the list, then it STILL let the commands go through. So I put the if statement BACK to normal as shown below... and our names are not on the list, and it still let's the commands go through. The script resets everytime the Allowed user list changes, so I know it's reading it. Why isn't it working? list users = []; integer lineNum = 0; integer input = 2; // channel that switch is sending on default { dataserver(key id, string data) { if (data != EOF) { users += [data]; lineNum++; //llGetNotecardLine("Allowed Users", lineNum); } } state_entry() { llListen(globalinput,"","",""); llGetNotecardLine("Allowed Users", lineNum); llWhisper(0, "Ready!"); } changed(integer change) { if (change & CHANGED_INVENTORY); //Check to see if there have been any notecard changes { llWhisper(0, "Reading Allowed User List..."); llResetScript(); } } listen(integer channel, string name, key id, string message) { // See if this person's name is on the list string userName = llDetectedName(0); if (llListFindList(users, [userName]) != -1) { // Might as well use a negative hard to guess channel llSay(747,message); // You mentioned some were linked and some were not.. ones that // WERE linked won't hear the same object's Say, so.. llMessageLinked(LINK_SET,0,message,NULL_KEY); } else { llWhisper(0, "Hey! You're not on the list!"); } }}
|
|
MadamG Zagato
means business
Join date: 17 Sep 2005
Posts: 1,402
|
03-09-2006 14:54
The channels are working... but when I add my name or a friends name to the list, it says they are not on the list. So I reveresed the if statement and then it worked. So I took my name and friends name off the list, then it STILL let the commands go through. So I put the if statement BACK to normal as shown below... and our names are not on the list, and it still let's the commands go through. The script resets everytime the Allowed user list changes, so I know it's reading it. Why isn't it working? list users = []; integer lineNum = 0; integer input = 2; // channel that switch is sending on default { dataserver(key id, string data) { if (data != EOF) { users += [data]; lineNum++; //llGetNotecardLine("Allowed Users", lineNum); } } state_entry() { llListen(globalinput,"","",""); llGetNotecardLine("Allowed Users", lineNum); llWhisper(0, "Ready!"); } changed(integer change) { if (change & CHANGED_INVENTORY); //Check to see if there have been any notecard changes { llWhisper(0, "Reading Allowed User List..."); llResetScript(); } } listen(integer channel, string name, key id, string message) { // See if this person's name is on the list string userName = llDetectedName(0); if (llListFindList(users, [userName]) != -1) { // Might as well use a negative hard to guess channel llSay(747,message); // You mentioned some were linked and some were not.. ones that // WERE linked won't hear the same object's Say, so.. llMessageLinked(LINK_SET,0,message,NULL_KEY); } else { llWhisper(0, "Hey! You're not on the list!"); } }}
|
|
Yumi Murakami
DoIt!AttachTheEarOfACat!
Join date: 27 Sep 2005
Posts: 6,860
|
03-09-2006 15:34
AFAIK listen() doesn't load llDetectedName(). list users = []; integer lineNum = 0; integer input = 2; // channel that switch is sending on default { dataserver(key id, string data) { if (data != EOF) { users += [llToLower(data)]; // YUMI: Be nice, be case insensitive :) lineNum++; // YUMI: Presume you mean to only read the 1st line of notecard //llGetNotecardLine("Allowed Users", lineNum); } } state_entry() { llListen(globalinput,"","",""); llGetNotecardLine("Allowed Users", lineNum); llWhisper(0, "Ready!"); }
changed(integer change) { if (change & CHANGED_INVENTORY); //Check to see if there have been any notecard changes { llWhisper(0, "Reading Allowed User List..."); llResetScript(); } } listen(integer channel, string name, key id, string message) { // See if this person's name is on the list if (llListFindList(users, [llToLower(name)]) != -1) { ....
[/QUOTE]
|
|
MadamG Zagato
means business
Join date: 17 Sep 2005
Posts: 1,402
|
03-10-2006 10:01
Check this out... it worked when I applied it to my menu: touch_start(integer total_number) { string userName = llDetectedName(0); if (llListFindList(users, [llToLower(userName)]) != -1) { //llWhisper(0, "Test " + llDetectedName(0)); doMenu(llDetectedKey(0),"MYMENU"); } else { llWhisper(0, "Hey, " + llDetectedName(0) + " you are not on the list!"); } } But everytime I tried it with listen commands, it just wouldn't work! So I wrote out llDetectedName to see what each of the 2 scripts would say...and the listen commands weren't detecting any name. So I looked it up on Wiki, and found this: Note: The llDetected* functions will only return a meaningful value in the collision(), collision_start(), collision_end(), sensor(), touch(), touch_start(), or touch_end() events. I was pulling out my hair up until I found that. Listen is not on that list  So I thought I could try using a sensor so that whenever /2 is spoken, the script can do a sensor and see who is around and THEN check to see if they are on the list. If they are, then do whatever. Can you help me with that? I started below, but I do not know how to get the sensor to also check the list in it's loop: listen(integer channel, string name, key id, string message) { if(channel == 2) { llSensor("", NULL_KEY, AGENT, 10, PI); string userName = llDetectedName(0); if (llListFindList(users, [llToLower(userName)]) != -1) { llSay(10,message); //llMessageLinked(LINK_SET,0,message,NULL_KEY); } else { llWhisper(0, "Hey, " + llDetectedName(0) + " you are not on the list!"); } } } //Grabbed this from Wiki... not sure how to incorporate the 'if (llListFindList(users, [llToLower(userName)]) != -1)' into this sensor(integer total_number) { llWhisper( 0, (string)total_number + " avatars detected" ); integer i; for ( i = 0; i < total_number; i++ ) { llWhisper( 0, "Hello " + llDetectedName(i) ); } }
Then again, if it checks to see who's around instead of who is actually speaking the command, it would just let anyone who was NOT on the list say commands if the owner or other person on the access list was standing there right? Oh I am so confused!! 
|
|
Ziggy Puff
Registered User
Join date: 15 Jul 2005
Posts: 1,143
|
03-10-2006 10:09
From: someone I was pulling out my hair up until I found that. Listen is not on that list That's what Yumi said: From: someone AFAIK listen() doesn't load llDetectedName(). Why do you need to run a sensor to find the person's name? The listen handler already gives you the name of the person/object who just spoke: listen(integer channel, string name, key id, string message) So you can use that name directly, you don't have to run a sensor and use llDetectedName(0), or anything else. Again, look at the script Yumi posted, you'll see that 'name' is used directly in the listen handler, and that's all you need to do. Again, copying from Yumi's script: listen(integer channel, string name, key id, string message) { // See if this person's name is on the list if (llListFindList(users, [llToLower(name)]) != -1) { ....
|
|
MadamG Zagato
means business
Join date: 17 Sep 2005
Posts: 1,402
|
03-10-2006 10:17
There you go again Ziggy, saving my hair!!! I was confusing the string UserName with the variable name in the listen commad and I thought it was a typo so I changed it (doh!) K, Now I'm gonna go get in the shower and treat myself to some herbal essence shampoo! Maybe even conditioner too...
|