Difference between revisions of "LlGetRegionCorner"

From Second Life Wiki
Jump to navigation Jump to search
m (Replaced <source> with <syntaxhighlight> and added a haiku generated by ChatGPT.)
 
(7 intermediate revisions by 4 users not shown)
Line 1: Line 1:
{{LSL_Function
{{LSL_Function
|func=llGetRegionCorner|sort=GetRegionCorner
|func_id=199|func_sleep=0.0|func_energy=10.0
|func_id=199|func_sleep=0.0|func_energy=10.0
|func=llGetRegionCorner
|func_desc
|func_desc
|func_footnote=Divide the returned value by 256 to get the region offset.
|func_footnote=Divide the returned value by 256 to get the region offset.
Line 9: Line 9:
|spec
|spec
|caveats
|caveats
|examples=<pre>//calculates your position relative to <0,0,0> of 'Da Boom' in meters when you touch it
|examples=
<syntaxhighlight lang="lsl2">
// Calculates your position relative to <0,0,0> of 'Da Boom' in meters when you touch it
vector vecrel; //a sum of llgetpos and llgetregioncorner (and another vector). Saving time doing vector math.
vector vecrel; //a sum of llgetpos and llgetregioncorner (and another vector). Saving time doing vector math.


Line 16: Line 18:
     state_entry()
     state_entry()
     {
     {
         llSetText("Touch me to get your position", <1,1,1>, 2.0);
         llSetText("Touch me to get your position", <1.0,1.0,1.0>, 1.0);
     }
     }
   
     touch_start(integer total_number)
     touch_start(integer total_number)
     {
     {
         vecrel = llGetRegionCorner() + llGetPos();
         vecrel = llGetRegionCorner() + llDetectedPos(0);
         llWhisper(0, "llGetRegionCorner() is:"+(string)vecrel ); //for debugging before vector addition
         llWhisper(0, "llGetRegionCorner() is:"+(string)vecrel); //for debugging before vector addition
       
         vecrel -= <256000.0, 256000.0, 0.0>;//Da Boom's region corner is at <256000.0, 256000.0, 0.0>
         vecrel -= <256000.0, 256000.0, 0.0>;//Da Boom's region corner is at <256000.0, 256000.0, 0.0>
         llWhisper (0, "Position relative to <0,0,0> of 'Da Boom': "+ (string)llRound(vecrel.x) +",\t\t\t"+ (string)llRound(vecrel.y) +",\t\t\t"+ (string)llRound(vecrel.z) + ".");
         llWhisper (0, "Position relative to <0,0,0> of 'Da Boom': " +  
         llWhisper(0, "Position relative to <0,0,0> of 'Da Boom':"+(string)vecrel ); //faster but unformatted output
        (string)llRound(vecrel.x) + ", " + (string)llRound(vecrel.y) + ", " + (string)llRound(vecrel.z) + ".");
       
         llWhisper(0, "Position relative to <0,0,0> of 'Da Boom':" +(string)vecrel); //faster but unformatted output
     }
     }
}
}
</pre>
</syntaxhighlight>
|helpers
|helpers
|haiku={{Haiku|Code lines whisper low|llGetRegionCorner unfolds|Meters reveal truth.}}
|also_header
|also_header
|also_functions
|also_functions

Latest revision as of 14:43, 24 January 2024

Summary

Function: vector llGetRegionCorner( );
0.0 Forced Delay
10.0 Energy

Returns a vector in meters that is the global location of the south-west corner of the region the object is in. The z component is 0.0

Divide the returned value by 256 to get the region offset.

Examples

// Calculates your position relative to <0,0,0> of 'Da Boom' in meters when you touch it
vector vecrel; //a sum of llgetpos and llgetregioncorner (and another vector). Saving time doing vector math.

default
{
    state_entry()
    {
        llSetText("Touch me to get your position", <1.0,1.0,1.0>, 1.0);
    }
    
    touch_start(integer total_number)
    {
        vecrel = llGetRegionCorner() + llDetectedPos(0);
        llWhisper(0, "llGetRegionCorner() is:"+(string)vecrel); //for debugging before vector addition
        
        vecrel -= <256000.0, 256000.0, 0.0>;//Da Boom's region corner is at <256000.0, 256000.0, 0.0>
        llWhisper (0, "Position relative to <0,0,0> of 'Da Boom': " + 
        (string)llRound(vecrel.x) + ", " + (string)llRound(vecrel.y) + ", " + (string)llRound(vecrel.z) + ".");
        
        llWhisper(0, "Position relative to <0,0,0> of 'Da Boom':" +(string)vecrel); //faster but unformatted output
    }
}

Notes

The great zero is at region offset <1000,1000>, Great Zero🖈

Deep Notes

Signature

function vector llGetRegionCorner();

Haiku

Code lines whisper low
llGetRegionCorner unfolds
Meters reveal truth.