Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Send Position Question.

bigmoe Whitfield
I>3 Foxes
Join date: 29 Jul 2007
Posts: 459
07-17-2009 22:14
Ive been using this but something has come up and I still need it to work outside of a link set. anybody have any idea at all how to accomplish this.

You use this script and link it and it says:[21:50] Object: The touched prim is 1.299942m from the root prim

But I need it to do this same exact thing being outside of the link set and seriously have no idea how to accomplish this. I just recently started scripting things that are still slightly out of my league lol.

Thanks

CODE

default
{
touch_start( integer vIntTouched )
{
string vStrMessage = "The touched prim is ";
if (llDetectedLinkNumber( 0 ) > 1)
{
vStrMessage += (string)llVecMag( llGetLocalPos() ) + "m from ";
}
llSay( 0, vStrMessage + "the root prim" );
}
}
_____________________
GoodBye Forums we will miss you ~moe 2-2-2010~
Dora Gustafson
Registered User
Join date: 13 Mar 2007
Posts: 779
07-18-2009 01:47
Use llSensor to find the object:
http://www.lslwiki.net/lslwiki/wakka.php?wakka=llSensor

In the sensor event:
http://www.lslwiki.net/lslwiki/wakka.php?wakka=sensor
you can use llDetectedPos to find the objects position:
http://www.lslwiki.net/lslwiki/wakka.php?wakka=llDetectedPos

Now calculate the float distance = llVecDist( llGetPos(), llDetectedPos(x));

Happy scripting:)
_____________________
From Studio Dora
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
07-18-2009 01:54
also possible via
llGetObjectDetails
https://wiki.secondlife.com/wiki/LlGetObjectDetails

with llSay in the child prim to give the other object it's key
https://wiki.secondlife.com/wiki/LlSay
_____________________
|
| . "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...
| -
bigmoe Whitfield
I>3 Foxes
Join date: 29 Jul 2007
Posts: 459
07-20-2009 17:27
This is what I have come up with but am getting spammed really bad and am still not sure how to get it to just say "I am (x)m away from the other prim" and also my way of getting the key of the other prim is a pain, would be nice if I could just insert the name of the item and it would go off of that instead of having to use the uuid of the other prim.

default
{

state_entry()
{

key id = "f7f6a3d4-bbc5-c443-8c92-0715cde830f1";
llSensorRepeat("",id,PASSIVE,20,2*PI,.4);
}

sensor(integer total_number)
{
vector pos = llDetectedPos(0);
llSay(0, " " + (string) pos);
}
}
_____________________
GoodBye Forums we will miss you ~moe 2-2-2010~
Shippou Oud
The Fox Within
Join date: 11 Jul 2005
Posts: 141
07-20-2009 19:33
( I cleaned up the script up a bit for you. )

default
{

state_entry()
{
}
touch_start(integer x)
{
if ( llGetOwner() == llDetectedKey(0) )
{

llSensor("",llGetLinkKey(),PASSIVE,20,2*PI);
}
}

sensor(integer x)
{

llOwnerSay("\n" + (string) llDetectedPos(0));
}
_____________________
DaVear Land Holdings, since 2005.
Dora Gustafson
Registered User
Join date: 13 Mar 2007
Posts: 779
07-21-2009 02:11
From: bigmoe Whitfield
still not sure how to get it to just say "I am (x)m away from the other prim" and also my way of getting the key of the other prim is a pain, would be nice if I could just insert the name of the item and it would go off of that instead of having to use the uuid of the other prim.
In llSensorRepeat you can use the name and not the ID if you want, no swet:)
CODE
default
{
state_entry()
{
string name = "Adam";
llSensorRepeat( name, NULL_KEY, PASSIVE, 20.0, PI, 4.0);
// note: PI will cover the whole sphere
}

sensor(integer total_number)
{
integer i;
for(i = 0 ; i < total_number ; i++)
{// for all sensed objects called name:
float distance = llVecDist( llGetPos(), llDetectedPos(i));
llOwnerSay( "\nI am "+(string)distance+" m away from: \""+llDetectedName(i)+"\"");
}
}
}
I tuned the script a bit but the form is still basically what you have.
As it is it is not of much use, you need to fit it to your application.
Happy scripting:)
(I can't believe I did it again: spend 30minutes making a free working script for someone I don't know)
_____________________
From Studio Dora
bigmoe Whitfield
I>3 Foxes
Join date: 29 Jul 2007
Posts: 459
07-22-2009 19:55
From: Dora Gustafson
In llSensorRepeat you can use the name and not the ID if you want, no swet:)
CODE
default
{
state_entry()
{
string name = "Adam";
llSensorRepeat( name, NULL_KEY, PASSIVE, 20.0, PI, 4.0);
// note: PI will cover the whole sphere
}

sensor(integer total_number)
{
integer i;
for(i = 0 ; i < total_number ; i++)
{// for all sensed objects called name:
float distance = llVecDist( llGetPos(), llDetectedPos(i));
llOwnerSay( "\nI am "+(string)distance+" m away from: \""+llDetectedName(i)+"\"");
}
}
}
I tuned the script a bit but the form is still basically what you have.
As it is it is not of much use, you need to fit it to your application.
Happy scripting:)
(I can't believe I did it again: spend 30minutes making a free working script for someone I don't know)



Thank you so much dora, I have another question.

I am wanting to build with this box no matter where it is in the sim. so say like 4000m up, wondering if region say could be used to calculate the distance between the 2 prims? like it does now or what kind of script would I need?
_____________________
GoodBye Forums we will miss you ~moe 2-2-2010~
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
07-22-2009 21:15
yes it should work with region say, in the listening script you would get the speaking objects position with llGetObjectDetails( id, [OBJECT_POS] ) and compare it to the receivers position
_____________________
|
| . "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...
| -
Dora Gustafson
Registered User
Join date: 13 Mar 2007
Posts: 779
07-23-2009 01:41
From: bigmoe Whitfield
I am wanting to build with this box no matter where it is in the sim. so say like 4000m up, wondering if region say could be used to calculate the distance between the 2 prims? like it does now or what kind of script would I need?
You can not use llSensor for big distances, it will not work beyond 96m.
For that you must know the UUID of the object.
Listen to what Void says.
_____________________
From Studio Dora
bigmoe Whitfield
I>3 Foxes
Join date: 29 Jul 2007
Posts: 459
07-23-2009 16:29
Thanks for the suggestions on this topic guys. Proves that there are still alot of people willing to help people like me who are beginners at scripting.



Moe
_____________________
GoodBye Forums we will miss you ~moe 2-2-2010~