Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

How to know the position of a prim

Azul Wilder
Registered User
Join date: 29 Jan 2007
Posts: 87
03-20-2007 13:33
Hi!

I need to know the position of a single prim from which I know the name, there are a lot of other single prims around, so the number will be 0 for all of them.

llDetectedPos detects the position of the prim number...
And a Sensor doesn't detect position (i think...)

Any suggestion?

Thanks
_____________________
First goes before
AW Devices
Darien Caldwell
Registered User
Join date: 12 Oct 2006
Posts: 3,127
03-20-2007 13:56
if you do a sensor, and then do llDetectedPos on the prim number of the prim with the name you know which was detected...
Azul Wilder
Registered User
Join date: 29 Jan 2007
Posts: 87
03-20-2007 14:15
How do you know the prim number from a sensor?
_____________________
First goes before
AW Devices
Newgate Ludd
Out of Chesse Error
Join date: 8 Apr 2005
Posts: 2,103
03-20-2007 14:23
The sensor will return up to 16 items which can be accessed via the llGetDetected functions.
Azul Wilder
Registered User
Join date: 29 Jan 2007
Posts: 87
03-20-2007 14:44
I have used this and it doesn't work
CODE

default
{ touch_start(integer total_number)
{
llSensor("prim_to_detect",NULL_KEY,PASSIVE,96,PI);
} sensor(integer total_number)
{
vector Posi;
Posi = llDetectedPos(total_number);
llOwnerSay("position X is: " + (string)Posi.x + " and for Y: " + (string)Posi.y);
} }
_____________________
First goes before
AW Devices
Deanna Trollop
BZ Enterprises
Join date: 30 Jan 2006
Posts: 671
03-20-2007 14:49
From: Azul Wilder
there are a lot of other single prims around, so the number will be 0 for all of them.

llDetectedPos detects the position of the prim number...
Er, hang on a sec... llDetectedPos( 0 ) doesn't reference Prim #0 of a detected linkset, it references the first detected object/agent in the array of accessible objects/agents of n length, passed to the event handler (e.g. touch*(), sensor(), collision*() )

So, if touch_start is raised, and 5 is the number passed to it, llDetected*( 0 ) will return info on the first agent in that array, llDetected*( 1 ) the second, and so on, up through llDetected*( 4 ).

Since you're only dealing with unlinked prims, you can just do a llSensor for the name of the object you're interested in, and if there's only 1 object with that name of the specified type within the specified range, the sensor() event will be raised with 1 passed to it, and llDetected*( 0 ) will return info on that object (the type of info depending on what * is, of course.)

I don't believe llDetected*() can ever return info on child prims of a linkset, other than llDetectedLinkNumber() in the touch*() hander of a root prim, and even then, only info about it's own children.
Deanna Trollop
BZ Enterprises
Join date: 30 Jan 2006
Posts: 671
03-20-2007 14:56
From: Azul Wilder

Posi = llDetectedPos(total_number);
This is the error. total_number is the length of the array of sensed objects/avatars. But since array indexes start with 0, the last element of the array will always be length - 1. e.g., if you have an array of size 5, the elements will be indexed as 0 through 4. Trying to use total_number as a reference guarantees you'll always overshoot the array by one.

If you only expect one object to be sensed, use llDetectedPos( 0 ).
Azul Wilder
Registered User
Join date: 29 Jan 2007
Posts: 87
03-20-2007 15:06
That is what i was trying to explain from the first post.

Then Is it possible to know the position of a single prim (PASSIVE), with a sensor or in any other way, in a script placed in another single prim?

Thanks.
_____________________
First goes before
AW Devices
Deanna Trollop
BZ Enterprises
Join date: 30 Jan 2006
Posts: 671
03-20-2007 15:19
Yes, the script you posted above, with the single change I describe above, should do exactly that.
Destiny Niles
Registered User
Join date: 23 Aug 2006
Posts: 949
03-20-2007 16:05
There is a radar script in the wiki libary

http://www.lslwiki.net/lslwiki/wakka.php?wakka=LibraryRadar

Change the value of scantype. In the library you will see
integer scanType = AGENT;
change to
integer scanType = PASSIVE;
Azul Wilder
Registered User
Join date: 29 Jan 2007
Posts: 87
03-20-2007 16:42
Yes Deanna, that works thank you.

I'll check that one in the wiki library too. thanks a lot.
_____________________
First goes before
AW Devices