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
Weapons Gun_Script  

Gun_Script

Gun Script.lsl

Category: Weapons
By : Anonymous
Created: 2010-01-10 Edited: 2010-01-10
Worlds: Second Life

the Zip file

Download all files for Gun_Script
Contents are in zip format, with .LSL (text) source code and LSLEdit (text + Solution) formats.
Get file # 1. Gun_Script_1.lsl
1
2 //
3 // This basic script acts as a gun, by doing the following:
4 //
5 // Attach gun to right hand so that aiming animation is correct.
6 //
7 //
8 vector pos;
9 rotation rot;
10 vector offset;
11
12 float BULLET_VELOCITY = 30.0;
13 float REPEAT_DELAY = 0.15;
14
15 default
16 {
18 {
19 if(perm)
20 {
23 llStartAnimation("hold_R_bazooka");
24 }
25 }
26
28 {
29
31 key on = llDetectedKey(0);
32 key avatar = llDetectedKey(0);
33 key owner = llGetOwner();
34 if(owner == avatar)
35 {
36 llWhisper(0, "Attach me to your right hand, and enter mouselook to fire!");
38 // {
40 // }
41 // else
42 // {
45 // llStartAnimation("hold_R_handgun");
46 // }
47 }
48 else
49 {
50 llWhisper(0, "Buy a copy and rez from your inventory and attach to your right hand to use.");
51 }
52 }
53
54 attach(key on)
55 {
56 if(on != NULL_KEY)
57 {
59
61 {
63 }
64 else
65 {
67 llStartAnimation("hold_R_bazooka");
68 }
69
70 }
71 else
72 {
74 llStopAnimation("hold_R_bazooka");
75 }
76 }
77
78 control(key owner, integer level, integer edge)
79 {
81 {
82 // Mouse down
84 {
85 // First Press - start sound loop and point
86 //llSay(0, "Start");
87 llLoopSound("gun", 2.0);
88 pos = llGetPos();
89 rot = llGetRot();
90 offset = <1.0, 0.0, 0.0>;
91 offset *= rot;
92 pos += offset;
93 llPointAt(pos);
94 }
95 // Fire 1 bullet
96 pos = llGetPos();
97 rot = llGetRot();
98 offset = <1.0, 0.0, 0.0>;
99 offset *= rot;
100 pos += offset;
101 llPointAt(pos);
102 vector fwd = llRot2Fwd(rot);
103 fwd *= BULLET_VELOCITY;
104 integer i = 5;
105 rot *= llEuler2Rot(<0, PI_BY_TWO, 0>);
106 llRezObject("Bullet 1.0", pos, fwd, rot, 1);
107 llSleep(REPEAT_DELAY);
108 }
109 else
110 {
112 {
113 // Stopped
114 //llSay(0, "Stop");
115 llLoopSound("gun", 0.0);
117 }
118 }
119
120 }
121 }
122 // END //

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