This script was tested and works on OpenSim version 0.7.4!

cannon_targeting.lsl
///////////////////////////////////////////////////////////////////////////
//  Copyright (C) Wizardry and Steamworks 2013 - License: GNU GPLv3      //
//  Please see: http://www.gnu.org/licenses/gpl.html for legal details,  //
//  rights of fair usage, the disclaimer and warranty conditions.        //
///////////////////////////////////////////////////////////////////////////
 
default
{
    touch(integer total_number)
    {
        vector t = llDetectedTouchUV(0);
        // llEuler2Rot(<0,0,1>*DEG_TO_RAD) ~= <.00000, .00000, .00873, .99996>
        // llEuler2Rot(<1,0,0>*DEG_TO_RAD) ~= <.00873, .00000, .00000, .99996>
        if(t.x < .2) {
            llSetLinkPrimitiveParams(1, [PRIM_ROTATION, llGetRootRotation()*<.00000, .00000, .00873, .99996>]);
            jump display;
 
        }
        //right
        if(t.x > .7) {
            llSetLinkPrimitiveParams(1, [PRIM_ROTATION, llGetRootRotation()/<.00000, .00000, .00873, .99996>]);
            jump display;
 
        }
        //down
        if(t.y < .2) {
            rotation c = llList2Rot(llGetLinkPrimitiveParams(3, [PRIM_ROT_LOCAL]), 0);
            vector rt = llRot2Euler(c)*RAD_TO_DEG;
            if(rt.x < 1) return;
            llSetLinkPrimitiveParamsFast(3, [PRIM_ROT_LOCAL, c/<.00873, .00000, .00000, .99996>]);
            jump display;
        }
        //up
        if(t.y > .7) {
            rotation c = llList2Rot(llGetLinkPrimitiveParams(3, [PRIM_ROT_LOCAL]), 0);
            vector rt = llRot2Euler(c)*RAD_TO_DEG;
            if(rt.x > 50) return;
            llSetLinkPrimitiveParamsFast(3, [PRIM_ROT_LOCAL, c*<.00873, .00000, .00000, .99996>]);
            jump display;
        }
        return;
@display;
        vector r = llRot2Euler(llList2Rot(llGetLinkPrimitiveParams(3, [PRIM_ROT_LOCAL]), 0))*RAD_TO_DEG;
        string e = llGetSubString((string)r.x,0, 4);
        llSetText("Elevation: " + e + "∘", <1,1,1>, 1);
    }
    touch_end(integer num) {
        // alarm 5
        llSetTimerEvent(5);
    }
    timer() {
        llSetText("", <1,1,1>, 1);
    }
}

secondlife/artillery/cannon/targeting.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.