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 Popgun  

Popgun

Popgun.lsl

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

the Zip file

Download all files for Popgun
Contents are in zip format, with .LSL (text) source code and LSLEdit (text + Solution) formats.
Get file # 1. Popgun_1.lsl
1
2 //
3 // Popgun
4 //
5
6 float RECHARGE_TIME = 1.5;
7 float BASE_POWER = 25.0;
8
9 float last_time = 0.0;
10 vector fwd;
11 vector pos;
12 quaternionrot;
13 float power = 1.0;
14 key holder; // Key of avatar holding gun
15 integer hListen = 0;
16
17 integer permissions = FALSE;
18 integer attached = FALSE;
19
20 fire_ball()
21 {
22 //
23 // Actually fires the ball
24 //
25 rot = llGetRot();
26 fwd = llRot2Fwd(rot);
27 pos = llGetPos();
28 pos = pos + fwd;
29 pos.z += 0.75; // Correct to eye point
30 fwd = fwd * BASE_POWER*power;
31 // llTriggerSound("tube", 1.0);
32 // llSay(0, "Boom!");
33 llRezObject("webshot", pos, fwd, <0,0,0,1>, 2);
34 last_time = llGetTime();
35 llSetTimerEvent(0.1);
36 }
37 hover()
38 {
39 //
40 // Spin at current position
41 //
42 //llTargetOmega(<0,0,1>, 1.0, 0.5);
43 }
44
45 no_hover()
46 {
47 //llTargetOmega(<0,0,1>, 0.0, 0.5);
48 }
49
50 default
51 {
53 {
54 //llSay(0, "Popgun, v1.0");
55 hover();
56 }
57 run_time_permissions(integer permissions)
58 {
59 if(permissions > 0)
60 {
61 // llSay(0, "Enter Mouselook to shoot me!");
62
63 llSetLinkColor(3, <1,1,0>, -1);
65 permissions = TRUE;
66 }
67 }
68 touch_start(integer total_number)
69 {
70 if(!attached)
71 {
72 //
73 // If clicked and not attached, ask to attach to avatar
74 //
75 key avatar = llDetectedKey(0);
76 key owner = llGetOwner();
77 if(owner == avatar)
78 {
79 // llSetText("Attach me to your right hand to use", <0,1,0>, 0.5);
80 llSleep(1.0);
81 llSetText("", <1,1,1>, 1.0);
82 }
83 else
84 {
85 // llSetText("$ Buy Me! $", <0,1,0>, 0.5);
86 llSleep(1.0);
87 llSetText("", <1,1,1>, 1.0);
88 }
89 return;
90 }
91
94 }
95
96 attach(key attachedAgent)
97 {
98 //
99 // If attached/detached from agent, change behavior
100 //
101 if(attachedAgent != NULL_KEY)
102 {
103 // llTriggerSound("switch", 1.0);
104 if(!permissions)
105 {
107 }
108 attached = TRUE;
109 no_hover();
110 }
111 else
112 {
113 // llTriggerSound("switch", 1.0);
114 attached = FALSE;
116 hover();
117
118 }
119 }
120
121 control(key name, integer levels, integer edges)
122 {
124 &&((levels & CONTROL_ML_LBUTTON) == CONTROL_ML_LBUTTON) )
125 {
126 fire_ball();
127 }
128 }
129 timer()
130 {
131 float current_time = llGetTime();
132 if((current_time - last_time) < RECHARGE_TIME)
133 {
134 power = (current_time - last_time)/RECHARGE_TIME;
135 // llSetLinkColor(3, <power,power,0>, -1);
136 }
137 else
138 {
139 power = 1.0;
140 // llSetLinkColor(3, <1,1,1>, -1);
141 llSetTimerEvent(0.0);
142 // llTriggerSound("splat3",1.0); // Play sound to indicate 'fully charged'
143 }
144 }
145 }
146 // END //

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