Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

crossing sim borders and edgeofworld

Neurosis Darkes
Registered User
Join date: 12 May 2006
Posts: 49
06-04-2006 07:28
I made a tiny sphere and have made it traverse the world map however I want to to detect when it hits the edge of the world and change direction. My problem is its not detecting the edge of the world. I think this is because it is traveling by say intervals of 10m for example and it is hitting on a north edge of world sim 255 then it asks if edgeofworld 265 its not getting a TRUE result that it should thereby triggering the direction change. can anyone help me with this?

here is the code... keep in mind this has no real use as of yet its just something neat i like to sit on and ride around the world.

CODE

integer iterations = 0;
vector pos;
vector temppos;
vector temppos2;
float leap = 10;
vector direction = <0,leap,0>;
float dirmod = randBetween(0.0,4.0);
integer haltnow = FALSE;
while ( iterations < 1000 ) {
pos = llGetPos();
//llSay(0,"CMON!!!");
if ( dirmod <= 1.0 && WouldGoOffWorld(pos,pos+<0,leap,0>) == FALSE ) { //north
//llShout(0,"GOING NORTH!!");
while( llVecDist(llGetPos(), pos+<0,leap,0>) > 0.01 ) {
llSetPos(pos+<0,leap,0>);
}
} else if ( dirmod > 1.0 && dirmod <= 2.0 && WouldGoOffWorld(pos,pos+<0,-leap,0>) == FALSE ) { //south
while( llVecDist(llGetPos(), pos+<0,-leap,0>) > 0.01 ) {
llSetPos(pos+<0,-leap,0>);
}
} else if ( dirmod > 2.0 && dirmod <= 3.0 && WouldGoOffWorld(pos,pos+<-leap,0,0>) == FALSE ) { //west
while( llVecDist(llGetPos(), pos+<-leap,0,0>) > 0.01 ) {
llSetPos(pos+<-leap,0,0>);
}
} else if ( dirmod > 3.0 && WouldGoOffWorld(pos,pos+<leap,0,0>) == FALSE ) { //east
while( llVecDist(llGetPos(), pos+<leap,0,0>) > 0.01 ) {
llSetPos(pos+<leap,0,0>);
}
} else {
llShout(0,"End Of World... CHANGING DIRECTION");
dirmod = randBetween(0.0,4.0);
}
iterations++;
}
llShout(0,"Powering Down... Out Of Gas!");





am i mucking the math up somewhere?
ed44 Gupte
Explorer (Retired)
Join date: 7 Oct 2005
Posts: 638
06-04-2006 21:56
Not sure what is wrong with your code as it seems to me to be a little more complicated than it needs to be. Is this simpler to follow? Maybe not, *sigh*

CODE

integer wouldGoOffWorld(vector here, vector there) // as in the wiki
{
if (there.x < 0 || there.x > 256 || there.y < 0 || there.y > 256)
{
return llEdgeOfWorld(here, there - here);
}
else
{
return FALSE;
}
}
vector vNorth = <0,leap,0>;
vector vSouth = <0,-leap,0>;
vector vWest = <-leap,0,0>;
vector vEast = <leap,0,0>;

integer leap = 10;
list lDirs = [vNorth,vEast,vSouth,vWest];
integer dirIndex = 0;
vector dir;

move1 ()
{
dir = llList2Vector(lDirs, dirIndex % 4);
vector here = llGetPos ();
vector there = here + dir;

if (wouldGoOffWorld (here, there))
++dirIndex;
else
llSetPos(pos+<0,leap,0>);// no need for loop (there - here <= 10M)
}


move ()
{
integer iterations = 0;
while (iterations < 1000) {
move1 ();
++iterations;
}
}


Not sure if you have to stay above ground level.

You may also come across land that does not allow scripting.

One idea might be to follow a scout. It might keep shouting its new successful positions at you and you would simply issue the same setPos's to follow it. Use a timer so that if you don't get a shout you simply change direction and rez another scout. You might have to shout a first new position to the new scout after you rez it.

Of course the scout should have a die timer in it to prevent sim clutter. Not sure whether I would stop to clean up a scout that could not die because parcel owner refused script permissions.
Angela Salome
Registered User
Join date: 6 Oct 2005
Posts: 224
06-04-2006 23:22
From: ed44 Gupte
Of course the scout should have a die timer in it to prevent sim clutter. Not sure whether I would stop to clean up a scout that could not die because parcel owner refused script permissions.


Make the scout temp_on_rez so it automatically cleans itself up. The main craft will just have to keep rezzing a new scout every minute or so.
Rickard Roentgen
Renaissance Punk
Join date: 4 Apr 2004
Posts: 1,869
06-04-2006 23:46
in my experience the edge of world function occasionally lies. However it seems to be mostly when I've technically already moved passed the edge of the world to that meter or so leaway.
_____________________