Change font size
It is currently Tue Dec 18, 2018 12:13 pm

Forum rules


{L_IMAGE}



Post a new topicPost a reply Page 1 of 1   [ 4 posts ]
Author Message
 Post subject: Board (fake vehicle)
PostPosted: Sat Jul 07, 2012 1:31 am 

Joined: Tue Nov 16, 2010 7:45 am
Posts: 9
its a script for a surfboard like object. Hope you like it.

{L_CODE}:
default
{
    on_rez(integer flag) { do { llSay(0, "Resetting..."); llResetScript(); } while (TRUE); }

    state_entry()
    {
        llSetClickAction(CLICK_ACTION_SIT);
       
        llSitTarget(<-0.25, 0.0, 0.75>, <0.0, 0.0, 0.0, 0.0>);
       
        llSetCameraEyeOffset(<-5, 0, 2> *  <0.0, 0.0, 0.0, 0.0>);
        llSetCameraAtOffset(<3, 0, 1> *  <0.0, 0.0, 0.0, 0.0>);
    }

    changed(integer change)
    {
        if ( change & (CHANGED_REGION_RESTART | CHANGED_REGION_START))
            do { llOwnerSay("Resetting..."); llResetScript(); } while (TRUE);

        if (change & CHANGED_LINK)
        {
            key avatar = llAvatarOnSitTarget();
            if ( avatar != NULL_KEY ) llRequestPermissions(avatar,PERMISSION_TRIGGER_ANIMATION | PERMISSION_TAKE_CONTROLS);
            else if (llGetPermissionsKey() != NULL_KEY)
            {
                llStopAnimation("surf");
                llReleaseControls();

                vector pos = llGetPos();
                float ground = llGround(ZERO_VECTOR);
                rotation rot = llGetRot();
                vector euler = llRot2Euler(rot) * RAD_TO_DEG;
               
                rot = <rot.x, rot.y, rot.z, -rot.s> * rot * llEuler2Rot(<0.0, 0.0, euler.z> * DEG_TO_RAD);
               
                if ((pos.z - ground) < 10.0) llSetLinkPrimitiveParamsFast(LINK_THIS, [PRIM_POSITION, <pos.x, pos.y, ground + 0.0125>]);
                llSetLinkPrimitiveParamsFast(LINK_THIS, [PRIM_ROTATION, rot]);
               
                llSay(0,"I have released control");
            }
        }
    }

    run_time_permissions(integer perm)
    {
        if (perm & ( PERMISSION_TRIGGER_ANIMATION | PERMISSION_TAKE_CONTROLS ))       
        {
            llStopAnimation("sit");
            llSleep(0.1);
            llStartAnimation("surf");

            llTakeControls(CONTROL_FWD | CONTROL_BACK |
                           CONTROL_ROT_LEFT | CONTROL_ROT_RIGHT |
                           CONTROL_UP | CONTROL_DOWN,
                           TRUE, FALSE);

            llSay(0,"I have control");
        }
    }
   
    control(key id, integer held, integer change)
    {
        vector pos = llGetPos();
        vector sim = ZERO_VECTOR;
        rotation rot = llGetRot();
       
        // Check sim boundry and Move
        if (held & CONTROL_FWD)
        {
            sim = pos + (llRot2Fwd(rot) * 1);
            if ((sim.x > 5.0) && (sim.x < 250.0) && (sim.y > 5.0) && (sim.y < 250.0)) { pos = sim; }
        }
           
        if (held & CONTROL_BACK)
        {
             sim = pos - (llRot2Fwd(rot) * 1);
             if ((sim.x > 5.0) && (sim.x < 250.0) && (sim.y > 5.0) && (sim.y < 250.0)) { pos = sim; }
        }
        // adjust rotation z axis
        if (held & CONTROL_ROT_LEFT)  { rot = rot * llEuler2Rot(<0.0, 0.0,  15.0> * DEG_TO_RAD); }
        if (held & CONTROL_ROT_RIGHT) { rot = rot * llEuler2Rot(<0.0, 0.0, -15.0> * DEG_TO_RAD); }
       
        // add banking
        if (held & change & CONTROL_ROT_LEFT)  { rot = llEuler2Rot(<-10.0, 0.0, 0.0> * DEG_TO_RAD) * rot; }
        if (held & change & CONTROL_ROT_RIGHT) { rot = llEuler2Rot(< 10.0, 0.0, 0.0> * DEG_TO_RAD) * rot; }
       
        // remove banking
        if (~held & change & CONTROL_ROT_LEFT)  { rot = llEuler2Rot(< 10.0, 0.0, 0.0> * DEG_TO_RAD) * rot; }
        if (~held & change & CONTROL_ROT_RIGHT) { rot = llEuler2Rot(<-10.0, 0.0, 0.0> * DEG_TO_RAD) * rot; }

        // Adjust rotation local y axis
        if (held & CONTROL_UP)   { rot = llEuler2Rot(<0.0,  1.0, 0.0> * DEG_TO_RAD) * rot; }
        if (held & CONTROL_DOWN) { rot = llEuler2Rot(<0.0, -1.0, 0.0> * DEG_TO_RAD) * rot; }

//        if (held & CONTROL_UP)   { pos = pos + (llRot2Up(rot) * 1); }
//        if (held & CONTROL_DOWN) { pos = pos - (llRot2Up(rot) * 1); }

        // fall have to change this.
        float ground = llGround(llGetPos() - pos);
        if (pos.z > ground) pos.z = pos.z - 0.25;
        if (pos.z < 1.0) pos.z = 1.0;

        llSetLinkPrimitiveParamsFast(LINK_THIS, [PRIM_POSITION, pos, PRIM_ROTATION, rot]);
    }
}


Top
 Profile  
 
 Post subject: Re: Board (fake vehicle)
PostPosted: Sun Jul 08, 2012 1:50 am 
It's fun :-) I always wondered how to bank a vehicle. Thanks for all the nice scripts your pasting here.


Top
  
 
 Post subject: Re: Board (fake vehicle)
PostPosted: Wed Jul 03, 2013 5:17 pm 
User avatar

Joined: Sat Mar 06, 2010 11:18 am
Posts: 30
Location: United Kingdom
Very bad script. You get lost underground as soon as you touch an up or down button.
That's your dead in the water. You then have to stand up if you can then goto world, about region, debug, get top scripts and hope you can return it
to the lost and found folder so you can delete it.
Sorry

_________________
Youtube Videos : http://www.youtube.com/user/proracermotorsports
Blog : http://www.pro-racer.info


Top
 Profile  
 
 Post subject: Re: Board (fake vehicle)
PostPosted: Thu Jul 04, 2013 1:27 pm 

Joined: Tue Jul 02, 2013 11:56 am
Posts: 3
Thanks for posting the board script.
It's always nice to see people's experiments in this direction.

If you don't mind a slightly off-topic question, what is the purpose of the on_rez being written the way you have it.
I have seen this form in other scripts.

{L_CODE}:
on_rez(integer flag) { do { llSay(0, "Resetting..."); llResetScript(); } while (TRUE); }


I use the simpler (eh simplistic?) form of:

{L_CODE}:
on_rez(integer flag) {
      llResetScript();
}


I am wondering what the do while wrapper is doing.

Does this mean that the llResetScript(); can fail leading to the need to be called again?

Regards,


Top
 Profile  
 
Display posts from previous:  Sort by  
Post a new topicPost a reply Page 1 of 1   [ 4 posts ]


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron


Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
610nm Style by Daniel St. Jules of Gamexe.net