Want to add a script or a project? Upload it and a half million people will see it and your name here this year.
![]() |
![]() |
||
---|---|---|---|
Category: | Contributor: | Creator | |
Cannon | Olly Butters | Avatar Cannon |
Category: Cannon
By : Olly Butters
Created: 2010-01-10 Edited: 2010-01-10
Worlds: Second Life
Browse the Zip file
12 //Person Cannon v0.9.43 //Author: Olly Butters4 //13 February 20075 //Part of the schome initiative. (www.schome.ac.uk)6 //You may copy/edit this, but please credit us.7 //This script moves an object via the avatars key strokes. It has a power variable which is controls the speed the avatar is shot.8 //Controls:9 //Left/Right - rotate cannon left/right10 //Forward/Back - rotate cannon up/down11 //Up/Down - increase/decrease the power the avatar is shot out.12 //Mouse-click - FIRE!!131415 //These are variables that could concievibly be altered.16 float muzzle_velocity = 50; //speed of the avatar17 float angle_increment = 10; //amount the cannon rotates by181920 //Nothing to edit below here at all, so don't even look!21 integer no_of_inclination_moves = 0; //keeps track of how much the cannon inclination22 integer no_of_rotation_moves = 0; //keeps track of the cannons rotation23 integer first_touch = 0; //keeps track of wether avatar is in the cannon24 key id; //avatar id.2526 //function to explain how to use.27 instructions()28 {29 llSay(0, "Hello.\n This is the person cannon - the best way to get around!\n To move the cannon use forward/back/left/right.\n To change the power of the cannon use up/down.\n\n To fire yourself click on the cannon.");30 }3132 //function to specify the precision of a float when converted to a string34 {35 if((precision = (precision - 7 - (precision < 1))) & 0x80000000)36 return llGetSubString((string)input, 0, precision);37 return (string)input;38 }3940 default41 {42 state_entry()43 {44 //sets up the initial position45 vector eul = <0, 0, 0>;46 eul *= DEG_TO_RAD; //convert to radians rotation48 llSetRot(quat); //rotate the object49 llSitTarget(<0,0,0.1>, ZERO_ROTATION); //this needs to be tweeked! shooting straight up is no longer straight up!50 llSetSitText("Climb in");//makes it say climb in istead of sit on in the pie menu.51 }52535455 //Move the cannon around and keeps track of the movement.57 {5961 {63 llSetRot(new_rot);64 no_of_rotation_moves = no_of_rotation_moves+1;65 }67 {69 llSetRot(new_rot);70 no_of_rotation_moves = no_of_rotation_moves - 1;71 }73 {74 rotation z_inc = llEuler2Rot( <0, angle_increment * DEG_TO_RAD, 0> );7677 llSetRot(new_rot);7879 no_of_inclination_moves = no_of_inclination_moves - 1;80 }82 {83 rotation z_inc = llEuler2Rot( <0, -angle_increment * DEG_TO_RAD, 0> );8586 llSetRot(new_rot);8788 no_of_inclination_moves = no_of_inclination_moves + 1;89 }91 {92 muzzle_velocity = muzzle_velocity + 50;93 string mv = "muzzle velocity=" + fixedPrecision(muzzle_velocity,0) + "m/s";94 llSay(0, mv);95 }97 {98 muzzle_velocity = muzzle_velocity - 50;99 if(muzzle_velocity<0)100 {101 muzzle_velocity=0;102 }103 string mv = "muzzle velocity=" + fixedPrecision(muzzle_velocity,0) + "m/s";104 llSay(0, mv);105 }106 }107108 //Invoked when the avatar 'sits' on the cannon.109 //Explains how to use,110 //Sets a time limit,111 //Gets permission for stuff,112 //Moves the camera113 //changes 'first_touch' to 1 indicating that avatar is in the cannon.115 {116 if(change & CHANGED_LINK)117 {118 instructions();119 llSetTimerEvent(60); //makes it reset itself after 1 minute120 // integer number;121 id = llAvatarOnSitTarget();122123 integer desired_controls =124 CONTROL_FWD |125 CONTROL_BACK |126 CONTROL_LEFT |127 CONTROL_RIGHT |128 CONTROL_ROT_LEFT |129 CONTROL_ROT_RIGHT |130 CONTROL_UP |131 CONTROL_DOWN;132133134 llRequestPermissions(id, PERMISSION_TAKE_CONTROLS );137138 llSetCameraParams([139 CAMERA_ACTIVE, 1, // 1 is active, 0 is inactive140 CAMERA_BEHINDNESS_ANGLE, 0.0, // (0 to 180) degrees141 CAMERA_BEHINDNESS_LAG, 0.0, // (0 to 3) seconds142 CAMERA_DISTANCE, 8.0, // ( 0.5 to 10) meters143 //CAMERA_FOCUS, <0,0,5>, // region relative position144 CAMERA_FOCUS_LAG, 0.05 , // (0 to 3) seconds146 CAMERA_FOCUS_THRESHOLD, 0.0, // (0 to 4) meters148 //CAMERA_POSITION, <0,0,0>, // region relative position149 CAMERA_POSITION_LAG, 0.1, // (0 to 3) seconds151 CAMERA_POSITION_THRESHOLD, 0.0, // (0 to 4) meters152 CAMERA_FOCUS_OFFSET, <3,0,2> // <-10,-10,-10> to <10,10,10> meters153 ]);154155 first_touch=1; //indicates that am inside156 }157 }158159 //If touching from the outside it explains that you have to get inside to use it. If touching from the inside it shoots.161 {162 if(first_touch==0)163 {164 llSay(0, "Hello.\n This is the person cannon - the best way to get around!\n To use me simply right click, climb inside and follow the instructions.");165 }166 else167 {168169 llUnSit(id);170 llPushObject(id, <muzzle_velocity*llCos(no_of_rotation_moves*angle_increment*DEG_TO_RAD)*llCos((no_of_inclination_moves*angle_increment)*DEG_TO_RAD),171 muzzle_velocity*llSin(no_of_rotation_moves*angle_increment*DEG_TO_RAD)*llCos((no_of_inclination_moves*angle_increment)*DEG_TO_RAD),173 llSleep(2);174 llResetScript();175 }176 }177178179 //resets the script180 timer()181 {182 llSay(0, "You've had your fun, script resetting.");183 llResetScript();184 }185186 }187 // END //
Back to the Best Free Tools in Second Life and OpenSim.