Building Jet Packs in Second Life
Submitted by jeffheaton on Thu, 01/31/2008 - 13:45.
Jet Packs can be very useful in Second Life. A jet pack allows you to fly much higher than Second Life normally allows. This video tutorial shows how to create a jet pack that not only allows you to fly higher than the limits imposed by Second Life, but also includes a hover feature that holds your avatar in place when it is high up.
Get The Jet Pack Here
http://slurl.com/secondlife/Encogia/157/233/23
Script Code
// From the book: // // Scripting Recipes for Second Life // by Jeff Heaton (Encog Dod in SL) // ISBN: 160439000X // Copyright 2007 by Heaton Research, Inc. // // This script may be freely copied and modified so long as this header // remains unmodified. // // For more information about this book visit the following web site: // // http://www.heatonresearch.com/articles/series/22/ integer locked; float LOCKTIME = 1.0; displayAltitude() { vector pos = llGetPos(); llSetText("Altitude: " + (string)((integer)pos.z), <0,1,0>, 1 ); } vector getVelocity() { rotation rot = llGetRot(); vector vel = llRot2Fwd(rot); if( llGetAgentInfo(llGetOwner()) & AGENT_FLYING ) vel*=4; else vel/=2; return vel; } default { state_entry() { llReleaseControls(); locked = FALSE; displayAltitude(); } attach(key id) { if(id) { state attached; } } } state attached { state_entry() { llSetTimerEvent(1); locked = FALSE; displayAltitude(); } attach(key id) { if(id==NULL_KEY) { state default; } } timer() { if (llGetAgentInfo(llGetOwner()) & AGENT_FLYING) { state flying; } } } state flying { state_entry() { llRequestPermissions(llGetOwner(), PERMISSION_TAKE_CONTROLS); llSetTimerEvent(1); locked = FALSE; } run_time_permissions(integer perm) { if (perm & PERMISSION_TAKE_CONTROLS) { llTakeControls(CONTROL_UP|CONTROL_DOWN|CONTROL_FWD|CONTROL_BACK, TRUE, FALSE); } } attach(key id) { if(id==NULL_KEY) { state default; } } timer() { displayAltitude(); if (!(llGetAgentInfo(llGetOwner()) & AGENT_FLYING) ) { llReleaseControls(); state attached; } if ((!locked) && (llGetTime() > LOCKTIME)) { llMoveToTarget(llGetPos(), 0.2); locked = TRUE; } } control(key id, integer held, integer change) { if (locked) { llStopMoveToTarget(); locked = FALSE; } if (held & CONTROL_UP) { llPushObject(llGetOwner(), <0,0,2>, ZERO_VECTOR, FALSE); } else if (held & CONTROL_DOWN) { llPushObject(llGetOwner(), -<0,0,2>, ZERO_VECTOR, FALSE); } else if (held & CONTROL_FWD) { llPushObject(llGetOwner(), getVelocity(), ZERO_VECTOR, FALSE); } else if (held & CONTROL_BACK) { llPushObject(llGetOwner(), -getVelocity(), ZERO_VECTOR, FALSE); } llResetTime(); } }








