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
Pose Balls PB_Script_W__Voice  

PB_Script_W__Voice

PB Script W_ Voice.lsl

Category: Pose Balls
By : CrystalShard Foo
Created: 2010-01-10 Edited: 2010-01-10
Worlds: Second Life

the Zip file

Download all files for PB_Script_W__Voice
Contents are in zip format, with .LSL (text) source code and LSLEdit (text + Solution) formats.
Get file # 1. PB_Script_W__Voice_1.lsl
1
2 //Pose Ball script, Revision 4.3.1
3 //Notecard configuration enabled, switchable link_message/touch_start/llListen support, sit_text, floating text, alpha.
4 //Version 4.3 fixs link_set hide/show and permission sensing issues.
5
6 //By CrystalShard Foo.
7 //Work started - October 10th (2004).
8 //Last compile - November 7th (2004).
9
10 //Version 4.3.1 mods by Strife Onizuka
11 //Modified to fix logic holes in permissions code when used on multi-sittarget objects.
12 //Work started - Febuary 14th 2005.
13 //Last compile - Febuary 14th 2005.
14
15 //This script will let you choose if you want to turn the ball visible on CLICK, or by using a SHOW/HIDE voice command.
16 //You can also set the offset and the title of the ball, as well as the sit button text - all with a notecard.
17
18 //This script is free and comes without support. Dont contact me. Ask a local geek for help if it gets messy.
19
20 // ** This script is NOT FOR SALE **
21 //You can use it in commercial products as long as you give this script to anyone who asks for it.
22 //You can use this source, distribute it and modify it freely, but leave the credits intact!
23 //(You can add your own name to the list, ofcourse. Like, "Modified by John Doe")
24
25
26 vector ROTATION = <0,0,0>; //Euler in degrees (like the edit box)
27
28 string TITLE="NP"; //This text will appear in the floating title above the ball
29 string ANIMATION="HaxHover"; //Put the name of the pose/animation here!
30 vector offset=<0,0,0.5>; //You can play with these numbers to adjust how far the person sits from the ball. ( <X,Y,Z> )
31 integer use_voice = TRUE;
32
33 string gNotecard = "NP";
34 integer gLine = 0;
35
36 integer listenHandle = -1;
37 integer masterswitch = TRUE;
38 integer visible = TRUE;
39 float base_alpha = 1.0;
40 key avatar;
41 key trigger;
42
43 key dataserver_key = NULL_KEY;
44
45 show()
46 {
47 visible = TRUE;
48 llSetText(TITLE, <1,1,1>,1);
49 llSetAlpha(base_alpha, ALL_SIDES);
50 }
51
52 hide()
53 {
54 visible = FALSE;
55 llSetText("", <1,1,1>,1);
57 }
58
59 next_line()
60 {
61 gLine++;
62 dataserver_key = llGetNotecardLine(gNotecard,gLine);
63 }
64
65 use_defaults()
66 {
67 llSetSitText("Chill");
68 if(visible == FALSE)
69 llSetText("",<1,1,1>,1);
70 else
71 llSetText(TITLE,<1,1,1>,1);
72 }
73
74 init()
75 {
76
77 if(llGetInventoryNumber(INVENTORY_ANIMATION) == 0) //Make sure we actually got something to pose with.
78 {
79 llWhisper(0,"Error: No animation found. Cannot pose.");
80 ANIMATION = "sit";
81 }
82 else
84
85 integer i;
88 {
89 gLine = 0;
90 dataserver_key = llGetNotecardLine(gNotecard, 0);
91 return;
92 }
93 //If we are here no configuration notecard was found... lets use the defaults.
94 use_defaults();
95 }
96
97 default
98 {
100 {
101 llSetText("Starting up", <1,1,1>,1);
102 llSitTarget(offset, llEuler2Rot(ROTATION * DEG_TO_RAD));
103 init();
104 }
105
106 link_message(integer sender_num, integer num, string str, key id)
107 {
108 if(num == 99)
109 {
110 if(str == "show")
111 {
112 masterswitch = FALSE;
113 hide();
114 return;
115 }
116
117 if(str == "hide");
118 {
119 masterswitch = TRUE;
120 show();
121 }
122 }
123 }
124
125 touch_start(integer detected)
126 {
127 if(use_voice == FALSE)
128 {
129 if(visible == TRUE)
130 hide();
131 else
132 show();
133 }
134 else
135 llSay(0,llDetectedName(0)+", say '/1 Hide' to hide me, or '/1 Show' to make me show. Or just right-click and sit on me to use me.");
136 }
137
138 changed(integer change)
139 {
140 if(change & CHANGED_LINK)
141 {
142 avatar = llAvatarOnSitTarget();
143 if(llKey2Name(avatar) != "")
144 {
145 hide();
147 }
148 else
149 {
150 if(llKey2Name(llGetPermissionsKey()) != "" && trigger == llGetPermissionsKey())
151 {
152 llStopAnimation(ANIMATION);
153 trigger = NULL_KEY;
154 }
155 if(masterswitch == TRUE)
156 {
157 llSetAlpha(base_alpha,ALL_SIDES);
158 llSetText(TITLE,<1,1,1>,1);
159 }
160 }
161 }
162 if(change & CHANGED_INVENTORY)
163 {
164 llSetText("Reloading configuration...",<1,1,1>,1);
165 init();
166 }
167 }
168
170 {
171 avatar = llAvatarOnSitTarget();
172 if(perm & PERMISSION_TRIGGER_ANIMATION && llKey2Name(avatar) != "" && avatar == llGetPermissionsKey())
173 {
174 trigger = avatar;
175 llStopAnimation("sit");
176 llStartAnimation(ANIMATION);
177 if(visible == TRUE)
178 base_alpha = llGetAlpha(ALL_SIDES);
179 else
180 base_alpha = 1.0;
182 llSetText("",<1,1,1>,1);
183 }
184 }
185
186
187 listen(integer channel, string name, key id, string message)
188 {
189 if(llStringLength(message)!=4)
190 return;
191
192 message = llToLower(message);
193
194 if(message == "show")
195 {
196 show();
197 return;
198 }
199 if(message == "hide")
200 hide();
201 }
202
203 dataserver(key queryid, string data)
204 {
205 if(queryid != dataserver_key)
206 return;
207
208 if(data != EOF)
209 {
210 if(llGetSubString(data,0,0) != ";")
211 {
212 if(llGetSubString(data,0,5) == "title:")
213 {
214 TITLE = llGetSubString(data,7,-1);
215 next_line();
216 return;
217 }
218 if(llGetSubString(data,0,6) == "offset:")
219 {
220 integer length = llStringLength(data);
221 if(llGetSubString(data,8,8) != "<" || llGetSubString(data,length - 1,length) != ">")
222 {
223 llSay(0,"Error: The numbers in the offset value lack the '<' and '>' signs. (Should be something like <3,1,6> )");
224 offset = <0,0,0.5>;
225 }
226 else
227 offset = (vector)llGetSubString(data,8,-1);
228
229 if(offset == <0,0,0>)
230 offset = <0,0,0.01>;
232 next_line();
233 return;
234 }
235 if(llGetSubString(data,0,5) == "voice:")
236 {
237 string value = llGetSubString(data,7,-1);
238 value = llToLower(value);
239
240 if(listenHandle != -1)
241 {
242 llListenRemove(listenHandle);
243 listenHandle = -1;
244 }
245
246 if(value !="no" && value != "yes" && value != "true" && value != "false")
247 use_voice = FALSE;
248 else
249 if(value == "no" || value == "false")
250 use_voice = FALSE;
251 else
252 {
253 use_voice = TRUE;
254 listenHandle = llListen(1,"","","");
255 }
256 next_line();
257 return;
258 }
259 if(llGetSubString(data,0,10) == "sit_button:")
260 {
261 llSetSitText(llGetSubString(data,12,-1));
262 next_line();
263 return;
264 }
265 next_line();
266 }
267 }
268 else
269 {
270 if(visible == FALSE)
271 llSetText("",<1,1,1>,1);
272 else
273 llSetText(TITLE,<1,1,1>,1);
274 }
275 }
276 } // END //

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