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
Tour Guide Tour_Guide  

Tour_Guide

This Tour Guide by Wandering Yaffle for Second Life turns a set of coordinates and notecards into an automated tour. The object hovers along a path, emitting chat lines at each stop and waiting to be touched to continue.

Place the following script and notecards in an object. Add a notecard for each stop in the tour. The "initialise" notecard contains the x,y,z coordinates and the names of notecards with chat lines. Waypoints with no comment are noted with ">". These are useful for going around walls, up stairways, etc.

Sample "initialise" notecard

Category: Tour Guide
By : Wandering Yaffle
Created: 2010-01-10 Edited: 2014-03-10
Worlds: Second Life

the Zip file

Download all files for Tour_Guide
Contents are in zip format, with .LSL (text) source code and LSLEdit (text + Solution) formats.
Get file # 1. Tour_Guide Script.lsl
1 anything goes here|<177,87,30>|Start the tour
2 line 2 is also ignored|<150,87,30>|This is line 2 and is chatted
3 ditto for line 3|<169,91,30>|
4 ciopy and paste these from chat|<177,87,30>|End of tour

Tour_Guide

The script

Category: Tour Guide
By : Wandering Yaffle
Created: 2010-01-10 Edited: 2014-03-10
Worlds: Second Life

1
2
3 // Revision:
4 // Ferd Frederix removed useless stuff
5
6 key RequestStops;
7 key GetIndexLines;
8 key ReadCard;
9
10 list Line = [];
11 list Locations = [];
12 list Descriptions = [];
13
14 integer IndexLines;
15 integer i = 0;
16 integer count = 0;
17 integer locationLength;
18 integer InitPerCent;
19 integer timeout = 0;
20
21 float OffsetLocx;
22 float OffsetLocy;
23 float OffsetLocz;
24
25 vector TempLocation;
26 vector CurrentLocation;
27 vector TargetLocation;
28
29 vector ownerpos;
30
31 string TempDescription;
32 string SpeechCard;
33 string owner;
34
35
36 default
37 {
38 on_rez(integer param)
39 {
41 }
42
44 {
47 //llSetStatus(STATUS_ROTATE_X | STATUS_ROTATE_Y | STATUS_ROTATE_Z, FALSE);
48 llSetColor(<1,0,0>, ALL_SIDES);
49 RequestStops = llGetNumberOfNotecardLines("Initialise");
50 GetIndexLines = llGetNotecardLine("Initialise",0);
51 CurrentLocation = (llGetPos());
52 OffsetLocx = llRound(CurrentLocation.x);
53 OffsetLocy = llRound(CurrentLocation.y);
54 OffsetLocz = llRound(CurrentLocation.z);
55 llSetPos(<OffsetLocx, OffsetLocy, OffsetLocz>);
56 llSay(0, "Tour guide initialising. Please wait.");
57
58 }
59
60 dataserver(key queryid, string data)
61 {
62 if(queryid == RequestStops)
63 {
64 IndexLines = (integer) data;
65 }
66
67 if(queryid == GetIndexLines)
68 {
69
70 if(data != EOF)
71 {
72 queryid = llGetNotecardLine("Initialise", i);
73 Line = (llParseString2List(data, ["|"], []));
74 string junk = llList2String(Line, 0);
75 TempLocation = (vector) llList2String(Line, 1);
76 Locations = Locations + [TempLocation];
77 TempDescription = llList2String(Line, 2);
78 Descriptions = Descriptions + [TempDescription];
79 locationLength = (llGetListLength(Locations));
80 InitPerCent = (integer) llRound(((float) locationLength / (float) IndexLines) * 100);
81 llSetText("Initialising... \n" + (string) InitPerCent + "%" , <1,1,1>, 1.0);
82 if(InitPerCent == 100)
83 {
84 state moving;
85 }
86 i++;
87 }
88 GetIndexLines = llGetNotecardLine("Initialise",i);
89
90
91 }
92
93 }
94
95 touch_start(integer total_number)
96 {
97 integer check = llGetListLength(Locations);
98
99 if(check >= IndexLines)
100 {
101 owner = llDetectedName(0);
102 state moving;
103 }
104
105 if(check < IndexLines)
106 {
107 llSay(0, "Hang on a sec, still initialisng...");
108 }
109 }
110
112 {
113 llSetText("", <1,1,1>, 1.0);
114 TargetLocation = (vector) llList2String(Locations, count);
115 }
116 }
117
118 state moving
119 {
120
122 {
124 llSetColor(<0,1,1>, ALL_SIDES);
125 CurrentLocation = (llGetPos());
126 llSetTimerEvent(0.5);
127 llLookAt(TargetLocation, 1, .5);
128 }
129
130
131 timer()
132 {
133 timeout = timeout + 1;
134 CurrentLocation = (llGetPos());
135 //llSetText("Timeout... \n" + (string) timeout, <1,1,1>, 1.0);
136
137 if(llVecMag(llGetPos() - TargetLocation) > .49999)
138 {
139 if(timeout > 50) // Time Out to contingency
140 {
141 state setposition;
142 }
143 llMoveToTarget((llVecNorm(TargetLocation - llGetPos()) * 1) + llGetPos(), .5);
144 //llSay(0,"Looking at target location: " + (string) TargetLocation);
145 }
146
147 if(llVecMag(llGetPos() - TargetLocation) < .49999)
148 {
149 state speaking;
150 }
151
152
153 }
154
156 {
157 SpeechCard = llList2String(Descriptions, count);
159 timeout = 0;
160 i = 0;
161 }
162
163 }
164
165 state setposition //contingency
166 {
168 {
170 CurrentLocation = (llGetPos());
171 llSetTimerEvent(0.5);
172 }
173
174 timer()
175 {
176 if(llVecMag(llGetPos() - TargetLocation) > .49999)
177 {
178 llSetPos((llVecNorm(TargetLocation - llGetPos()) * 0.5) + llGetPos());
179 llLookAt(TargetLocation, 10, 10);
180 }
181
182 if(llVecMag(llGetPos() - TargetLocation) < .49999)
183 {
184 state speaking;
185 }
186
187 }
189 {
190
191 timeout = 0;
193
194 }
195
196 }
197
198 state speaking
199 {
200
202 {
203 llSetColor(<0,0,1>, ALL_SIDES);
204 llSetTimerEvent(0.5);
205 if(SpeechCard == ">")
206 {
207 count = count +1;
208 if(count > (IndexLines - 1))
209 {
210 state end;
211 }
212 if(count <= (IndexLines - 1))
213 {
214 TargetLocation = (vector) llList2String(Locations, count);
215 state moving;
216 }
217 }
218 ReadCard = llGetNotecardLine(SpeechCard,i);
219 }
220
221 sensor(integer total_number)
222 {
223 ownerpos = llDetectedPos(0) + <0,0,.7>;
224 }
225
226 dataserver(key queryid, string data)
227 {
228
229 if(queryid == ReadCard)
230 {
231 if(data != EOF)
232 {
233 llSay(0, data);
234 queryid = llGetNotecardLine(SpeechCard, i);
235 llSleep(2);
236 i++;
237 }
238 ReadCard = llGetNotecardLine(SpeechCard,i);
239 }
240
241 }
242
243 timer()
244 {
245 llSensor(owner, NULL_KEY, AGENT, 10, PI);
246 llLookAt(ownerpos, .05, 1);
247 timeout = timeout + 1;
248 if(timeout == 600)
249 {
250 llSay(0, "Bored now. Click me to continue!");
251 }
252
253 if(timeout > 800)
254 {
255 llSay(0, "No response. Ending tour.");
256 state end;
257 }
258 }
259
260 touch_start(integer total_number)
261 {
262
263 count = count +1;
264 if(count > (IndexLines - 1))
265 {
266 state end;
267 }
268 if(count <= (IndexLines - 1))
269 {
270 TargetLocation = (vector) llList2String(Locations, count);
271 state moving;
272 }
273 }
274
276 {
278 timeout = 0;
279 }
280
281 }
282
283 state end
284 {
286 {
287 llSay(0, "This concludes the tour. Terminating.");
288 llDie();
289 }
290
291 }

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