|
Dudeney Ge
EduNation Archipelago
Join date: 21 Jul 2006
Posts: 95
|
10-01-2006 02:08
Hi All,
Here's a script that reports all the lines in a notecard, but how do I get it to stop after it has read out the first line, and wait ti be clicked before reading out the next? Any ideas gratefully received...
string NotecardName = "speakme"; // notecard to read out integer NotecardLine = 0; // line of notecard to start at key NotecardQueryID; // dataserver query id default { state_entry() { NotecardQueryID = llGetNotecardLine(NotecardName, NotecardLine); } dataserver(key query_id, string data) { if (query_id == NotecardQueryID) { if (data != EOF) { llSay(0, ""+data); ++NotecardLine; NotecardQueryID = llGetNotecardLine(NotecardName, NotecardLine); } } } }
Thanks in advance
DG
|
|
Eloise Pasteur
Curious Individual
Join date: 14 Jul 2004
Posts: 1,952
|
10-01-2006 02:51
use php tags - in [ and ] and with a / to make your code easier to read on the fora please! But anyway, I've not tested it, but something like this should help: integer pointer=0; string cardName="myCard"; default { touch_start(integer num) { llGetNotecardLine(cardName, pointer); } dataserver(key id, string data) { if(data==EOF) { pointer=0; llGetNotecardLine(cardName, pointer); } else { llSay(0, data); } } }
|
|
Dudeney Ge
EduNation Archipelago
Join date: 21 Jul 2006
Posts: 95
|
Slight Change
10-01-2006 03:01
Eloise,
Thanks for that, and sorry for not formatting the code properly. I've added a:
++pointer;
under:
llSay(0, data);
to increment the line number each time the object is clicked and a line is read out. Is this the right way of going about it? It works - just wanted to check that this is the most efficient way.
DG
|
|
Joannah Cramer
Registered User
Join date: 12 Apr 2006
Posts: 1,539
|
10-01-2006 08:27
From: Dudeney Ge to increment the line number each time the object is clicked and a line is read out. Is this the right way of going about it? It works - just wanted to check that this is the most efficient way. Pretty much yes ^^ it's possible to make it a bit more tricky: touch_start(integer num) {
llGetNotecardLine( cardName, pointer++ ); }
which should read the card line, then increase the pointer variable by one... it's a small saving though and can make the code somewhat less readable after a while, so not sure if worth the trouble. Increasing variable in separate line makes it more obvious so i'd go with that. o.O
|
|
Eloise Pasteur
Curious Individual
Join date: 14 Jul 2004
Posts: 1,952
|
10-01-2006 12:17
I'd probably do it with ++pointer under llSay... but Jonnah's way works just fine. The reason I'd do it the other way... easier to debug. As you can see, even in short scripts like this is easy to make dumb mistakes. 
|