Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- default
- {
- state_entry()
- {
- }
- touch_start(integer total_number)
- {
- // Get parcel you're in right now.
- key thisParcel = llList2Key(llGetParcelDetails(llGetPos(), [PARCEL_DETAILS_ID]),0);
- // Scan the region in 4m increments (from 2,2) and record the min and max
- // x and y for each point that is in the same parcel.
- float minx = 257.0;
- float maxx = -1.0;
- float miny = 257.0;
- float maxy = -1.0;
- float x;
- float y;
- key p;
- llOwnerSay("Scanning....");
- for (x = 2.0; x < 256.0; x += 4.0)
- {
- for (y = 2.0; y < 256.0; y += 4.0)
- {
- p = llList2Key(llGetParcelDetails(<x, y, 0.0>, [PARCEL_DETAILS_ID]), 0);
- if (p == thisParcel)
- {
- if (x < minx) minx = x;
- if (y < miny) miny = y;
- if (x > maxx) maxx = x;
- if (y > maxy) maxy = y;
- }
- }
- }
- // min/maxs are mid-points of the 4x4 grid squares, so adjust
- minx -= 2.0;
- miny -= 2.0;
- maxx += 2.0;
- maxy += 2.0;
- // And report what you've found....
- llOwnerSay("Done. Region sits between (" + (string)minx + "," + (string)miny +
- ") and (" + (string)maxx + "," + (string)maxy + ").");
- float midx = (minx + maxx) * 0.5;
- float midy = (miny + maxy) * 0.5;
- llOwnerSay("The midpoint of the parcel extremities is (" + (string)midx +
- "," + (string)midy + ")");
- key m = llList2Key(llGetParcelDetails(<midx, midy, 0.0>, [PARCEL_DETAILS_ID]), 0);
- if (m == thisParcel) llOwnerSay("The midpoint is inside the parcel.");
- else llOwnerSay("Your parcel is weirdly-shaped. The midpoint is NOT inside it!");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement