Join us in Outworldz at www.outworldz.com:9000 or follow us:

Search dozens of selected web sites for OpenSim and LSL script

New! Script Meta-Search will search thousands of scripts here and at other sites for LSL or Opensim scripts.
Loading

Want to add a script or a project? Upload it and a half million people will see it and your name here this year.

Home   Show All
Category: Contributor: Creator
Helicopter Helicopter scripts  

Helicopter scripts

controller

Category: Helicopter
By : Anonymous
Created: 2013-09-06 Edited: 2013-09-04
Worlds: Second Life

the Zip file

Download all files for Helicopter scripts
Contents are in zip format, with .LSL (text) source code and LSLEdit (text + Solution) formats.
Get file # 1. controller.lsl
Get file # 2. link message for seat.lsl
Get file # 3. seat.lsl
Get file # 4. Simple bullet rezzer.lsl
1
2
3 ////////////////////////////////////////////////////////////////
4
5 integer HUD = 87654567; // the secret channel the HUD is own
6 float ROTATION_RATE = 1.0; // Rate of turning
7 float FWD_THRUST = 25; // Forward thrust motor force
8 float BACK_THRUST = 25; // Backup thrust
9 float VERTICAL_THRUST = 15;
10 vector linear_motor = <0,0,0>; // Keep a running linear motor value for better response
11
12
13 default {
14
15 // this runs first after a reset
16 state_entry() {
17
18 llListen(HUD,"","",""); // listen for HUD commands
19 llListen(0,"",llGetOwner(),""); // listen for owner on channel 0
20
21 llSitTarget(<0.1, 0.0, 1.95>, ZERO_ROTATION);
22
24
29
30 llSetVehicleFloatParam(VEHICLE_LINEAR_MOTOR_TIMESCALE, 0.2);
33 llSetVehicleFloatParam(VEHICLE_ANGULAR_MOTOR_DECAY_TIMESCALE, 0.1);
34
41
44
48
49 llSetCameraEyeOffset(<-7.0, 0.0, 3.0>);
50 llSetSitText("RAH-66");
51 llSetCameraAtOffset(<0.5, 0, 0>);
52 }
53
54 changed(integer change) {
55 if(change & CHANGED_LINK) {
56 key agent = llAvatarOnSitTarget();
57 if(agent) {
58 if(agent != llGetOwner()) {
59 // only the owner can use this vehicle
60 llSay(0, "You aren't the owner of this Comanche.");
61 llUnSit(agent);
62 llPushObject(agent, <0,0,10>, ZERO_VECTOR, FALSE);
63 } else {
64 // driver is entering the vehicle
65 llOwnerSay("type 'start' to begin fying");
67 }
68 } else {
69 // driver is getting up
72 }
73 }
74 }
75
76
77 listen(integer channel, string name, key id, string message)
78 {
79 if(llToLower(message) == "start") {
80 // owner or HUD spoke 'STart' or START or start
81 llMessageLinked(LINK_SET,0,"start",""); // send to any other scripts
83 } else if(llToLower(message) == "stop") {
84 llMessageLinked(LINK_SET,0,"stop",""); // send 'stop' to any other scripts
87 }
88 }
89
92
95 }
96 }
97
98
99 link_message(integer sender_number, integer number, string message, key id)
100 {
101 // incoming link messages appar here, so you can control this script from other scripts.
102 }
103
104 control(key id, integer level, integer edge) {
105 if(level & (CONTROL_LEFT | CONTROL_ROT_LEFT)) {
107 } else if(edge & (CONTROL_LEFT | CONTROL_ROT_LEFT)) {
109 }
114 }
115
116 if(level & CONTROL_FWD) {
117 linear_motor.x = FWD_THRUST;
118 } else if(edge & CONTROL_FWD) {
119 linear_motor.x = 0;
120 }
121 if(level & CONTROL_BACK) {
122 linear_motor.x = -BACK_THRUST;
123 } else if(edge & CONTROL_BACK) {
124 linear_motor.x = 0;
125 }
126
127 if(level & CONTROL_UP) {
128 linear_motor.z = VERTICAL_THRUST;
129 } else if(edge & CONTROL_UP) {
130 linear_motor.z = 0;
131 }
132 if(level & CONTROL_DOWN) {
133 linear_motor.z = -VERTICAL_THRUST;
134 } else if(edge & CONTROL_DOWN) {
135 linear_motor.z = 0;
136 }
138
139 }
140 }

Helicopter scripts

link message for seat

Category: Helicopter
By : Anonymous
Created: 2013-09-06 Edited: 2013-09-04
Worlds: Second Life

