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 BasicGun  

BasicGun

BasicGun

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

the Zip file

Download all files for BasicGun
Contents are in zip format, with .LSL (text) source code and LSLEdit (text + Solution) formats.
Get file # 1. BasicGun_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 float SPEED = 80.0;
16 integer LIFETIME = 7;
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";
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, LIFETIME);
42
43 llSetTimerEvent(DELAY);
44 }
45 }
46
47 default
48 {
50 {
51 if(!have_permissions)
52 {
55 }
56 }
57 on_rez(integer param)
58 {
59 llPreloadSound("shoot");
60 }
61
62 run_time_permissions(integer permissions)
63 {
65 {
67 llStartAnimation("hold_R_handgun");
68 have_permissions = TRUE;
69 }
70 }
71
72 attach(key attachedAgent)
73 {
74 if(attachedAgent != NULL_KEY)
75 {
78 }
79 else
80 {
81 if(have_permissions)
82 {
83 llStopAnimation("hold_R_handgun");
84 llStopAnimation("aim_R_handgun");
86 llSetRot(<0,0,0,1>);
87 have_permissions = FALSE;
88 }
89 }
90 }
91
92 control(key name, integer levels, integer edges)
93 {
95 &&((levels & CONTROL_ML_LBUTTON) == CONTROL_ML_LBUTTON) )
96 {
97 fire();
98 }
99 }
100
101 timer()
102 {
103 llSetTimerEvent(0.0);
104 armed = TRUE;
105 }
106
107 }
108

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