Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

llGetPos and llSetPos

Knight Nootan
Registered User
Join date: 26 May 2008
Posts: 73
08-25-2009 17:27
Very basic functions but I am confusing myself yet again I think, lol

What I am trying to do is this.
I have a physical object that moves, when it moves say 5 meters from its spot of rezz I want it to go back to the spot of rezz. I know I need to get the pos on rez to set the home spot but my problem is how do I get it to spring back to the home spot when it goes x meters away from it?

Thanks in advance!!
Ruthven Willenov
Darkness in your light
Join date: 16 Jan 2008
Posts: 965
08-25-2009 17:31
From: Knight Nootan
Very basic functions but I am confusing myself yet again I think, lol

What I am trying to do is this.
I have a physical object that moves, when it moves say 5 meters from its spot of rezz I want it to go back to the spot of rezz. I know I need to get the pos on rez to set the home spot but my problem is how do I get it to spring back to the home spot when it goes x meters away from it?

Thanks in advance!!


i don;t think llSetPos works for physical objects, you'll either need to temporarily set it to non-phys, or use llMoveToTarget to move it back the starting position
_____________________
Dark Heart Emporium

http://www.xstreetsl.com/modules.php?name=Marketplace&MerchantID=133020

want more layers for tattoos, specifically for the head? vote here
http://jira.secondlife.com/browse/VWR-1449?

llDetectedCollision* Functions similar to touch
http://jira.secondlife.com/browse/SVC-3369
Jesse Barnett
500,000 scoville units
Join date: 21 May 2006
Posts: 4,160
08-25-2009 17:37
From: Knight Nootan
Very basic functions but I am confusing myself yet again I think, lol

What I am trying to do is this.
I have a physical object that moves, when it moves say 5 meters from its spot of rezz I want it to go back to the spot of rezz. I know I need to get the pos on rez to set the home spot but my problem is how do I get it to spring back to the home spot when it goes x meters away from it?

Thanks in advance!!

llSetPos works fine in Physical objects. Post what you have so far and we can point you in the right direction.
_____________________
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
Talarus Luan
Ancient Archaean Dragon
Join date: 18 Mar 2006
Posts: 4,831
08-25-2009 19:52
From: Jesse Barnett
llSetPos works fine in Physical objects. Post what you have so far and we can point you in the right direction.


Since when?

From: The Wiki on llSetPos
This function does not work for physical objects.
Sindy Tsure
Will script for shoes
Join date: 18 Sep 2006
Posts: 4,103
08-25-2009 19:56
From: Jesse Barnett
llSetPos works fine in Physical objects..

Er... You sure about that?

edit: fast dragon typing!
_____________________
Sick of sims locking up every time somebody TPs in? Vote for SVC-3895!!!
- Go here: https://jira.secondlife.com/browse/SVC-3895
- If you see "if you were logged in.." on the left, click it and log in
- Click the "Vote for it" link on the left
Jesse Barnett
500,000 scoville units
Join date: 21 May 2006
Posts: 4,160
08-25-2009 20:18
Yep, my bad! I was calling physics off first wherever I used it in scripts.

OP, still post whatcha got.
_____________________
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
08-25-2009 20:28
Here is the OP's script:

CODE

vector home;
string pos;
float XPOS;
float YPOS;
float ZPOS;
key gQueryID;

default {
state_entry() {
gQueryID = (string) home;
pos = llGetObjectDesc();
}
dataserver(key query_id, string data) {
if (query_id == gQueryID) {
list tempLine = llParseString2List(data,[","],[]);
XPOS = llList2Float(tempLine, 0);
YPOS = llList2Float(tempLine, 1);
ZPOS = llList2Float(tempLine, 2);
}
}
collision_start(integer num) {
if (llDetectedName(0) == llGetOwner()) {
llSetPrimitiveParams([PRIM_PHYSICS, TRUE]);
}
}
collision_end(integer num_detected) {
pos = llGetObjectDesc();
llStopSound();
llSetPrimitiveParams([PRIM_PHYSICS, FALSE]);
llGetPos();
llSay(0, (string) XPOS);
if (XPOS > XPOS + (integer) pos) {
llSetPrimitiveParams([PRIM_PHANTOM, TRUE]);
llSetPos(home);
return;
}
if (XPOS < XPOS - (integer) pos) {
llSetPrimitiveParams([PRIM_PHANTOM, TRUE]);
llSetPos(home);
return;
}
}
on_rez(integer start_param) {
home = llGetPos();
}
}
_____________________
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
Knight Nootan
Registered User
Join date: 26 May 2008
Posts: 73
08-25-2009 20:31
Thank you Jesse, I havent been able to post back for some reason untill now

Basically the object will only go physical when the owner touches it. On collision_end I want it to check its pos and if the new pos is greater than home + pos the reset if not then let it be.
Jesse Barnett
500,000 scoville units
Join date: 21 May 2006
Posts: 4,160
08-25-2009 20:38
The data_server event is never being called:

gQueryID = (string) home;

Is not a valid call. See:

http://lslwiki.net/lslwiki/wakka.php?wakka=dataserver

Calling: pos = llGetObjectDesc();
just once in state_entry works for debugging. Get the script working and then add in extra layers. And on that note, bypass the object description and data_server event entirely and fill in those values manually until you get the script working. Then add in one at a time.

Also remove llStopSound() as it is never called to begin with. Remember that as the others correctly pointed out (and I was delusional) llSetPos will not work with physics. Do you need to jump to position or do you need to move to position? If a hop is fine then bypass the physics. If you need the physics then you need to read up on llMoveToTarget().

And finally one caveat of llSetPos() is a 10 meter max limit. TO go farther, you need to call it in a loop.

Might help if you told us exactly what you were trying to do with this.
_____________________
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
08-25-2009 20:42
BTW the reason you could not post was as I pointed out in world. You have to have a space behind every opening angle bracket to bypass the stupid sql injection attack filter here.

This was the offending bit:

if(XPOS < XPOS - (integer)pos)
_____________________
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
Knight Nootan
Registered User
Join date: 26 May 2008
Posts: 73
08-25-2009 21:19
Working on doing it a way that doesnt require the dataserver.

The reason for the llStopSound() was that I had originally had a sound on collision start but removed it during my testing. Will post back prob tomorrow night with what I have done.

Thanks again Jesse