Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

3d radar system?

Aniam Ingmann
llOwnage(float pwnage);
Join date: 22 Oct 2005
Posts: 206
11-07-2007 16:02
how would I get started on this?

i'm guessing it'd just be a sensor that when someone came into the range of the sensor it rezzed a small ball that follows an offset that's like their position divided by the ratio of what the size of the radar is to what the size of the area it's checking is... correct?
_____________________
From: someone

Don't worry, Aniam is here!
- Noob
Stephen Zenith
Registered User
Join date: 15 May 2006
Posts: 1,029
11-07-2007 16:05
Basically, yes. Make a sculptie of the sim too, it looks awesome - trust me.

You'll need a script inside the balls that listen for position updates from the main scanner, and messages telling it to die if the av moves out of range.

I should really think about selling the one I already made like this...
_____________________
Jesse Barnett
500,000 scoville units
Join date: 21 May 2006
Posts: 4,160
11-07-2007 16:17
and if you want to have a lot of fun and sacrifice a few brain cells for the benefit of mankind at the same time; if detected pos is > some distance from last pos then it rezzes a new ball. You end up with a 3d track of the avatars in range
_____________________
I (who is a she not a he) reserve the right to exercise selective comprehension of the OP's question at anytime.
From: someone
I am still around, just no longer here. See you across the aisle. Hope LL burns in hell for archiving this forum
Stephen Zenith
Registered User
Join date: 15 May 2006
Posts: 1,029
11-07-2007 16:18
From: Jesse Barnett
and if you want to have a lot of fun and sacrifice a few brain cells for the benefit of mankind at the same time; if detected pos is > some distance from last pos then it rezzes a new ball. You end up with a 3d track of the avatars in range


Even better, make them shrink over time, then die after a certain cutoff.
_____________________
Jesse Barnett
500,000 scoville units
Join date: 21 May 2006
Posts: 4,160
11-07-2007 16:25
And you can also just use particles rezzed at the positions. Set the time they live to the same as your scan frequency (or longer if you want the track). Maybe rotate the colors so that dif av's will show up as dif colors
_____________________
I (who is a she not a he) reserve the right to exercise selective comprehension of the OP's question at anytime.
From: someone
I am still around, just no longer here. See you across the aisle. Hope LL burns in hell for archiving this forum
Aniam Ingmann
llOwnage(float pwnage);
Join date: 22 Oct 2005
Posts: 206
11-07-2007 16:44
Hmm. Interesting. I've pretty much got everything built now in world except for one problem; the sensor repeat just constantly rezzes the scan balls everytime it senses me on it's .2 second loop. How can I have it so it only scans an avatar once and once that avatar is in that range it ignores it and looks for other avatars?
_____________________
From: someone

Don't worry, Aniam is here!
- Noob
Stephen Zenith
Registered User
Join date: 15 May 2006
Posts: 1,029
11-07-2007 16:58
From: Aniam Ingmann
Hmm. Interesting. I've pretty much got everything built now in world except for one problem; the sensor repeat just constantly rezzes the scan balls everytime it senses me on it's .2 second loop. How can I have it so it only scans an avatar once and once that avatar is in that range it ignores it and looks for other avatars?


Ah, and therein lies the fun :)

I keep a list of avs I'm plotting. Every time I get a sensor event, I check in the list for that av. If it's already in there, I update the position and llSay a message to the relevant ball telling it the new position. If it's not in the list, I rez a new ball and tell it the name and position.

You'll also have fun knowing when to delete balls - the way I use is to "timestamp" each av in the list with the last time I saw them, then run a cleanup function to look for avs that haven't been seen in the past x number of seconds (where x > 2 * scan freq).

My scanner can also listen to other objects with scanners, that then send updates via llRegionSay, to give full sim coverage, so killing all av balls not visible immediately after a sensor event would mean some sensed only by a peripheral scanner would constantly rez and die.
_____________________
Katryna Jie
Registered User
Join date: 24 Jun 2007
Posts: 187
11-07-2007 17:21
store already scanned keys in a list, and have it check against the list?? I dunno... i'm still a noob at scripting, but just a thought.
Aniam Ingmann
llOwnage(float pwnage);
Join date: 22 Oct 2005
Posts: 206
11-07-2007 19:40
I'm also having problems getting a scaled offset for the movement of the prims to follow the scaled radar. The radar prim is 1.920 (.960*2) which stands for 1/50th of the size of the radars scanner.. but for some reason this won't work.
From: someone