1
2 integer sit;
3 key pilot;
4
5 integer listenState( integer listener){ return 1;}
6
7 default
8 {
10 {
11 llSay(0, "Hello, Avatar!");
12 }
13 // DETECT AV SITTING/UNSITTING AND GIVE PERMISSIONS
14 link_message(integer sender_number, integer number, string message, key id)
15 {
16
17 if(message == "pilot" & id == NULL_KEY) // no id, means they unsat
18 {
20 llStopAnimation("recline sit");
21 llMessageLinked(LINK_SET, 0, "unseated", "");
24 sit = FALSE;
25 listenState(FALSE);
26
27 }
28
29 else if(message == "pilot" & id != NULL_KEY) // id, means they sat
30 {
31 // Avatar gets on vehicle
32
33 pilot = id ;
34 sit = TRUE;
36 listenState(TRUE);
37 llWhisper(0,"Comanche Pilot, "+llKey2Name(pilot)+", with your HUD attached, Select Start Engine to begin Flight, type help for additional assistance.");
38 llMessageLinked(LINK_SET, 0, "seated", "");
39 }
40
41 // more ifs and code can go here to detect other link message
42
43 }
44
45
46
47 }

Helicopter scripts

seat prim

Category: Helicopter
By : Anonymous
Created: 2013-09-06 Edited: 2013-09-04
Worlds: Second Life

1
2 integer sit;
3 key pilot;
4
5 integer listenState( integer listener){ return 1;}
6
7 default
8 {
10 {
11 llSay(0, "Hello, Avatar!");
12 }
13 // DETECT AV SITTING/UNSITTING AND GIVE PERMISSIONS
14 link_message(integer sender_number, integer number, string message, key id)
15 {
16
17 if(message == "pilot" & id == NULL_KEY) // no id, means they unsat
18 {
20 llStopAnimation("recline sit");
21 llMessageLinked(LINK_SET, 0, "unseated", "");
24 sit = FALSE;
25 listenState(FALSE);
26
27 }
28
29 else if(message == "pilot" & id != NULL_KEY) // id, means they sat
30 {
31 // Avatar gets on vehicle
32
33 pilot = id ;
34 sit = TRUE;
36 listenState(TRUE);
37 llWhisper(0,"Comanche Pilot, "+llKey2Name(pilot)+", with your HUD attached, Select Start Engine to begin Flight, type help for additional assistance.");
38 llMessageLinked(LINK_SET, 0, "seated", "");
39 }
40
41 // more ifs and code can go here to detect other link message
42
43 }
44
45
46
47 }

Helicopter scripts

bullet rezzer

Category: Helicopter
By : Anonymous
Created: 2013-09-06 Edited: 2013-09-04
Worlds: Second Life

