Fox Zapata
Junior Member
Join date: 24 Apr 2004
Posts: 5
|
08-26-2004 06:58
Can someone please explain how llSetPos works in a way that i can understand (I'm kind of slow and the LSL help guide confused me beyond belief  ). Also, if someone could show me and example of it I'd greatly apprecialte it, Thanks!
|
Azelda Garcia
Azelda Garcia
Join date: 3 Nov 2003
Posts: 819
|
08-26-2004 07:20
Well... SetPos takes a coordinate of a point in space and moves an object to that point.
Note that it only works for non-physical objects. That means you cant use it for avatars.
A coordinate in space uses three numbers: x, y, z:
llSetPos( < xcoordinate, ycoordinate, zcoordinate> );
xcoordinate is distance North-South ycoordinate is distance East-West zcoordinate is distance upwards
You can see the directions the coordinates point by editing an object and looking at the directions the axes point: x axis = red arrow y axis = green arrow z axis = blue arrow
(make sure "local axes" is unchecked)
You can get your current position using llGetPos().
The coordinates in a sim range from 0 to 256 along x and y axes, and from 0 up to a really high number for z axis.
To what extent does that answer your question? Which bits about llSetPos are least clear?
Azelda
|
Fox Zapata
Junior Member
Join date: 24 Apr 2004
Posts: 5
|
08-26-2004 07:28
That makes things much more clearer, thanks a lot Is there anyway i can see an example of a script using llSetPos?
|
Azelda Garcia
Azelda Garcia
Join date: 3 Nov 2003
Posts: 819
|
08-26-2004 07:43
I could post one, but my experience is if I post without actually trying the script on SL it has syntax errors in it  But I'll post one anyway and someone can correct the syntax errors. default { state_entry() { llWhisper( 0, "compile completed" ); } touch_start (integer num ) { llSetPos( llGetPos() + <0,0,0.5> ); } }
Whenever you touch the object, it'll move 0.5m higher (z-axis). Azelda
|
Kineda Kuroda
Junior Member
Join date: 11 Dec 2003
Posts: 2
|
08-30-2004 17:24
One note: last I checked, llSetPos will only move the object a maximum of ten meters. Here's an easy demonstration of how to write a script for a domino that falls when touched, then goes back to its original position. Grab it after it falls and throw it far far away to see the while loop in action. (Better yet, sit on it and have a friend do it!) vector restpos; //where are we normally rotation restrot; //how are we normally rotated vector currentpos; //where are we now integer touched; //did someone touch us; are we already falling?
default {
state_entry() { touched = FALSE; //we're not currently falling llSetStatus(STATUS_PHYSICS, FALSE); //this is WHY we're not falling } touch_start(integer num_detected) { if(touched == FALSE) //don't start this if we're already falling { touched = TRUE; //note to world: we're falling now! restpos = llGetPos(); //this is where we want to go back to restrot = llGetRot(); //and this is how we want to rotate back to llSetStatus(STATUS_PHYSICS, TRUE); //Geronimo! llSetTimerEvent(10.0); //ten seconds later... } } timer() { touched = FALSE; //...we right ourselves llSetStatus(STATUS_PHYSICS, FALSE); //try not to use llSetPos while physics are on llSetRot(restrot); //spin back to normal rotation do { llSetPos(restpos); //move to our old pos (or 10m, whichever is closer) currentpos = llGetPos(); //where are we now? }while(currentpos != restpos); /if we're not home, keep trying! llSetTimerEvent(0); //we're home, the show's over! }
}
|