Difference between revisions of "Template:Darwin's Scripts"

From Second Life Wiki
Jump to navigation Jump to search
m
Line 5: Line 5:
<div id="box">
<div id="box">
==Find Screen Width==
==Find Screen Width==
<div style="padding: 0.5em">
The script below will give the width of the screen in meters by touching anywhere on the visible face, given that the prim is a box with zero rotation and attached at one of the corner HUD attachment points.
The script below will give the width of the screen in meters by touching anywhere on the visible face, given that the prim is a box with zero rotation and attached at one of the corner HUD attachment points.
<lsl>default
<lsl>default
Line 20: Line 21:
     }
     }
}</lsl>
}</lsl>
</div></div>
  | Script not found: {{{1}}}
  | Script not found: {{{1}}}
}}
}}
</div>
</includeonly>
</includeonly>


<noinclude>
<noinclude>
Returns lsl scripts
Returns lsl scripts
{{Darwin's Scripts|find screen width}}
</noinclude>
</noinclude>

Revision as of 11:10, 26 November 2008


Returns lsl scripts


Find Screen Width

The script below will give the width of the screen in meters by touching anywhere on the visible face, given that the prim is a box with zero rotation and attached at one of the corner HUD attachment points. <lsl>default {

   touch_start(integer total_number)
   {
       vector scale = llGetScale();
       vector off_point = llGetLocalPos();
       vector face_pos = llDetectedTouchST(0);
       vector screen_pos = llDetectedTouchPos(0);
       
       float screen_width = ((face_pos.x-.5)*scale.y-off_point.y+screen_pos.y)*2;
       
       llOwnerSay((string)screen_width);
   }

}</lsl>