string avStatus;
string avName;
string avDistance;
key avKey;
integer i;
integer avListen;
integer avListen2;
integer avListen3;
vector getpos;
vector avPos;
vector avDivPos;
vector rPos;
default
{
on_rez(integer sp)
{
llSetText("Finding avatar...",<1,1,1>,1);
}
state_entry()
{
avListen = llListen(-34234,"",NULL_KEY,"";);
avListen2 = llListen(-34235,"",NULL_KEY,"";);
avListen3 = llListen(-34236,"",NULL_KEY,"";);
}
listen(integer c, string n, key id, string msg)
{
if (c == -34236)
{
llSetObjectName(msg);//The Avatar it's tracking
llListenRemove(avListen3);
}
if (c == -34235)
{
llSetObjectDesc(msg);//The Position of the radar
llListenRemove(avListen2);
}
if (c == -34234)
{
avKey = (key)msg;//The Key of the avatar it's tracking
avName = llGetObjectName();
llListenRemove(avListen);
llSensorRepeat(avName,avKey,AGENT,96,PI,.1);
}
}
sensor(integer n)
{
rPos = (vector)llGetObjectDesc();
avPos = llDetectedPos(0);
avDivPos = <avPos.x/50,avPos.y/50,rPos.z>;//doesn't work...
avDistance = (string)llVecDist(rPos,llDetectedPos(i));//maybe i'm //just doing some math wrong?
llSetPos(avDivPos + <0,0,.125>;);
llOwnerSay((string)avDivPos);
llSetText(avName + "[" + avDistance + "]",<1,1,1>,1);
}
no_sensor()
{
llSetText(avName+" is now out of range.",<1,1,1>,1);
llOwnerSay(avName + " is now out of range.";);
llDie();
}
}
_____________________
From: someone

Don't worry, Aniam is here!
- Noob
Aniam Ingmann
llOwnage(float pwnage);
Join date: 22 Oct 2005
Posts: 206
11-08-2007 03:46
Okay... So this is what I've got. The balls pretty much work (they move in a correct ratio) but for some reason they all rez about 3 m away from the radar prim and move correctly. Also, for unknown reasons, the main radar script continually rezzes "Aniam Ingmann" radar balls after every sensor event, even though it's supposed to have written my key into it and ignored all calls for that key...

Here are the scripts, if you can figure out what's wrong, that would be great.

MAIN RADAR SCRIPT
From: someone

string avKey;
string avName;
string getpos;
list avList;
list avTest;
default
{
on_rez(integer sp)
{
llResetScript();
}
state_entry()
{
llListen(0,"",llGetOwner(),"";);
llOwnerSay("Say 'scan' to do a scan for avatars.";);
}
listen(integer c, string n, key id, string msg)
{
if (msg == "scan";)
{
llWhisper(-34240,"die";);
llSensorRepeat("","",AGENT,96,PI,.5);
}

if (msg == "reset";)
{
llRegionSay(-34240,"die";);
llResetScript();
}
}
sensor(integer n)
{
avKey = llDetectedKey(0);
avName = llDetectedName(0);
integer findlist = llListFindList(avList, (list)avKey);
if (findlist = -1)
{
llRezObject("Aniam.RadarBall",llGetPos(),ZERO_VECTOR,ZERO_ROTATION,42);
avList = avList + [avKey];
}
if (findlist != -1)
{
llOwnerSay(llList2String(avList,findlist));
return;
}
}
object_rez(key id)
{
llWhisper(-34234,avKey);
llWhisper(-34235,(string)llGetPos());
llWhisper(-34236,avName);
}
}

RADAR BALL SCRIPT
From: someone

