Don't click here unless you want to be banned.

LSL Wiki : ExampleControls

HomePage :: PageIndex :: RecentChanges :: RecentlyCommented :: UserSettings :: You are crawl338.us.archive.org
Example Controls

// example_controls.lsl // ready jack // 21 jan 2006 // v1.0

// Put this in an attachment. When you put the script in or make
// a change, you have to re-attach the object to activate the controls.

default
{
    attach(key who)
    {
        if (who == NULL_KEY) { 
            // detached
            if (llGetPermissions() & PERMISSION_TAKE_CONTROLS) {
                llReleaseControls();
            }
        } else {
            llRequestPermissions(who, PERMISSION_TAKE_CONTROLS);
        }
    }

    run_time_permissions(integer perms)
    {
        integer desired_controls = 
                CONTROL_FWD |
                CONTROL_BACK |
                CONTROL_LEFT |
                CONTROL_RIGHT |
                CONTROL_ROT_LEFT |
                CONTROL_ROT_RIGHT |
                CONTROL_UP |
                CONTROL_DOWN |
                CONTROL_LBUTTON |
                CONTROL_ML_LBUTTON
        ; 

        if (perms & PERMISSION_TAKE_CONTROLS) {
            llTakeControls(desired_controls, TRUE, TRUE);
        }
    }

    control(key id, integer down, integer new)
    {
        integer pressed = down & new;
        integer held = down & ~new;
        integer released = ~down & new;

        if (pressed & CONTROL_LBUTTON) llOwnerSay("click");
        if (held & CONTROL_FWD) llOwnerSay("forward held");
        // etc.
    }
}


Examples
There is no comment on this page. [Display comments/form]