Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

restricting an object's position

droolcup Hastings
Registered User
Join date: 30 Apr 2008
Posts: 2
05-29-2008 07:11
Hiya all. I'm sure this has been asked several times before, but I couldn't find anything after some searching, apologies in advance.

I have a couple of objects I would like people to be able to move freely withing a predetermined area. I am already running touch_start() & touch_end() to get the objects' positions (sent to a php script elsewhere). i would prefer that these things were not allowed to roam willy nilly all over the place, and would like to keep them confined to the area of the building they are in.

Is there an existing function that will allow me to keep an object within some predefined coordinates, or do I need to manually check against the location after touch_end()?
Hewee Zetkin
Registered User
Join date: 20 Jul 2006
Posts: 2,702
05-29-2008 07:36
Hmm. I thought maybe llSetStatus(STATUS_SANDBOX, TRUE) might be useful for this, but apparently that turns the object non-physical as well. Might play around with that in any case and see if it might do what you want (e.g. try setting STATUS_SANDBOX then turning the object physical afterwards).

Otherwise, I'd say check position in 'touch_end' and maybe 'touch' as well. If it is out of bounds, force it back with a llMoveToTarget() or (maybe just if it is far enough away) by turning the object non-physical, moving back with non-physical movement, then turning the object physical again.
Hewee Zetkin
Registered User
Join date: 20 Jul 2006
Posts: 2,702
05-29-2008 07:39
Oh, and here's one more possibility that might work depending on your situation. Make the place you want to keep the object a parcel, and completely surround it with another parcel that has object entry turned off. You might need the object owner to be different from the owner of the surrounding parcel so that automatic owner exemptions don't apply. This won't constrain vertical movement, but I think it should take care of the horizontal.
Johan Laurasia
Fully Rezzed
Join date: 31 Oct 2006
Posts: 1,394
05-29-2008 12:54
There's a multitude of ways it can be done. You can set a base position, and if with a timer event, check the current position against the base, if it's too far away (llVectDist()), you can move it back to the base position. Also, you can use various parcel tools (llOverMyLand()) to check to see if it's on a specific parcel, and if not, move it back there.
Cryas Tokhes
Great Googley Moogley...
Join date: 8 Feb 2006
Posts: 124
05-29-2008 15:06
From: Johan Laurasia
There's a multitude of ways it can be done. You can set a base position, and if with a timer event, check the current position against the base, if it's too far away (llVectDist()), you can move it back to the base position. Also, you can use various parcel tools (llOverMyLand()) to check to see if it's on a specific parcel, and if not, move it back there.


This would be the easiest way to do this.
droolcup Hastings
Registered User
Join date: 30 Apr 2008
Posts: 2
follow up
06-03-2008 07:06
thanks for all your suggestions.

I wound up using a timed event (every second) that checks the current x & y coordinates against the boundaries of the space.

if it has traveled beyond the boundaries i make it a phantom object and have it travel to a predetermined spot, once there it becomes physical again.

below is the relevant code. any suggestions on improving are welcomed.


vector my_pos = <0,0,0>;
float timetowait = 1.;

default
{
state_entry()
{
llSetTimerEvent(timetowait);
}

timer()
{
my_pos = llGetPos();

float x_pos = my_pos.x;
float y_pos = my_pos.y;

if (y_pos < 159 || y_pos > 208 || x_pos > 99 || x_pos < 60){

llSetStatus(STATUS_PHANTOM, TRUE);
llMoveToTarget(<96,190,22.7>,.2);

} else {

llSetStatus(STATUS_PHANTOM, FALSE);
llStopMoveToTarget();

}
}
}
Strife Onizuka
Moonchild
Join date: 3 Mar 2004
Posts: 5,887
06-03-2008 07:13
Checkout the not_at_target event.
https://wiki.secondlife.com/wiki/not_at_target
_____________________
Truth is a river that is always splitting up into arms that reunite. Islanded between the arms, the inhabitants argue for a lifetime as to which is the main river.
- Cyril Connolly

Without the political will to find common ground, the continual friction of tactic and counter tactic, only creates suspicion and hatred and vengeance, and perpetuates the cycle of violence.
- James Nachtwey