Jump to content

Multiple listen script?


LouiseDeBlois
 Share

You are about to reply to a thread that has been inactive for 3619 days.

Please take a moment to consider if this thread is worth bumping.

Recommended Posts

Long story short, I am looking for a script which will only work when 4 words are being said. 

 

The concept it, 4 keys, which are needed to open a door/box.

 

Each key should say a word, and the door will only open when all 4 keys are in the listen radius, so the 4 words are needed for the door to open, 3 words would do nothing, it HAS to be 4 words to make the door open

Link to comment
Share on other sites

This should be pretty trivial. In default state entry call llListen() 4 times, first time with word 1, second time with word 2, etc. Also define a global variable, let's say integer lock = 0;

In the listen event your conditions would be: If word 1 is detected, increment lock by one  but only if lock was zero prior to detection. If word 2 is detected, increment lock by one but only if it was 1 before and so on. When the lock value is 4 all words have been spoken in proper order so the door opens.

There is a little more to it. The lock value is basically the number of the next expected word, so if the word 3 was spoken when the lock is 1 (word 2 expected) you'd need to reset lock to 0

That's all there is to it but you'd have to write the code implementing the above yourself :)

Link to comment
Share on other sites

Though you ARE talking about a listening script, it might be possible to make a similar script using the UUIDs of the keys. The script could have a list of the four keys' UUIDs and an integer - say, keys_still_needed_count = 4 - and run a sensor every ~10 seconds or so.

When any keys are in range during a sensor scan, the script would check them against its list and decrease the count by the number of keys it finds.

Then, if the count ever drops to 0, you know you've got all the keys in the range.

This option would probably take some more time to implement than listening for phrases, but it would be more secure, since UUIDs can't be "faked" like messages.

Link to comment
Share on other sites

if this is for a door / box, you could use a touch event, since

Someone will be around to do the opening...the sensor would work

on touch, and scan the area for UUID's..you wouldn't need to

listen for objects.?

                           //a list of your key UUID's

 list keys = ["8e611fd9-5766-5c9a-a688-0db115cb8ebc", 
              "26a0a76c-f7b6-c62d-c571-2f9f156bfc0e",
              "38f40c0f-1bad-5834-ceef-feb7b8f166b1",
              "38f40c0f-1bad-5834-ceef-feb7b8f166b2"];
default
{
    state_entry()
    {
       
    }

    touch_start(integer total_number)
    {  
       llSensor( "", NULL_KEY, ( AGENT_BY_LEGACY_NAME | PASSIVE | ACTIVE ), 3.0, PI );
          
    }
     sensor( integer detected )
    {
        integer lock = 0;
        while(detected--)
        {         
           key dKey =  llDetectedKey(detected);           
            if (~llListFindList(keys,[(string)dKey]))
            {
              ++lock;
              llOwnerSay("Lock at: " + (string)lock);
            }                 
        }
        if(lock == 4)
        {
            llOwnerSay("OPEN"); // send open command here
        }
    }
     
}

Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 3619 days.

Please take a moment to consider if this thread is worth bumping.

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
 Share

×
×
  • Create New...