LouiseDeBlois Posted February 26, 2013 Share Posted February 26, 2013 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 More sharing options...
Ela Talaj Posted February 26, 2013 Share Posted February 26, 2013 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 More sharing options...
Akninirith Posted February 27, 2013 Share Posted February 27, 2013 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 More sharing options...
Xiija Posted February 27, 2013 Share Posted February 27, 2013 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 More sharing options...
LouiseDeBlois Posted March 1, 2013 Author Share Posted March 1, 2013 Thanks for all your replies, to Xiija, will this also work if the items which are needed to unlock the door, were not on the player? As in... the place them in world in the doors locks etc? (In short, will they work when not attached to the player) Link to comment Share on other sites More sharing options...
Xiija Posted March 2, 2013 Share Posted March 2, 2013 yes. they will work when not attached, the sensor will pick them up in world Link to comment Share on other sites More sharing options...
Innula Zenovka Posted March 2, 2013 Share Posted March 2, 2013 Since the UUIDs of the items are going to change each time they're rezzed, scanning for an object by UUID is maybe not a very good idea. Link to comment Share on other sites More sharing options...
Rolig Loon Posted March 2, 2013 Share Posted March 2, 2013 :smileywink: Link to comment Share on other sites More sharing options...
Recommended Posts
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