|
Badd Haul
Registered User
Join date: 17 Sep 2006
Posts: 5
|
11-09-2006 03:13
I have played with, and figured out how to make my script listen to owner and others. I have even figured out how to make it listen to a different channle. what I want is to have the channel (/3) and a sub channel..if that is what it is? (/3 color)?
I have items that require this functionality, but can't look at the scripts to figure out how they did it. I have one that uses the command "/4 dancer command". I am just trying to figure out how to get that second part into my own scripts so I can do two different things with my script.
If anyone could help that would be greatl, I do better with examples...thanks!
|
|
Anti Antonelli
Deranged Toymaker
Join date: 25 Apr 2006
Posts: 1,091
|
11-09-2006 03:49
Yeah it's not really a subchannel, probably just an if/then branch that checks to see if the first part of the message matches "dancer". You could use llGetSubString. http://lslwiki.com/lslwiki/wakka.php?wakka=llgetsubstringHere's a code fragment to give you the idea. Done quickly off the top of my head, read that link to understand how the start and end index numbers work. listen(integer channel, string name, key id, string message) { if (llGetSubString(message, 0, 6) == "dancer")// check to see if the code word matches { string command = llGetSubString(message, 7, -1); // the rest of the message is the command doStuff(); } }
In the real world you'd want to allow for spaces and differences in capitalization and such, and probably have command declared as a global up top, but that's the basic concept. Perhaps some kind soul will have a more complete solution to offer, in the meantime hope that helps a bit. 
|
|
Newgate Ludd
Out of Chesse Error
Join date: 8 Apr 2005
Posts: 2,103
|
11-09-2006 05:15
The other function you may find useful is llParseString2List. Use it to break input up into distinct 'words' GetParameters(string str) { // Read parameters // Channel=xxx list ldata = llParseString2List(str, ["="], [""]); string command = llList2String(ldata,0); string value = llList2String(ldata,1); if("Channel" == command) { gLockChannel = (integer)value; } else if("Percentage" == command) { percentage = (float)value/100.0; } else if("Locked" == command) { string yesno = llToLower(value); if("yes" == yesno) Locked = TRUE; else if("no" == yesno)Locked = FALSE; } }
|
|
Anti Antonelli
Deranged Toymaker
Join date: 25 Apr 2006
Posts: 1,091
|
11-09-2006 15:56
Unsurprisingly, Mr. Ludd came up with a MUCH better example than mine for your purpose. So yeah, listen to him. 
|