These forums are CLOSED. Please visit the new forums HERE
Confused about sensors o.O |
|
|
Thanos Taurog
Registered User
Join date: 21 Apr 2007
Posts: 6
|
11-25-2007 12:26
I have been trying to find a sensor and greet scipt for a long time, the kind you see in greeter bots. I paid over 5000L for one recently but to no avail does it even work. I tried the freebie scripts to see if I could change them but the sensors get more and more confuseing. I am very new to this scripting and I have slowly been learnig and the key word is sssslllllllllloooooowwwwllly been teaching myself. If someone could help me and tell me where I went wrong it would be greatly appreciated. : )
|
|
Zena Juran
Registered User
Join date: 21 Jul 2007
Posts: 473
|
11-25-2007 12:33
What's got you confused Thamos: the sensor part or the greeting part?
![]() |
|
Thanos Taurog
Registered User
Join date: 21 Apr 2007
Posts: 6
|
Still confused
11-25-2007 13:15
I have tried the sensor part with
state_entry() { llSensorRepeat( "", "", AGENT, range, TWO_PI, rate ); } on_rez(integer start_params) { llResetScript(); } sensor( integer number_detected ) I have tried to use this with a float and cant get the return on it. I have tried to use several different scripts by changeing the variables in them and have made it alot more confuseing for myself. I am new to all this and still not totally confident in starting from scratch. Is there a better site to explain floats. I am trying to have it float in a certain radius and greet an avatar. I am just not sure on what you use to change the hiegth at wich the float is. I am sure my neighbors are getting tired of me sending prim squares all over there land as I try to figure this all out.Here is an example of what a mess I have made of this. X D. float d=0.25; float step = 0.2; vector pos; float x=0; vector bobthrust; list gPeople = []; vector gStartPos = <0,0,0>; integer gHop = 30; integer gDirection = 1; integer move() { vector pos = llGetPos(); vector targetpos = pos + <gHop*gDirection,0,0>; targetpos.z = llGround(targetpos - pos) + 42; if(targetpos.x >= 250 || targetpos.x <= 0) { targetpos.x = pos.x; targetpos.y += 30; if(gDirection == 1) gDirection = -1; else if(gDirection == -1) gDirection = 1; } if(targetpos.y >= 250) { integer i; vector pos = llGetPos(); vector targetpos = <pos.x,pos.y,400>; while (llVecDist(llGetPos(), targetpos) > 0.001) llSetPos(targetpos); targetpos = gStartPos; while (llVecDist(llGetPos(), targetpos) > 0.001) llSetPos(targetpos); llSay(llGetStartParameter(),"robot ready" ;return FALSE; } while (llVecDist(llGetPos(), targetpos) > 0.001) llSetPos(targetpos); return TRUE; } default { on_rez(integer param) { llListen(param,"",NULL_KEY,"" ;} listen(integer channel, string name, key id, string message) { if(llGetOwnerKey(id) == llGetOwner()) { if(message == "start" ![]() { gStartPos = llGetPos(); vector targetpos = <gHop,gHop,400>; while (llVecDist(llGetPos(), targetpos) > 0.001) llSetPos(targetpos); vector pos = llGetPos(); targetpos = <pos.x,pos.y,llGround(ZERO_VECTOR)+42>; while (llVecDist(llGetPos(), targetpos) > 0.001) llSetPos(targetpos); llSensor("",NULL_KEY,AGENT,96,PI); } else if(message == "robotdie" ![]() { integer i; integer count = llGetListLength(gPeople); integer chan = llGetStartParameter(); for(i=0;i<count;i+=2) { llSay(chan,"sensor:"+llList2String(gPeople,i)+":"+llList2String(gPeople,i+1)); llSleep(0.7); } llSay(chan,"robot returning home" ;llSleep(0.5); llDie(); } } } sensor(integer num) { integer i; for(i=0;i<num;++i) { integer pos = llListFindList(gPeople,[llDetectedName(i)]); if(pos == -1) { gPeople += [llDetectedName(i),llDetectedPos(i)]; } } if(move())llSensor("",NULL_KEY,AGENT,96,PI); } no_sensor() { if(move())llSensor("",NULL_KEY,AGENT,96,PI); { state_entry() } llSetBuoyancy(1.0); llSetTimerEvent(0.5); llTargetOmega(<0,0,0.5>,1,1); pos=llGetPos(); llSetStatus(STATUS_PHANTOM , TRUE); llSetStatus(STATUS_PHYSICS , TRUE); } timer() { x+=step; bobthrust = <0,0,llCos(x)*d>; llMoveToTarget(pos+bobthrust,0. ; } } |
|
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
|
11-26-2007 00:30
ok first, for angle 2Pi is too big, you only need pi... why? because the angle is from the center of the sensor cone, not across the cone, so angle is actually only HALF of the cone size... pi being half of a full circle which gets doubled for the opposing direction, becoming 2pi and a whole circle
\/ <-- what you were expecting |/ <-- what is actually being described \|/ <- what's actually being used the second thing is num_detected... you don't place a number there, this is just a holder for the number of things found by the sensor. it will ALWAYS be an integer, because it can only sense whole things =) I make mine read CODE
which looks at each thing it senses, in reverse order, using it's index in the various dected functions to avoid problems with sensing things over other peoples land, check the llOverMyLand function, if true, keep going, if false, do nothing. hopefully those will help you get started... if you haven't already found them the 3 popular wikis for LSL are http://wiki.secondlife.com/wiki/LSL_Portal _____________________
|
| . "Cat-Like Typing Detected" | . This post may contain errors in logic, spelling, and | . grammar known to the SL populace to cause confusion | | - Please Use PHP tags when posting scripts/code, Thanks. | - Can't See PHP or URL Tags Correctly? Check Out This Link... | - |
|
Haravikk Mistral
Registered User
Join date: 8 Oct 2005
Posts: 2,482
|
11-26-2007 04:02
Correct me if I'm wrong but:
llSensorRepeat( "", "", AGENT, range, TWO_PI, rate ); Should be: llSensorRepeat( "", NULL_KEY, AGENT, range, TWO_PI, rate ); Even if they're the same it's good practice to use NULL_KEY in case keys change in future =) _____________________
Computer (Mac Pro):
2 x Quad Core 3.2ghz Xeon 10gb DDR2 800mhz FB-DIMMS 4 x 750gb, 32mb cache hard-drives (RAID-0/striped) NVidia GeForce 8800GT (512mb) |
|
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
|
11-26-2007 04:33
well using "" instead of null key does save space and time, since null key is actually a 36 character string.... I cringe when I see people use it in link messages... it's like tacking an extra 36bytes of data (more actually) onto every message or call
_____________________
|
| . "Cat-Like Typing Detected" | . This post may contain errors in logic, spelling, and | . grammar known to the SL populace to cause confusion | | - Please Use PHP tags when posting scripts/code, Thanks. | - Can't See PHP or URL Tags Correctly? Check Out This Link... | - |
|
Thanos Taurog
Registered User
Join date: 21 Apr 2007
Posts: 6
|
Thank you for the help
11-26-2007 11:30
I will give that a try and see if I can make it work.Thanks again to everyone that replied. =)
|
|
Tyken Hightower
Automagical
Join date: 15 Feb 2006
Posts: 472
|
11-26-2007 12:34
There are times when NULL_KEY is important, however.
When checking to see if no one is sitting on your prim's sit target in a changed event, you cannot use if (llAvatarOnSitTarget() == "" , because "" != NULL_KEY, and the function returns NULL_KEY specifically when the sit target is empty._____________________
![]() |
|
Thanos Taurog
Registered User
Join date: 21 Apr 2007
Posts: 6
|
I think I made it worse = P
11-26-2007 13:11
OK I have changed my tactics a little and now I am makeing a robot that follows a person and when they move it points at them at all times. I got the sensors to work and it points and the avatar but when you make the object non-physical it doesnt move in float. I am sure I am missing something. Should I give up and move to something different? Here is the butchered script I have slowly peiced together.
vector offset =<-1.2,0,1>; vector currentoffset =<0,0,0>; float xshift =.2; float yshift =.25; float bob =2; float shifttime =5; integer timeset=0; float currentxshift =0; float currentyshift =0; float currentyfacing =0; integer currentbob; float bobbing =0; list BobCycle = [0.0, 0.08, 0.12, 0.14, 0.15, 0.14, 0.12, 0.08, 0.0, -0.08, -0.12, -0.14, -0.15, -0.14, -0.12, -0.08]; startup() { vector pos = llGetPos(); llSetStatus(STATUS_ROTATE_Z,TRUE); llSetStatus(STATUS_PHYSICS, TRUE); key id = llGetOwner(); llSensorRemove(); llSensorRepeat("",llGetOwner(),AGENT,200,2*PI,.4); } default { state_entry() { startup(); } on_rez(integer start_param) { startup(); } sensor(integer total_number) { vector pos = llDetectedPos(0); bobbing = llList2Float(BobCycle, currentbob)*bob; llSetTimerEvent(llFrand(shifttime)); currentoffset = <currentxshift, currentyshift, bobbing>; llMoveToTarget(pos+(offset+currentoffset)*llDetectedRot(0),.3); if (currentyshift>=0) { currentyfacing = currentyshift; } else { currentyfacing = currentyshift*-1; } llLookAt(pos+<0,0+(currentyfacing*.33),1+bobbing>, 1 , 2); currentbob = currentbob +1; if (currentbob == 16) { currentbob = 0; } if(timeset==0) { timeset = 1; llSetTimerEvent(((llFrand(shifttime)+llFrand(shifttime)+llFrand(shifttime))/3)*2); } llSensorRemove(); llSensorRepeat("", "", AGENT, 25, TWO_PI, 0.5); } sensor(integer num_detected) { vector target = llDetectedPos(0); float strength = llGetMass()/2; float damping = strength/10.1; llLookAt(target, strength, damping); } no_sensor() { llSensorRemove(); } timer() { timeset = 0; currentyshift = llFrand(yshift*2)-yshift; currentxshift = llFrand(xshift*2)-xshift; } } |
|
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
|
11-26-2007 19:04
There are times when NULL_KEY is important, however. When checking to see if no one is sitting on your prim's sit target in a changed event, you cannot use if (llAvatarOnSitTarget() == "" , because "" != NULL_KEY, and the function returns NULL_KEY specifically when the sit target is empty.no but why not just use if(llAvatarOnSitTarget()){ ?? since nullkey will parse as invalid key, it'll come back false when you need it to, and it makes sense visually _____________________
|
| . "Cat-Like Typing Detected" | . This post may contain errors in logic, spelling, and | . grammar known to the SL populace to cause confusion | | - Please Use PHP tags when posting scripts/code, Thanks. | - Can't See PHP or URL Tags Correctly? Check Out This Link... | - |
|
jefferey Heart
Registered User
Join date: 25 Jan 2006
Posts: 45
|
llSensorRepeat
12-06-2007 14:42
llSensorRepeat has been failing alot lately.
Has anyone else noticed that this is not working right? Dropped several example scripts into items and most seem to BREAK and not detect Avatars. Any others having issues with it? |
|
Jesse Barnett
500,000 scoville units
Join date: 21 May 2006
Posts: 4,160
|
12-06-2007 16:04
OK I have changed my tactics a little and now I am makeing a robot that follows a person and when they move it points at them at all times. I got the sensors to work and it points and the avatar but when you make the object non-physical it doesnt move in float. I am sure I am missing something. Should I give up and move to something different? Here is the butchered script I have slowly peiced together. Never give up! The 1st big script you make is always a bitch. When I made my teleport hud I think it took me about a month and a half to get it debugged and working correctly. It only gets better after you get this one behind you.(not easier, just better )Right off the bat I notice 2 sensor events. You can't do that. Also curious as to why you are calling llFrand 3 times in a row to generate the timer float? llSetTimerEvent(((llFrand(shifttime)+llFrand(shift time)+llFrand(shifttime))/3)*2); _____________________
I (who is a she not a he) reserve the right to exercise selective comprehension of the OP's question at anytime.
I am still around, just no longer here. See you across the aisle. Hope LL burns in hell for archiving this forum |
|
Jesse Barnett
500,000 scoville units
Join date: 21 May 2006
Posts: 4,160
|
12-06-2007 16:07
llSensorRepeat has been failing alot lately. Has anyone else noticed that this is not working right? Dropped several example scripts into items and most seem to BREAK and not detect Avatars. Any others having issues with it? Was just playing with sensor repeat when I was finishing up the 3D radar for the library. Didn't have any problems as of about 2 weeks ago. Have showed it to a couple of people since then with no problems. You might want to check jira to see if something was filed on it. _____________________
I (who is a she not a he) reserve the right to exercise selective comprehension of the OP's question at anytime.
I am still around, just no longer here. See you across the aisle. Hope LL burns in hell for archiving this forum |
|
Thanos Taurog
Registered User
Join date: 21 Apr 2007
Posts: 6
|
Thank you for all the help
12-06-2007 18:40
I am still working on it peice by peice, just want to thank all the people with the great ideas and information. I have started a new script and so far it works the sensor is a tough one to learn = ). I just want to say thank you again to everyone with the help.
|