Skip to content
lsl.devlsl.devLSL Dev

FindScreenWidth

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.
//Find Screen Width
//By Darwin Recreant

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);
    }
}
Original wiki source

Some wiki templates and tables need their original context. View this article on the Second Life Wiki. Technical wording and examples are retained from the source; historical guidance may differ from current behavior.

From the Second Life Wiki

Community documentation adapted from FindScreenWidth, by Linden Research, Inc. and contributing residents.View contributors and history.

Imported wiki revision:

Licensed under CC BY-SA 3.0. Last wiki edit: .Formatting and links have been adapted for this site; API metadata follows the LSL definitions.