string avStatus;
string avName;
string avDistance;
key avKey;
integer i;
integer avListen;
integer avListen2;
integer avListen3;
vector getpos;
vector avPos;
vector avDivPos;
vector rPos;
default
{
on_rez(integer sp)
{
llResetScript();
}
state_entry()
{
avListen = llListen(-34234,"",NULL_KEY,"";);
avListen2 = llListen(-34235,"",NULL_KEY,"";);
avListen3 = llListen(-34236,"",NULL_KEY,"";);
llListen(-34240,"",NULL_KEY,"";);
llSetText("Finding avatar...",<1,1,1>,1);
llSetObjectDesc(" ";);
llSetObjectName("Aniam.RadarBall";);
}
listen(integer c, string n, key id, string msg)
{
if (c == -34240)
{
if(msg == "die";)
{
llDie();
}
}
if (c == -34236)
{
llSetObjectName(msg);
llListenRemove(avListen3);
}
if (c == -34235)
{
llSetObjectDesc(msg);
llListenRemove(avListen2);
}
if (c == -34234)
{
avKey = (key)msg;
llListenRemove(avListen);
llSensorRepeat("",avKey,AGENT,96,PI,1);
}
}
sensor(integer n)
{
rPos = (vector)llGetObjectDesc();
avName = llGetObjectName();
avPos = llDetectedPos(0);
vector avDivPos = <rPos.x+avPos.x/50,rPos.y+avPos.y/50,rPos.z+.12>;
avDistance = (string)llRound(llVecDist(rPos,llDetectedPos(0)));
llMoveToTarget(avDivPos,.2);
llSetText(avName + "[" + avDistance + "]",<1,1,1>,1);
}
no_sensor()
{
llSetText(avName+" is now out of range.",<1,1,1>,1);
llOwnerSay(avName + " is now out of range.";);
llSleep(5);
llDie();
}
}
_____________________
From: someone

Don't worry, Aniam is here!
- Noob
Stephen Zenith
Registered User
Join date: 15 May 2006
Posts: 1,029
11-08-2007 04:02
Try doing llOwnerSay on the list before and after you add your key to it.

Also, I wouldn't use another sensor in the ball, I use chat messages to update the position from the main scanner.
_____________________
Aniam Ingmann
llOwnage(float pwnage);
Join date: 22 Oct 2005
Posts: 206
11-08-2007 14:44
why would I use chat instead? that makes it more confusing and it'll be hard to have more than one avatar to be sensed at a time and chat is more laggy... i'm confused?
_____________________
From: someone

Don't worry, Aniam is here!
- Noob
Jesse Barnett
500,000 scoville units
Join date: 21 May 2006
Posts: 4,160
11-08-2007 14:48
LOL. OK I think you have had enough now. You can put the spleef back in the ashtray :p

Stephen is suggesting you use llOwnerSays to debug your script and make sure it is getting on your key.
_____________________
I (who is a she not a he) reserve the right to exercise selective comprehension of the OP's question at anytime.
From: someone
I am still around, just no longer here. See you across the aisle. Hope LL burns in hell for archiving this forum
Aniam Ingmann
llOwnage(float pwnage);
Join date: 22 Oct 2005
Posts: 206
11-08-2007 14:58
I did that.. and it's not recording it.. Any chance you can check my scripts for me to see what's wrong and why it's not recording the keys?
_____________________
From: someone

Don't worry, Aniam is here!
- Noob
Jesse Barnett
500,000 scoville units
Join date: 21 May 2006
Posts: 4,160
11-08-2007 16:00
No need to ask. I was going to go over them tonight anyway :)
_____________________
I (who is a she not a he) reserve the right to exercise selective comprehension of the OP's question at anytime.
From: someone
I am still around, just no longer here. See you across the aisle. Hope LL burns in hell for archiving this forum
Aniam Ingmann
llOwnage(float pwnage);
Join date: 22 Oct 2005
Posts: 206
11-08-2007 16:23
thanks :)
_____________________
From: someone

Don't worry, Aniam is here!
- Noob
Jesse Barnett
500,000 scoville units
Join date: 21 May 2006
Posts: 4,160
11-08-2007 18:45
I am still working on it. If you take out all of the says and put in llOwnerSay((string)llGetPos()) instead into the rezzed ball you will see that it is moving away from the rezzer on every sensor scan. It is adding the avDivPos to the rPos everytime.
_____________________
I (who is a she not a he) reserve the right to exercise selective comprehension of the OP's question at anytime.
From: someone
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
11-08-2007 19:33
OK Main Radar Script is still messed up. It keeps rezzing a new ball every scan. But to troubleshoot the position and until you have it just like you want change the sensor repeat there to a sensor. Once you do that then you can concentrate on the ball and the math wasn't as bad as I thought it was going to be:

CODE

