If an object is detected, then use this channel
|
|
Thorne Kaiser
Nice Guy
Join date: 29 Nov 2005
Posts: 132
|
03-26-2006 15:21
Is it possible to do this: If the object named "square" is within 5m, then use channel 4 otherwise if it is not detected then use channel 5? Thanks for any help 
|
|
Ares Desmoulins
Registered User
Join date: 13 Sep 2005
Posts: 22
|
03-26-2006 16:04
You can use llListenControl to flip between two listens. Integer square = llListen(4, "Square",NULL_KEY,""  ; Integer nosquare = llListen(5,"Square",NULL_KEY,""  ; Default { State_entry() { llListenControl(nosquare, TRUE); llListenControl(square, FALSE); llSensorRepeat("Square",NULL_KEY,SCRIPTED,5,TWO_PI,1); } Sensor(integer sensed) { llListenControl(square, TRUE); llListenControl(nosquare, FALSE); } No_sensor() { llListenControl(square, FALSE); llListenControl(nosquare, TRUE); } } When this senses whatever you define in your sensor it will turn off the chan 5 listen and activate the chan 4 listen. When the sensor cannot find whatever your sensing for, it will flip off the chan 4 and turn on the chan 5. Note, syntax may bee off, captials etc....I'm on my cell phone browser and it likes to autocapitalize =P
|
|
Thorne Kaiser
Nice Guy
Join date: 29 Nov 2005
Posts: 132
|
03-26-2006 16:08
Thanks for replying!!!!
Not sure I understand where I am checking to see if the actual Object "Square" is within 5m though.
|
|
Exile Loudon
Aspiring Scripter
Join date: 10 Dec 2005
Posts: 122
|
03-26-2006 16:57
Integer square = llListen(4, "",NULL_KEY,"");
Integer nosquare = llListen(5,"",NULL_KEY,"");
At this part of the script, you'd want to put the key from the square where "NULL_KEY" is. Just use: default { touch_start(integer num_detected) { key getkey = llGetKey(); llOwnerSay("My key is: " + getkey); } }
This will say the objects key. The key changes each time it is rezzed.
|
|
Ziggy Puff
Registered User
Join date: 15 Jul 2005
Posts: 1,143
|
03-26-2006 17:30
From: someone llSensorRepeat(desired sensor params here); That line would set up a periodic sensor sweep. That's where you need to tell it the name of the object you're scanning for, the range to scan in, the frequency of the scan, and other parameters. The Wiki will tell you how to set up the parameters for that function.
|
|
Ares Desmoulins
Registered User
Join date: 13 Sep 2005
Posts: 22
|
03-26-2006 19:14
Exactly ziggy, its just a horrible pain to try and type the whole sensor line on my phone lol
With the listen, if its going to be an object that is ever re-rezzed, leave it as NULL_KEY or the listen will fail due to a new key being issued anytime something is rezzed =)
The original script in my first post has been edited to accomodate your requests. It will work assuming the following criteria: -The object "Square" is named exactly that, the capitalization IS important -The object "Square" has at least one script in it, any script, it doesn't matter what
|
|
Thorne Kaiser
Nice Guy
Join date: 29 Nov 2005
Posts: 132
|
03-26-2006 19:27
So if I am giving this object to others, I will not be able to make this script no modify since I have to put a key in every time it is rezzed? There's no way to just use the objects name?
|
|
Ares Desmoulins
Registered User
Join date: 13 Sep 2005
Posts: 22
|
03-26-2006 19:32
Leave it as is, do not assign a specific key. The syntax I edited in the original will ignore keys and sense for just items named Square.
|
|
Thorne Kaiser
Nice Guy
Join date: 29 Nov 2005
Posts: 132
|
03-26-2006 21:37
I keep getting a syntax error at llListen on the first AND the 2nd when I comment the first out: integer square = llListen(4, "square",NULL_KEY,""); integer nosquare = llListen(5,"square",NULL_KEY,"");
|
|
Ralek Queso
Registered User
Join date: 3 Feb 2005
Posts: 32
|
03-26-2006 22:05
From: Thorne Kaiser I keep getting a syntax error at llListen on the first AND the 2nd when I comment the first out: integer square = llListen(4, "square",NULL_KEY,""); integer nosquare = llListen(5,"square",NULL_KEY,"");
You cannot use functions on global declarations. Declare them as integers up there and then assign the values to them on state_entry.
|
|
Thorne Kaiser
Nice Guy
Join date: 29 Nov 2005
Posts: 132
|
03-27-2006 10:21
OK, Got it! Thanks for that! Now I have just implemented it and do not seem to be getting any response as if it were not listening. integer square; integer square;
default { state_entry() { integer square = llListen(4, "Square",NULL_KEY,""); integer nosquare = llListen(5,"Square",NULL_KEY,""); llListenControl(nosquare, TRUE); llListenControl(square, FALSE); llSensorRepeat("Square",NULL_KEY,SCRIPTED,8,TWO_PI,10); } sensor(integer sensed) { llListenControl(square, TRUE); llListenControl(nosquare, FALSE); llOwnerSay("The square is near"); } no_sensor() { llListenControl(square, FALSE); llListenControl(nosquare, TRUE); llOwnerSay("The square is not near"); } listen(integer channel, string name, key id, string message) { if(message == "hello") { llWhisper(0,"Hello! I heard you."); } } }
Also is it possible to have it only check when it is rezzed whether or not the Square is near instead of having it create lag by checking avery few seconds etc?
|
|
Ziggy Puff
Registered User
Join date: 15 Jul 2005
Posts: 1,143
|
03-27-2006 10:55
llSensorRepeat("Square",NULL_KEY,SCRIPTED,8,TWO_PI,10); That acts strangely sometimes, or rather, I don't fully understand how it works. So I usually use: llSensorRepeat("Square",NULL_KEY,SCRIPTED|ACTIVE|PASSIVE,8,TWO_PI,10);
... or something like that. Throw in a bunch of flags, and you'll probably find your object  From: someone Also is it possible to have it only check when it is rezzed whether or not the Square is near instead of having it create lag by checking avery few seconds etc? That would be llSensor, instead of llSensorRepeat. The syntax is similar, it just doesn't have the last parameter which sets the rate of the scan repetitions. And you'd want to put it in an on_rez event handler, and remove the llSensorRepeat from the state_entry handler. That way you'll make a single sensor scan every time the object is rezzed. Which is probably what you want, if I understood your question correctly.
|
|
Over Sleeper
I Dream in LSL
Join date: 12 Jan 2006
Posts: 141
|
03-27-2006 11:48
No go. That did not work. Seems like it should, but all get get is "The Square is near" every 10 seconds. My commands receive no response. 
|
|
Thorne Kaiser
Nice Guy
Join date: 29 Nov 2005
Posts: 132
|
03-27-2006 11:50
That did not change anything unfortunatley  I tried all the flags listed in the WIKI too. Still nothing different.
|
|
Thorne Kaiser
Nice Guy
Join date: 29 Nov 2005
Posts: 132
|
03-27-2006 12:10
I see the example on the WIKI for llListenControl. I am going to build off of that since it works for me and post what I come up with LOL
|
|
Thorne Kaiser
Nice Guy
Join date: 29 Nov 2005
Posts: 132
|
03-27-2006 13:09
That definitley worked just fine! Thanks for sticking with me!!!
|