Detecting Mega Regions and their edges

Creating scripts
Post Reply
User avatar
Kayaker Magic
Posts: 354
Joined: Sun Dec 01, 2013 8:40 am
Has thanked: 52 times
Been thanked: 393 times

Detecting Mega Regions and their edges

Post by Kayaker Magic »

As near as I can tell, llEdgeOfWorld always returns 1 no matter where you are inside a mega region, no mater which way you look.
In grids that allow vehicles to cross region boundaries, I use llEdgeOfWorld to tell if there is another region across an upcoming border.
This is important to know because if you cross off an edge with no sim on the other side, your scrip is stopped with no way to recover.
I like to script my vehicles to stop just before the border and allow you to turn until you are moving in a safe direction again.
In places that allow vehicles to cross region boundaries (Avination, InWorldz SL) you can still get in trouble if you drive across into a region that has NO SCRIPTS enabled, and there is no way to check for that beforehand. But in those places at least you can rely on llEdgeOfWorld to find many places where your should not go.

Is there any way to detect the EdgeOfMegaWorld?

It would be nice if llEdgeOfWorld(pos,dir) returned a 0 if pos and pos+dir were both inside the mega region, and 1 if pos+dir was outside. But that would break some scripts from SL that assume that both points can be inside and still get 1 if the projection of dir eventually crosses outside a region.

Is there aw way to ask with a script "what is the largest x and y co-ordinate I will ever see in this world?"
Then I could implement my own EdgeOfWorld test...
User avatar
Dundridge Dreadlow
Posts: 616
Joined: Mon May 06, 2013 2:23 pm
Location: England
Has thanked: 590 times
Been thanked: 339 times

Re: Detecting Mega Regions and their edges

Post by Dundridge Dreadlow »

Hmmm... interesting...
ImageImageImageImageImageImage
PS. Kitely is awesome.
User avatar
Dot Matrix
Posts: 1626
Joined: Sun Jul 28, 2013 3:26 am
Has thanked: 1209 times
Been thanked: 2326 times

Re: Detecting Mega Regions and their edges

Post by Dot Matrix »

I remember vaguely that you have to tell Boo's boats what size world you are in. Would that be a way of handling this sort of issue?
User avatar
Kayaker Magic
Posts: 354
Joined: Sun Dec 01, 2013 8:40 am
Has thanked: 52 times
Been thanked: 393 times

Re: Detecting Mega Regions and their edges

Post by Kayaker Magic »

Since I cannot detect the EdgeOfWorld or EdgeOfMegaRegion, I tried sailing off the edge. My windsurfer is a non-physical vehicle so it is moving with llSetLinkPrimParamFast(LINK_THIS,[PRIM_POSITION,pos]); First I tried sailing off the south or west edge of a mega region (or a single region I assume). As soon as you get over the border, your script stops working. You can grab the build, rotate it around to face back in (while still seated on it), drag it back into the SIM and after a few false starts it will continue on it's way. That's not so bad, I could live with that.

BUT THEN I TRIED SAILING OFF THE NORTH and EAST edges of the mega region. Every time (well 2 out of 2 so far) I have gotten a "DON'T PANIC, FIRESTORM HAS CRASHED" message and it has closed. When I logged back in, I found the windsurfer was stuck off the edge. But on the N and E edges, I am unable to edit the windsurfrer, rotate it, drag it back in-SIM, or even delete it. The edit option in the pie menu is greyed out so I cannot edit it. The delete button is not greyed out, but clicking on that does nothing, the sailboat is stuck out there and I cannot get rid of it. In the second case, when I tried to delete, it gave me a warning dialog "at least one object is locked, not copyable, not owned by you, are you sure you want to delete this". I said yes, but it didn't work. It is still stuck out there. Eventually there will be a fence of dead sailboats around these two edges of my mega region, a warning to sailors to stay away.

This is why it is so important to have a way to detect the edges of the mega region. We have to check for the edges in our scripts and stay inside the valid regions!
User avatar
Kayaker Magic
Posts: 354
Joined: Sun Dec 01, 2013 8:40 am
Has thanked: 52 times
Been thanked: 393 times

Re: Detecting Mega Regions and their edges

Post by Kayaker Magic »

Dot Matrix wrote:I remember vaguely that you have to tell Boo's boats what size world you are in. Would that be a way of handling this sort of issue?
Yeah, I could find no other way to do it, so I added a button to my dialog that says 1x1 by default and you can click on it to change to 2x2, 3x3, etc.
Unfortunately I have to default to 1x1 to be safe, so when you first rez a boat it will refuse to leave the sub-region you rezzed it in. You can change it and save the boat back into inventory and it will remember that for the next time it is rezzed.
These users thanked the author Kayaker Magic for the post:
Constance Peregrine
User avatar
Oren Hurvitz
Posts: 361
Joined: Sun Dec 23, 2012 8:42 am
Has thanked: 19 times
Been thanked: 499 times
Contact:

Re: Detecting Mega Regions and their edges

Post by Oren Hurvitz »

We added a function called osGetRegionSize(), which returns the size of the current region and works correctly even in megaregions. See http://www.kitely.com/virtual-world-new ... g-physics/.
These users thanked the author Oren Hurvitz for the post (total 4):
Constance PeregrineKeith SelmesKayaker MagicJack Spade
Post Reply