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
Books HoloReader_Book_using_Particles  

HoloReader_Book_using_Particles

HoloReader_Book_using_Particles

Category: Books
By : Moriash Moreau
Created: 2010-11-18 Edited: 2010-11-18
Worlds: Second Life

the Zip file

Download all files for HoloReader_Book_using_Particles
Contents are in zip format, with .LSL (text) source code and LSLEdit (text + Solution) formats.
Get file # 1. HoloReader_Book_using_Particles_1.lsl
1 // Simplified HoloReader by Moriash Moreau, August 2005
2 // You may use this script for whatever purpose you like,
3 // provided it is legal and obeys the Terms of Service
4 // for Second Life. Please include the above information
5 // in any scripts derived from the following code.
6
7 // GENERAL USE
8 // Place this script and the textures for the book pages
9 // inside your book prim. The Z axis for the book prim
10 // should ideally point straight upward. Note that
11 // face 1 of the prim will be updated to show the next
12 // page each time the pages are flipped. This is so
13 // that the next page is loaded into the user's image
14 // cache. Ideally, the cover would be face 0 (top, or
15 // positive Z direction), and face 1 would be the bottom
16 // edge of the book. Your book design should take
17 // this preloading behavior into account.
18 // Note also that the object description line is used
19 // to store bookmark data.
20 // Note that the texture pages MUST be in alphabetical
21 // order, with the cover/title page as the first.
22 // They must also be the ONLY textures in the inventory.
23
24 // MODIFY THESE VALUES FOR YOUR BOOK.
25
26 // Set X equal to the desired width, Y to desired height.
27 // This size is in meters, with a max size of 4.0m in either dimension.
28 // Adjust as needed to keep height-to-width ratio right for
29 // the book pages. (The Z coordinate doesn't matter, but it
30 // needs to be there for vector formatting. Leave it at zero.)
31 // For example, <1.0,1.5,0> would be 1 meter wide by 1.5 meters tall.
32 // You'll have to look at the original sizes of the pre-upload
33 // images to determine this. All the pages must be the
34 // same size.
35
36 vector PageScale = <0.5,1.0, 0>;
37
38 // BaseOffset is the minimum height above the book page. This is
39 // mostly a matter of aesthetics. It controls how
40 // high the CENTER of the page will be above the
41 // book artifact. You'll want to at least clear
42 // the top of the book and the floating text for
43 // the page numbers.
44
45 float BaseOffset = 0.8;
46
47 // INTERNAL SYSTEM VARIABLES
48 // Do not modify.
49 string Page;
50 string NextPage;
51 string Description;
52 string FlickerMessage;
53 integer count = 0;
54 integer BookMark = 1;
55 integer PageCount;
56 integer ParticleCount = 8;
57 integer CommChannel;
58 integer Listener;
59 key BookUser;
60 float Offset;
61 vector Height;
62 integer Flicker = FALSE;
63
64 TakeControls()
65 {
66 llInstantMessage(BookUser,"Use Page Up and Page Down to turn pages. Best read in Mouselook.");
67 llInstantMessage(BookUser,"Touch again to bring up the additional functions menu.");
68 // Capture the page up and page down keys. Note that these keys will NOT perform their normal
69 // functions while these keys are captured.
71 }
72
73 // Check to see if we have PERMISSION_TAKE_CONTROLS. If so,
74 // take the controls, if not, request the permission
75 Init()
76 {
77 integer nMyPerms;
78 nMyPerms = llGetPermissions();
80 {
81 TakeControls();
82 }
83 else
84 {
86 }
87 }
88
89 SetPage()
90 {
91 // Set the floating text to show the page number.
92 if(count == 0)
93 {
94 llSetText("Cover",<0,0,0>,1.0);
95 }
96 else
97 {
98 llSetText("Page " + (string)count,<0,0,0>,1.0);
99 }
100 // Read the next two pages from the inventory.
102 if(count == PageCount || count == (PageCount - 1))
103 {
105 }
106 else
107 {
108 NextPage = llGetInventoryName(INVENTORY_TEXTURE, count + 1);
109 }
110 ShowPage();
111 llSetTexture(NextPage, 1);
112 }
113
114 MainMenu()
115 {
116 CommChannel = (integer)(llFrand(314159) + 1);
117 llDialog(BookUser,"Additional Book Functions:", ["Mark Page", "To Mark", "Flicker?", "Close Book"],CommChannel);
118 Listener = llListen(CommChannel,"",BookUser,""); // listen for the dialog answer
119 }
120
121 FlickerMenu()
122 {
123 CommChannel = (integer)(llFrand(420000) + 1);
124 FlickerMessage = "If the pages are flickering, try changing the particle count. Current particle count is " + (string)ParticleCount + ". Set the particle count to the minimum number necessary to remove flicker on your system.";
125 llDialog(BookUser, FlickerMessage, ["4", "8", "12", "16", "20", "24"],CommChannel);
126 Listener = llListen(CommChannel,"",BookUser,""); // listen for the dialog answer
127 }
128
129
130 ShowPage()
131 {
134 // Appearance Settings
135 PSYS_PART_START_SCALE,(vector) PageScale,
136 PSYS_PART_END_SCALE,(vector) PageScale,
142 // Time/Rate Settings
143 PSYS_SRC_BURST_PART_COUNT,(integer) ParticleCount, // # of particles per burst
144 PSYS_SRC_BURST_RATE,(float) 0.1, // delay between bursts
145 PSYS_PART_MAX_AGE,(float) 1.2, // particle life
147 // Placement Settings
149 PSYS_SRC_BURST_RADIUS,(float) Offset, // How far from the book the particles start
152 PSYS_SRC_OMEGA,(vector) <0,0,0>,
153 // Movement Settings
154 PSYS_SRC_ACCEL,(vector) <0,0,0>,
158 PSYS_PART_EMISSIVE_MASK | // particles glow
159 0
160 ] );
161 }
162
163 default
164 {
166 {
169 // Check the number of pages (textures) in inventory.
171 llSetText("",<0,0,0>,1.0);
172 }
173
174 on_rez(integer start_param)
175 {
179 llSetText("",<0,0,0>,1.0);
180 }
181
182 touch_start(integer total_number)
183 {
184 Height = llDetectedPos(0) - llGetPos() + llGetAgentSize(BookUser)*0.6;
185 Offset = Height.z - BaseOffset;
186 if(Offset < BaseOffset)
187 {
188 Offset = BaseOffset;
189 }
190 BookUser = llDetectedKey(0);
191 state read;
192 }
193 }
194
195 state read
196 {
198 {
201 // Keep an eye on the user. Later, we'll kill the book
202 // if he walks out of range.
203 llSensorRepeat(llKey2Name(BookUser), BookUser, AGENT, 6, PI, 30);
204 Init();
205 count = 0;
206 SetPage();
207 }
208
209 // Return to standby/default mode if the book was copied/taken
210 // while it was in operation.
211 on_rez(integer start_param)
212 {
213 state default;
214 }
215
216 // If the touch is from the current user, call the functions menu.
217 // If not, inform the toucher that the book is in use.
218 // Use a random channel each time, to prevent the dialog
219 // box from being misdirected later on.
220 touch_start(integer total_number)
221 {
222 if(llDetectedKey(0) == BookUser)
223 {
224 MainMenu();
225 }
226 else
227 {
228 llInstantMessage(llDetectedKey(0),"This book is currently in use.");
229 }
230 }
231
232 // Process our various dialog box responses.
233 listen(integer channel, string name, key id, string message)
234 {
235 if(message == "Close Book")
236 {
239 llSleep(1.0);
240 BookUser = "";
241 state default;
242 }
243 else if(message == "Mark Page")
244 {
245 // Save the current page number to the object description line.
246 if(BookUser == llGetOwner())
247 {
248 BookMark = count;
249 llSetObjectDesc("Marked on page " + (string)BookMark + ".");
250 llInstantMessage(BookUser, "Bookmarking page " + (string)BookMark + ".");
251 }
252 else
253 {
254 llInstantMessage(BookUser,"Only the owner of this book can set the bookmark.");
255 }
256 }
257 else if(message == "To Mark")
258 {
259 Description = llGetObjectDesc();
260 count = (integer)llGetSubString(Description, 15, llStringLength(Description) - 2);
261 SetPage();
262 llInstantMessage(BookUser, "Jumping to marked page " + (string)count + ".");
263 }
264 // The Flicker menu is all numbers. Is this message a number?
265 else if((integer)message > 1)
266 {
267 ParticleCount = (integer)message;
268 llInstantMessage(BookUser, "Setting particle count to " + (string)ParticleCount + ".");
269 ShowPage();
270 }
271 // Kill the old listen channel, call the flicker menu on a new channel.
272 else if(message == "Flicker?")
273 {
274 Flicker = TRUE;
275 }
276 // Shut down the menu listen channel.
277 llListenRemove(Listener);
278 if(Flicker == TRUE)
279 {
280 Flicker = FALSE;
281 FlickerMenu();
282 }
283 }
284
285 // Standard permissions event. We asked for permission to take
286 // controls above. This is triggered by that request.
288 {
290 {
291 TakeControls();
292 }
293 else
294 {
296 llSleep(1.0);
297 state default;
298 }
299 }
300
301 control(key id, integer level, integer edge)
302 {
303 if(level & edge & CONTROL_DOWN )
304 {
305 count = count + 1;
306 if(count >= PageCount)
307 {
308 count = 0;
309 }
310 SetPage();
311 }
312 else if(level & edge & CONTROL_UP )
313 {
314 count = count - 1;
315 if(count <= -1)
316 {
317 count = PageCount - 1;
318 }
319 SetPage();
320 }
321 }
322
323 // If the user walks out of range, reset the book.
324 no_sensor()
325 {
328 llSleep(1.0);
329 BookUser = "";
331 state default;
332 }
333
334 sensor(integer num_detected)
335 {
336 // Just in case we need this later.
337 }
338 }

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