1
2 // simple cannon pointer script
3 // just go into mouselook, it will point wherever you look
4 // mouse button rezzes a bullet. Release the button to stop firing.
5 // can only fire 10 rounds per second, max.
6 // the bullet will be fired from center of the entire bullet or missile. To have the bullet rez from the center of the root prim,
7 // change llRezObject to llRezAtRoot instead.
8
9 integer debugon = FALSE; // set to TRUE for debug to owner only.
10
11 vector ANGLE = <0,0,90> ; // used to point the gun 90 degrees rotated around the Z axis, this may need to be changed. It depends upon your prim and how the gun sticks out of it.
12
13 string shoot = "shoot"; // the sound it makes when firing, must be in inventory. You can change this to:
14 // key shoot = "12345000-0000-0000-0000-000000000001"; // where this is a copied UUID from your inventory and then there is no need to give away the sound file.
15
16 // The avatar must be within 2 meters of the gun script, or it will not aim or fire
17 // the original value was 20, which is horrible laggy in comparison as it must scan an area 4 * PI R squared larger ( 100 times more work), for no good reason!
18 // But if it is made larger, you can shoot the gun from a greater distance
19 float DISTANCE = 2; // Make this as small as possible to control lag
20
21 float SPEED = 40.0; // how fast the bullet flies away, this is really fast! For a missile, set it to 0 and make the missile do its own acceleration
22
23
24 // code bgins
25 // general purpose Debug("some message");
26 Debug( string msg)
27 {
28 if(debugon)
29 llOwnerSay(msg);
30 }
31
32
33 default
34 {
36 {
37 // normally, this little bit of code is disabled by FALSE. It can be deleted entirely. But it is extremely handy!
38
39 // This routine lets you change hard coded rotations to vectors so humans can work on them
40 // It does not run unless you set this to TRUE
41 // When it runs, it takes whatever crap quaternionhas been copied from old code into a vector
42 // It prints the vector in degrees
43
44 // a crap quaternionlooks like this, and has 4 numbers:
45 // <0.00000, 0.00000, 0.70711, 0.70711> // bet you didn't know this is a rotation of 90 degrees around the Z axis!
46
47 // sample output when set to TRUE:
48 // original:<0.00000, 0.00000, 0.70711, 0.70711> This was the original, copied quaternion
49 // replacement:<0.00000, 0.00000, 90.00000> aha, its a 90 degree rotation about Z
50
51 // How to use it: Whenever you see a rotation hard-coded in like this, don't cuss at the programmer, they didn't know better.
52 // llSetRot(<-0.00000, -0.00000, 0.70711, 0.70711>);
53 // Paste the old crap rotation <..> in the arot line below, set the variable to TRUE, and then change the script to this line, where the <0,0,90> is whatever the script spits out:
54
55 // llSetRot(llEuler2Rot(<0,0,90> * DEG_TO_RAD)); // change <0,0,90> to the vector form
56 // much easier to change and the same as this unreadable crap:
57 // llSetRot(<-0.00000, -0.00000, 0.70711, 0.70711>);
58
59 // one last thing: <0.00000,0.0000, 0.00000, 1.0000> ( 0,0,0,1) is a ZERO rotation, or <0,0,0> as a vector. That's easy to remember so you can just change it to llSetRot(ZERO_VECTOR);
60
61 // you can comment this all out, but there is really no need, it just saves a few bytes of memory if you comment it out
62 if(FALSE) // set to TRUE to conver any 4-vector quaternioninto a human readable 3-unit vector.
63 {
64 rotation arot = <0.00000, 0.00000, 0.70711, 0.70711>; // replace this with your crappy quaternion
65 llOwnerSay("original:" + (string) arot);
66
67 vector in_degrees = llRot2Euler(arot);
68 in_degrees *= RAD_TO_DEG;
69 llOwnerSay("replacement:" + (string) in_degrees); // output it as a vector in degrees instead of radians.
70 }
71 }
72
73
74 touch_start(integer total_number)
75 {
76 integer i;
77 // MUST scan over all people who touch, and only allow the owner to fire the weapon.
78 // many people can click at the same time, how many is in total_number
79 for (i = 0; i < total_number; i++)
80 {
81 // See if this person is the owner
83 {
85 Debug("Requesting Permissions");
86 }
87 }
88 }
89
90
91 touch_end(integer total_number)
92 {
93 integer i;
94 for (i = 0; i < total_number; i++)
95 {
96 // See if this person is the owner
98 {
101 llSetRot(llEuler2Rot(ANGLE * DEG_TO_RAD));
102 Debug("stopped firing");
103 }
104 }
105 }
106
107 sensor(integer sense)
108 {
110 llRotLookAt(k, 0.1, 0.1);
111 }
112
113 // oh dear, the avatar is out of range
114 no_sensor()
115 {
118
119 llSetRot(llEuler2Rot(ANGLE * DEG_TO_RAD)); // this is the same as the following line, but easily changed
120 //llSetRot(<-0.00000, -0.00000, 0.70711, 0.70711>); // old crap code, actually <0.00000, 0.00000, 90.00000>
121 Debug("No Owner nearby, check the DISTANCE variable");
122
123 }
125 {
127 {
128 Debug("Permissions to take controls has been granted");
130 llSensorRepeat("", llGetOwner(), AGENT, DISTANCE, TWO_PI, 0.1); // look for the owner only
131 }
132 }
133
134 control(key name, integer levels, integer edges)
135 {
136 // mouse left button pressed
137 if(levels & CONTROL_ML_LBUTTON)
138 {
139 rotation rot = llGetRot(); // mouselook rotation
140 vector vel = llRot2Fwd(rot); // forward direction only
141 vector pos = llGetPos(); // gun position
142 pos = pos + vel; // add to gun position the forward direction
143 pos.z += 0.0; // worthless by adding a 0, but by changing 0.0 to another number you can fire higher or lower than the prim this script is in.
144 vel = vel * SPEED; // multiply all 3 coordinates by the constant SPEED to set a bullet speed.
145 llTriggerSound(shoot, 1.0);
146 llRezObject("bullet", pos, vel, rot, 1); // sends a 1 to the bullet, to the on_rez(integer start_param)
147 }
148 }
149
150 }

Back to the Best Free Tools in Second Life and OpenSim.