Nexeus Fatale
DJ Nexeus
Join date: 28 Aug 2004
Posts: 128
|
07-04-2005 18:26
So I'm trying to make a script that follows a few command prefixes (like /song next or /song prev). But I'm not sure how these commands work (as in how to do them). Looking at some other scripts that have done these before, I see you have to set a list that has the command prefix, but what about the rest of the message?
So basically, how do I mage a /prefix command work?
_____________________
Website: www.nexeusfatale.com [nf_d]: nfd.nexeusfatale.com
|
Burke Prefect
Cafe Owner, Superhero
Join date: 29 Oct 2004
Posts: 2,785
|
07-04-2005 18:31
the '/' or '!' is just part of the instruction. I don't think any scripts actually filter for that. Now. /xxx denotes a subchannel. don't put any numbers in the / command.
My stuff, when I need a Channel 0 command uses a '!' prefix. like !fly or !s (num).
|
Jillian Callahan
Rotary-winged Neko Girl
Join date: 24 Jun 2004
Posts: 3,766
|
07-04-2005 18:48
It's just parsing. llGetSubString() and llSubStringIndex() are useful here. Here's a quick example: default { state_entry() { llListen(0, "", llGetOwner(), ""); // Meh, don't do this for real if you can help it. } listen(integer chan, string name, key id, string msg) { msg = llToLower(msg); //doing this lets the user mix-n-match case. if( llGetSubString(msg, 0, 6) == "/speed ") // From the start(0) to the 6th position { string cmd = llGetSubString(msg, 7, -1); // From the 7th position to the end if( cmd == "full" ) { // set speed to full } else if( cmd == "half" ) { // set speed to half } } else if ( llGetSubString(msg, 0, 6) == "/color ") { vector col = (vector)llGetSubString(msg, 7, -1); } } } Note that I've not compiled this. Just an example. 
|
Nexeus Fatale
DJ Nexeus
Join date: 28 Aug 2004
Posts: 128
|
07-05-2005 12:43
okay this does help... although the script I'm thinking of... IS going to probabbly 'cause a ton of lag (because of listening on channel 0). Regardless, I get the point!  Thanks, this helps me soo much!! I'll update to tell you guys what I've done/how
_____________________
Website: www.nexeusfatale.com [nf_d]: nfd.nexeusfatale.com
|
Eloise Pasteur
Curious Individual
Join date: 14 Jul 2004
Posts: 1,952
|
07-05-2005 18:59
Unless it absolutely, definitely, always MUST listen on channel 0 can I suggest another channel. /9 is a nice one (easy to type and remember for people) and there are other nice numbers (someone I know uses their phone number as their personal chat to script channel, they're used to typing the numbers in after all!).
There are times that channel 0 must be used, but generally if you can get away without it I would.
|