//string avStatus;
string avName;
string avDistance;
key avKey;
//integer i;
integer avListen;
integer avListen2;
integer avListen3;
//vector getpos;
vector avPos;
vector avDivPos;
vector rPos;
default
{
on_rez(integer sp)
{
llSetText("Finding avatar...",<1,1,1>,1);
}
state_entry()
{
avListen = llListen(-34234,"",NULL_KEY,"");
avListen2 = llListen(-34235,"",NULL_KEY,"");
avListen3 = llListen(-34236,"",NULL_KEY,"");
}
listen(integer c, string n, key id, string msg)
{
if (c == -34236)
{
llSetObjectName(msg);//The Avatar it's tracking
llListenRemove(avListen3);
}
if (c == -34235)
{
llSetObjectDesc(msg);//The Position of the radar
llListenRemove(avListen2);
}
if (c == -34234)
{
avKey = (key)msg;//The Key of the avatar it's tracking
avName = llGetObjectName();
llListenRemove(avListen);
llSensorRepeat(avName,avKey,AGENT,96,PI,1.0);
}
}
sensor(integer n)
{
rPos = (vector)llGetObjectDesc();
avPos = llDetectedPos(0);
vector avDivPos = (avPos - rPos) * 0.095;
avDistance = (string)llVecDist(rPos,llDetectedPos(0));
llSetPos(rPos + avDivPos);
llSetText(avName + "[" + avDistance + "]",<1,1,1>,1);
}
no_sensor()
{
llSetText(avName+" is now out of range.",<1,1,1>,1);
llOwnerSay(avName + " is now out of range.");
llDie();
}
}


Look at how beautifully simple this is :

vector avDivPos = (avPos - rPos) * 0.095;//Basically positions the ball 1/10th of the scan distance or 1/10th the distance between the rezzer and the avatar.

You could always adjust it some but it looks right like it is and the ball will move around as you move.
_____________________
I (who is a she not a he) reserve the right to exercise selective comprehension of the OP's question at anytime.
From: someone
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
11-08-2007 19:36
And hope you know I was kidding you before. Wouldn't have said it if you were truly a noob now. You have absorbed more concepts in a shorter period then anyone I can recall in a while. Keep up the good work.
_____________________
I (who is a she not a he) reserve the right to exercise selective comprehension of the OP's question at anytime.
From: someone
I am still around, just no longer here. See you across the aisle. Hope LL burns in hell for archiving this forum
Stephen Zenith
Registered User
Join date: 15 May 2006
Posts: 1,029
11-09-2007 02:41
Actually, I was suggesting both! Use llOwnerSayto debug it, and just run a single sensor and chat messages to update the position of the ball.

It might not seem like much benefit if you're jut rezzing a single ball, but if you're tracking the positions of all avs within 96m, having a separate scanner for each is a bit of a waste.

It also means that the balls don't need to know the postion of the main radar - the main prim can work out the exact position the ball needs to be in relative to itself.

It also means you can reuse the code in the balls and the plotting code in the main prim for other things - for example I'm working on a flightpath system using waypoints and interpolating splines, that I'll also be able to plot on a miniature sim model using the same code.
_____________________
Aniam Ingmann
llOwnage(float pwnage);
Join date: 22 Oct 2005
Posts: 206
11-09-2007 02:58
Oh I see.. Thanks you, both of you guys. You're both really helpful :) And yeah, Jesse, you've helped me so much I wouldn't be where I am with scripting without you =p

So I guess I'll spend some time testing what's wrong with the lists. Trying to fix something by yourself always contributes to something new to learn. :)
_____________________
From: someone

Don't worry, Aniam is here!
- Noob
Jesse Barnett
500,000 scoville units
Join date: 21 May 2006
Posts: 4,160
11-09-2007 14:42
You are not the only one learning. I have several freebie radars, the most intriuing is an old one that has a ball with a stick on it that rezzes balls for each avatar and thier relative position exactly as yours does. In fact if you delete the rezzer the av ball will stay there and keep working. Forgot the creators name but it was frustrating because the rezzer script had mod rights but the balls didn't. Drove me nuts for quite a while as to how he did it. Never got around to figuring it out until you started this thread.
_____________________
I (who is a she not a he) reserve the right to exercise selective comprehension of the OP's question at anytime.
From: someone
I am still around, just no longer here. See you across the aisle. Hope LL burns in hell for archiving this forum
Johan Laurasia
Fully Rezzed
Join date: 31 Oct 2006
Posts: 1,394
11-10-2007 03:29
my 2 cents worth...

I have no listens at all, I get all the info I need with the sensor event.

First thing I do inside the sensor event is scannerPos = llGetPos(); that way, if you move the scanner, the balls 'follow' the scanner position.

