Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

llEdgeOfWorld Help Please?

Kain Cleaver
Registered User
Join date: 24 Jan 2006
Posts: 178
06-02-2007 16:16
Ok. so i have a follow pet that i dont want to die if i get too close to the boarder. i wanna set limits to where if it gets too close for compfort it will not go into the offending area..

Can someone help me with this? I dont quite understand how LSLWiki explains it... its driving me nuts.
Kain Cleaver
Registered User
Join date: 24 Jan 2006
Posts: 178
06-03-2007 21:30
please can anyone answer
Qie Niangao
Coin-operated
Join date: 24 May 2006
Posts: 7,138
06-04-2007 00:43
Well, I can try to interpret the Wiki entry, but I'm not sure what's confusing. The slightly tricky bit, I suppose, is the "direction" vector, but there's an example there of computing it as the difference between two positions.

Presumably your follow-pet will check before moving whether its new computed location is outside the current sim (x or y dimension outside the range 0..255), and if so, then just see if the direction from current location to new location pushes llEdgeOfWorld() to true. But that's pretty much the example in the Wiki.
Kain Cleaver
Registered User
Join date: 24 Jan 2006
Posts: 178
06-04-2007 14:34
well.. the example it gives confuses me a lil i guess..

i dont understand how the interger situation works. i cant seem to referance the
integer wouldGoOffWorld(vector here, vector there)

situation to my movement. im working off a non phys movement script.


the only way a script compiles is if the integer is outside the script area (where nomral vector,integer,string definitions are) but im only used to assigning numbers/words to these.. not entire script situations like

integer wouldGoOffWorld(vector here, vector there)
{
if (there.x < 0 || there.x > 256 || there.y < 0 || there.y > 256)
{
return llEdgeOfWorld(here, there - here);
}
else
{
return FALSE;
}
}

when i try referancing wouldgooffworld in my movement field i get an error.

so lemme ask this.. using that above... where would i put a llSay command in.. to make my object say "too close" when i get 1m too close to the boarder?
Qie Niangao
Coin-operated
Join date: 24 May 2006
Posts: 7,138
06-05-2007 03:44
Okay, so... that wouldGoOffWorld() thing is a "function" you're defining; it's being defined to return an integer, and sure enough, the "return" statements inside all evaluate to integers--in this case TRUE or FALSE (1 or 0). So, in your script's event handlers (the stuff you define for the default state, for example), you can use the integer returned from wouldGoOffWorld() for whatever you need that TRUE or FALSE for... most likely a conditional, like an "if" or "while" statement. So, somewhere in your script you might have something like:

if (wouldGoOffWorld (wherePetIsNow, wherePetWantsToGo) )
{
llOwnerSay("oopsy!";);
}
else
{
kainsFunctionToMoveThePet ( wherePetWantsToGo );
}

(but I've no idea if this is in any way helpful.)