Jump to content

chat die problem


Avex Axon

Recommended Posts

Hi Guys......had great response for a dice script I was trying to throw together, so have popped back in case anyone can help suggest methods for a particular use of a chat die script. As I said in the other thread, I'm new to scripting, and have tried taking the following apart to get to what I need with little success....the script I am using is the basic free one as below:

 

//This is to delete objects by chat. Place this script in an object you wish to have self delete. Say or Shout (hold ctrl while hitting enter) the word delete, and your object will self delete.

//remove the 123 to be able to use this script. Just delete the numbers and make sure running in the lower left is checked and hit save.

//Make sure you save a copy of this script and all others in this package before removing the 123.


default
{
    state_entry()
    {
        llListen(0,"",llGetOwner(),"");
    }

    listen(integer channel, string name, key id, string m)
    {
        if (m=="delete")llDie();
    }
}

 

What I am trying to do, is place it in an object whereby the command word (in the above it is "delete", can be spoken as part of a sentence and still have the same effect. I've found that if I change "delete" to "looks closely at the box and wonders where the delete button is", and then say the exact sentence in open chat, it does indeed delete. What I'm trying to get however, is a more natural way of having a one word command, which can be used ANYWHERE in any sentence, rather than as a one word command

It may be that it isn't possible within the parameters, and if someone can tell me that, I can stop trying to get it working...and if someone can tell me HOW it can be done, I can stop working and buold an effigy to them!!

Thanks in advance

Avex

Link to comment
Share on other sites

You're looking for a way to parse a chat message and recognize a specific key word in it.  You can do that "easily" by coding something like

 

listen (integer channel, string name, key id, string msg){    integer idx = llSubStringIndex(msg, "delete");    if (~idx)      //that is, if (idx >= 0)

{

 llOwnerSay("You said \"delete\"!"); llDie();
}}

 I say "easily" with caution because this will be a rather slow process, adding quite a bit to sim lag because it will have to listen to every single thing that anyone says within chat range, parse it, and test for the presence of your key word.  Even if you filter your llListen to hear only your own chat, that''s an intensive process.  If you really want to do this, I'd recommend keeping the listen handle live for only a short time.

 

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...