Table of Contents

About

This script was tested and works on OpenSim version 0.7.4!

A flight band or a flight plume will allow you to fly above the 200m limit. If you have ever wondered what the script looks like which allows you to fly to higher altitudes, here is a free implementation of such a device. To use this device, simply drop it in a prim and wear it; you can also drop it in a prim which is already attached to your body.

Command

The script also responds to commands on the main chat (without the quotes):

  • by saying fly on, you enable the flight assist. By default, when you attach the prim to yourself, or place it in a prim you are already wearing, the flight assist will automatically be turned on.
  • by saying fly off, you can disable the flight assist.
  • by saying fly faster, you can increase your speed while flying.
  • by saying fly slower, you can decrease your flying speed.

The way the script works is by capturing your forward, backward, left, right, up and down controls and whenever you press one of them, the script applies a physical force to your avatar. This is roughly how vehicles work in SL too.

Code

flight_assist.lsl
///////////////////////////////////////////////////////////////////////////
//  Copyright (C) Wizardry and Steamworks 2011 - License: GNU GPLv3      //
//  Please see: http://www.gnu.org/licenses/gpl.html for legal details,  //
//  rights of fair usage, the disclaimer and warranty conditions.        //
///////////////////////////////////////////////////////////////////////////
float speed = .5;
 
default {
 
    state_entry() {
        llRequestPermissions(llGetOwner(), PERMISSION_TAKE_CONTROLS);
        llSetTimerEvent(.5);
    }
 
    control(key id, integer level, integer edge) {
        vector impulse = < .0, .0, .0 > ;
        if (level & CONTROL_UP) {
            impulse += < 0, 0, speed > ;
        }
        if (level & CONTROL_DOWN) {
            impulse += < 0, 0, -speed > ;
        }
        if (level & CONTROL_FWD) {
            impulse += < speed, 0, 0 > ;
        }
        if (level & CONTROL_BACK) {
            impulse += < -speed, 0, 0 > ;
        }
        if (level & CONTROL_LEFT) {
            impulse += < 0, speed, 0 > ;
        }
        if (level & CONTROL_RIGHT) {
            impulse += < 0, -speed, 0 > ;
        }
        llApplyImpulse((vector) impulse, 1);
    }
 
    timer() {
        if (llGetAgentInfo(llGetOwner()) & AGENT_FLYING) {
            llSetForce(( < .0, .0, 9.81 > * llGetMass()), 0);
            jump flight_off;
        }
        llSetForce( < .0, .0, .0 > , 0);@flight_off;
        llSetTimerEvent(.5);
    }
 
    listen(integer channel, string name, key id, string message) {
        if (message == "fly on") {
            llOwnerSay("Flight engaged...");
            llRequestPermissions(llGetOwner(), 4);
            llSetTimerEvent(.5);
            return;
        }
        if (message == "fly off") {
            llOwnerSay("Flight disengaged...");
            llSetTimerEvent(0);
            llSetForce( < .0, .0, .0 > , 0);
            llReleaseControls();
            return;
        }
        if (message == "fly faster") {
            llOwnerSay("Flying faster...");
            speed += .5;
            return;
        }
        if (message == "fly slower") {
            llOwnerSay("Flying slower...");
            speed -= .5;
            return;
        }
    }
 
    run_time_permissions(integer permissions) {
        if (permissions & PERMISSION_TAKE_CONTROLS) {
            llTakeControls(CONTROL_FWD | CONTROL_BACK | CONTROL_LEFT | CONTROL_RIGHT | CONTROL_UP | CONTROL_DOWN, 1, 1);
            llListen(0, "", llGetOwner(), "");
        }
    }
}

secondlife/flight_assist.txt ยท Last modified: 2022/11/24 07:46 by 127.0.0.1

Access website using Tor Access website using i2p Wizardry and Steamworks PGP Key


For the contact, copyright, license, warranty and privacy terms for the usage of this website please see the contact, license, privacy, copyright.