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 MultiGun  

MultiGun

MultiGun

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

the Zip file

Download all files for MultiGun
Contents are in zip format, with .LSL (text) source code and LSLEdit (text + Solution) formats.
Get file # 1. MultiGun_1.lsl
1 // From the book:
2 //
3 // Scripting Recipes for Second Life
4 // by Jeff Heaton (Encog Dod in SL)
5 // ISBN: 160439000
6 X// Copyright 2007 by Heaton Research, Inc.
7 //
8 // This script may be freely copied and modified so long as this header
9 // remains unmodified.
10 //
11 // For more information about this book visit the following web site:
12 //
13 // http://www.heatonresearch.com/articles/series/22/
14
15 integer CHANNEL = 44;
16 float SPEED = 80.0;
17 float DELAY = 0.2;
18 vector vel;
19 vector pos;
20 rotation rot;
21 integer have_permissions = FALSE;
22 integer armed = TRUE;
23
24 string bulletName = "bullet:Blank";
25
26
27 fire()
28 {
29 if(armed)
30 {
31 armed = FALSE;
32 rot = llGetRot();
33 vel = llRot2Fwd(rot);
34 pos = llGetPos();
35 pos = pos + vel;
36 pos.z += 0.75;
37
38 vel = vel * SPEED;
39
40 llTriggerSound("shoot", 1.0);
41 llRezObject(bulletName, pos, vel, rot, 10);
42
43 llSetTimerEvent(DELAY);
44 }
45 }
46
47 load()
48 {
49 list bulletList = [];
50 string bullet = "";
51 integer i = 0;
52 do
53 {
55
56 if( bullet!="" )
57 {
58 list cmd = llParseString2List(bullet,[":"],[]);
59
60 if( llList2String(cmd,0)=="bullet" )
61 bulletList+=llList2String(cmd,1);
62 }
63 i++;
64 } while( bullet!="" );
65 llDialog(llGetOwner(),"Choose a bullet type:",bulletList,CHANNEL);
66 }
67
68 default
69 {
71 {
72 if(!have_permissions)
73 {
76 }
77 llListen(0,"",llGetOwner(),"");
78 llListen(CHANNEL,"",llGetOwner(),"");
79 llOwnerSay("Say 'load' to change bullet type");
80 }
81 on_rez(integer param)
82 {
83 llPreloadSound("shoot");
84 }
85
86 run_time_permissions(integer permissions)
87 {
89 {
91 llStartAnimation("hold_R_handgun");
92 have_permissions = TRUE;
93 }
94 }
95
96 listen(integer channel, string name, key id, string message)
97 {
98 if( id==llGetOwner() && channel ==0 )
99 {
100 if( llToLower(message) == "load" )
101 {
102 load();
103 }
104 }
105 else if( channel==CHANNEL )
106 {
107 bulletName = "bullet:" + message;
108 llOwnerSay(message + " now loaded");
109 }
110 }
111
112
113
114 attach(key attachedAgent)
115 {
116 if(attachedAgent != NULL_KEY)
117 {
120 }
121 else
122 {
123 if(have_permissions)
124 {
125 llStopAnimation("hold_R_handgun");
126 llStopAnimation("aim_R_handgun");
128 llSetRot(<0,0,0,1>);
129 have_permissions = FALSE;
130 }
131 }
132 }
133
134 control(key name, integer levels, integer edges)
135 {
137 &&((levels & CONTROL_ML_LBUTTON) == CONTROL_ML_LBUTTON) )
138 {
139 fire();
140 }
141 }
142
143 timer()
144 {
145 llSetTimerEvent(0.0);
146 armed = TRUE;
147 }
148
149 }
150

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