Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

NoteCard Reader

MystressAnna Lovenkraft
Registered User
Join date: 24 Oct 2007
Posts: 28
08-12-2008 23:40
I have looked all over the forums and checked the Wikis

But I can't find a script for a Notecard reader..

What I want is for anyone to be able to drop in a Notecard and have the object read it outloud .. and then read the next one .. and the next one and when it has read them all start with the first one again .. over and over ..

My grasp of LSL is ..well not that much ...

Thank for any Help you can provide ..

Anna
Innula Zenovka
Registered User
Join date: 20 Jun 2007
Posts: 1,825
08-13-2008 03:46
One (or both) of the two examples at http://www.lslwiki.net/lslwiki/wakka.php?wakka=llGetNotecardLine might provide the basis of what you want. Do you need help making it start over when it's finished reading?
Very Keynes
LSL is a Virus
Join date: 6 May 2006
Posts: 484
08-13-2008 09:21
From: MystressAnna Lovenkraft
..and have the object read it outloud ..


Outloud as in voice?
MystressAnna Lovenkraft
Registered User
Join date: 24 Oct 2007
Posts: 28
08-13-2008 14:24
Hi me again...

that does reader note cards...but it reads them all at once....No pauses between lines...

I can't seem to find the place to put in llSleep() to slow it down...or where to put a timer..

....

Thanks

Anna
Kaluura Boa
Polygon Project
Join date: 27 Mar 2007
Posts: 194
08-14-2008 00:15
The most obvious places to add an llSleep() are just before llGetNotecardLine() or just after llSay().

Here is a script looping over all available notecards with a timer:

integer Index = 0;
string Notecard;
float Delay = 2.5; // One line every 2.5 seconds
key Query;
integer Line = 0;

default
{
state_entry()
{
Notecard = llGetInventoryName(INVENTORY_NOTECARD, Index);
llSetTimerEvent(Delay);
}

timer()
{
llSetTimerEvent(0.0);
Query = llGetNotecardLine(Notecard, Line);
}

dataserver(key id, string data)
{
if (id == Query)
{
if (data == EOF)
{
Line = 0;
integer number = llGetInventoryNumber(INVENTORY_NOTECARD);
string next_note;
do
{
Index = (Index + 1) % number; // Loop from 0 to number - 1
next_note = llGetInventoryName(INVENTORY_NOTECARD, Index);
}
while ( (next_note == Notecard) && (number != 1) );
Notecard = next_note;
}
else
{
llSay(0, data);
++Line;
}
llSetTimerEvent(Delay);
}
}
}

Tested in world. It works fine...
MystressAnna Lovenkraft
Registered User
Join date: 24 Oct 2007
Posts: 28
Wow thanks
08-14-2008 05:18
From: Kaluura Boa
The most obvious places to add an llSleep() are just before llGetNotecardLine() or just after llSay().

Here is a script looping over all available notecards with a timer:

integer Index = 0;
string Notecard;
float Delay = 2.5; // One line every 2.5 seconds
key Query;
integer Line = 0;

default
{
state_entry()
{
Notecard = llGetInventoryName(INVENTORY_NOTECARD, Index);
llSetTimerEvent(Delay);
}

timer()
{
llSetTimerEvent(0.0);
Query = llGetNotecardLine(Notecard, Line);
}

dataserver(key id, string data)
{
if (id == Query)
{
if (data == EOF)
{
Line = 0;
integer number = llGetInventoryNumber(INVENTORY_NOTECARD);
string next_note;
do
{
Index = (Index + 1) % number; // Loop from 0 to number - 1
next_note = llGetInventoryName(INVENTORY_NOTECARD, Index);
}
while ( (next_note == Notecard) && (number != 1) );
Notecard = next_note;
}
else
{
llSay(0, data);
++Line;
}
llSetTimerEvent(Delay);
}
}
}

Tested in world. It works fine...




This one worked just like I was hoped..

Thank You
Koa

I should have have known to ask hang out at AN more..

Thank You again..
Haravikk Mistral
Registered User
Join date: 8 Oct 2005
Posts: 2,482
08-14-2008 06:18
Here's a modified script that I use for just outputting notecard data. There are two variables of note:
delayPerCharacter - this is the delay incurred for every character of a line. So if a line is 100 characters long and the delay 0.05 then the script will wait 5 seconds before grabbing the next line. If the line is only 50 characters long then the delay is only 2.5 seconds. If you find 0.05 is too fast or slow then adjust it accordingly, however, remember that it is per-character, so lower values will cause one or two word lines to pass quickly. I find 0.05 is about right, as quick readers don't have to wait too long, but slow readers shouldn't be overwhelmed.
newNotecardDelay - this is the delay after switching to a new notecard.

Just drop the following script into an object (you might want to fix up the formatting a bit, or click the "quote" button below my post to grab the script complete with formatting from between the php tags). Then drop in a load of notecards. Notecards are read in alphabetical order, and if you drop more in while reading is in progress then you may end up repeating some sooner than normal. However, after completing a 'loop' the script will always return to normal.
The script grabs the key of the notecard and uses that for reading, so if you remove a notecard then the script will finish reading it anyway rather than stopping abruptly with an error or moving on to a new script.

CODE
integer notecard            = 0;
integer line = 0;

key notecardKey = NULL_KEY;
key dataserverKey = NULL_KEY;

float delayPerCharacter = 0.05;
float newNotecardDelay = 1.0;

default {
state_entry() {
integer notecards = llGetInventoryNumber(INVENTORY_NOTECARD);
if (notecards < 1) llOwnerSay("No notecards found!");
else state readNotecard;
}

changed(integer x) {
if (x & CHANGED_INVENTORY) llResetScript();
}
}

state readNotecard {
state_entry() {
if (notecard >= llGetInventoryNumber(INVENTORY_NOTECARD)) {
if (notecard <= 0) llResetScript();
else notecard = 0;
}

string name = llGetInventoryName(INVENTORY_NOTECARD, notecard);
key id = llGetInventoryKey(name);
if (notecardKey == id) llResetScript();
else notecardKey = id;

llSay(0, "Now reading from notecard '"+name+"'");
llSleep(newNotecardDelay);

state readLines;
}
}

state readLines {
state_entry() {
dataserverKey = llGetNotecardLine(notecardKey, (line = 0));
}

dataserver(key id, string data) {
if (id != dataserverKey) return;

if (data == EOF) {
++notecard;
state readNotecard;
} else {
llSay(0, data);
llSleep((float)llStringLength(data) * delayPerCharacter);

dataserverKey = llGetNotecardLine(notecardKey, ++line);
}
}
}
_____________________
Computer (Mac Pro):
2 x Quad Core 3.2ghz Xeon
10gb DDR2 800mhz FB-DIMMS
4 x 750gb, 32mb cache hard-drives (RAID-0/striped)
NVidia GeForce 8800GT (512mb)