Then, IN A FOR LOOP -->, I get the avatar's name, avatar's position, then calculate the difference between the avatar and the sensor base. Then, to scale for the movement, I use the value 0.05208333. The reason being this... full sized cylinder has a 10 meter diameter, and the balls rez at the center of the prim, thus giving you a 5 meter radius. 5/96=0.05208333, hence the ball movement is 5 meters (from the center of the cylinder flat to the end for the avatar moving up to 96 meters from the scanner (max sensor range). Therefore, an avatar coming into range would appear at the extreme edge of the cylinder, then as the avatar flew directly over the scanner, the rez ball would be at center, and as they passed out of range the ball would be at the other extreme edge just before de-rezzing.

Then, using llListFindList, I check for the avatar's name on the list I use to track weather they've already had a ball rezzed or not, if they're not on the list, they're added to it, a ball is rezzed, and it's position is chatted to the ball (along with the avatar's name so it can be set above the ball). If they're already on the list, there's no need to rez the ball, so only the avatar's position is updated. So... first part a for loop, with two if statments inside it, one for rezzing a ball and naming it, then setting it's position, the other just updating the position (since the ball is rezzed if the 2nd if statement is true).
___

then a 2nd for loop to build a list of sensed avatars...
___

then a 3rd for loop checks to see if the stored name is on the sensed list, if it is, they're still there, and nothing is done, if the stored list name is not on the sensed list, then the avatar is out of range, and a command is chatted to their ball to de-rez that avatar's ball, and the name is removed from the stored name list.

This script was a logic nightmare at first, and I initially gave up on it, but then recently revisited it and it's working pretty well. You sure picked a heck of a script to write as a noob that's for sure :)
Jesse Barnett
500,000 scoville units
Join date: 21 May 2006
Posts: 4,160
11-10-2007 05:40
If you think about it, the way he is doing it is pretty easy and efficient. Yes there can be up to 17 sensors running but each of the children are keyed to just one avatar. Also you don't have up to 16 says being spouted by mom every second or so updating thier position. All mom has to do is maintain a list of avatars in range to know whether to rezz another ball or so. The children sense the position of thier av and move accordingly and then die when the avatar is no longer in range.

Doing it this way you couldn't do tracks or use particles instead of position balls, but it's a good way to start and you learn all of the basics to expand upon.
_____________________
I (who is a she not a he) reserve the right to exercise selective comprehension of the OP's question at anytime.
From: someone
I am still around, just no longer here. See you across the aisle. Hope LL burns in hell for archiving this forum
Aniam Ingmann
llOwnage(float pwnage);
Join date: 22 Oct 2005
Posts: 206
11-10-2007 06:18
Yeah I think I'm going to stick with my idea, though thanks for your two cents, johan =p.

I actually have everything set up for my radar, but for some reason the llListFindList won't find a key after it's been written into the list.. and I think I'm just reading it wrong. The llOwnerSay that I stuck in there is reading -1 no matter what, even when the list has my key in it, and it's supposed to be reading anything else other than 1...
From: someone

string avKey;
string avName;
string getpos;
list avTest;
integer findlist;
list avList;
list test;
default
{
on_rez(integer sp)
{
llResetScript();
}
state_entry()
{
llListen(0,"",llGetOwner(),"";);
llOwnerSay("Say 'scan' to do a scan for avatars.";);
}
listen(integer c, string n, key id, string msg)
{
if (msg == "scan";)
{
llWhisper(-34240,"die";);
llSensorRepeat("","",AGENT,96,PI,1);
}

if (msg == "reset";)
{
llRegionSay(-34240,"die";);
llResetScript();
}
}
sensor(integer n)
{
avKey = llDetectedKey(0);
avName = llDetectedName(0);
avList += [(string)avKey];
test = [(string)avKey];
findlist = llListFindList(avList, test);
if (findlist = -1)
{
llRezObject("Aniam.RadarBall",llGetPos(),ZERO_VECTOR,ZERO_ROTATION,42);
llOwnerSay((string)findlist);
}
if (findlist != -1)
{
llOwnerSay(llList2String(avList,findlist));
return;
}
}
object_rez(key id)
{
llWhisper(-34234,avKey);
llWhisper(-34235,(string)llGetPos());
llWhisper(-34236,avName);
}
}
_____________________
From: someone

Don't worry, Aniam is here!
- Noob
1 2