|
Milcoi Delcon
Registered User
Join date: 24 May 2007
Posts: 30
|
08-23-2007 03:59
Hi,
I'm having some problems with this script, as you can see it reads the lines in a notecard, activated by chat command. This is working fine but, i can't figure out how to stop it at any time.
note: there is a llSleep between the lines (I think that's the problem for not stop reading)
Help would be welcome
string STOP_MESSAGE = "STOP"; string START_MESSAGE = "START"; string gName = "Testnotecard"; integer COMMAND_CHANNEL = 101; integer gLine = 0; key gQueryID; default {
state_entry() {
llListen(COMMAND_CHANNEL, "", NULL_KEY, "" ); }
listen( integer chan, string name, key id, string msg )
{ if (llToUpper( msg) == START_MESSAGE ) { gQueryID = llGetNotecardLine(gName, gLine); } else if ( llToUpper(msg) == STOP_MESSAGE) { //some stop action, but how? } }
dataserver(key query_id, string data) { if (query_id == gQueryID) { if (data != EOF) { llSay(0, (string)data); ++gLine; llSleep(3.0); gQueryID = llGetNotecardLine(gName, gLine); } } } }
|
|
Jillian Callahan
Rotary-winged Neko Girl
Join date: 24 Jun 2004
Posts: 3,766
|
08-23-2007 04:27
THis isn't the best possible method, but it works: string STOP_MESSAGE = "STOP"; string START_MESSAGE = "START"; string gName = "Testnotecard"; integer COMMAND_CHANNEL = 101; integer gLine = 0; key gQueryID; integer reading = FALSE; default { state_entry() { llListen(COMMAND_CHANNEL, "", NULL_KEY, "" ); } listen( integer chan, string name, key id, string msg ) { if (llToUpper( msg) == START_MESSAGE ) { reading = TRUE; gQueryID = llGetNotecardLine(gName, gLine); } else if ( llToUpper(msg) == STOP_MESSAGE) { reading = FALSE; } } dataserver(key query_id, string data) { if (query_id == gQueryID) { if (data != EOF && reading) { llSay(0, (string)data); ++gLine; llSleep(3.0); gQueryID = llGetNotecardLine(gName, gLine); } } } }
|
|
Milcoi Delcon
Registered User
Join date: 24 May 2007
Posts: 30
|
08-23-2007 05:01
it's working ...
I added gLine = 0; so it will start on top of notecard when activating it again.
string STOP_MESSAGE = "STOP"; string START_MESSAGE = "START"; string gName = "Testnotecard"; integer COMMAND_CHANNEL = 101; integer gLine = 0; key gQueryID; integer reading = FALSE;
default { state_entry() { llListen(COMMAND_CHANNEL, "", NULL_KEY, "" ); }
listen( integer chan, string name, key id, string msg ) { if (llToUpper( msg) == START_MESSAGE ) { reading = TRUE; gQueryID = llGetNotecardLine(gName, gLine=0); // gLine=0 to start on top of notecard } else if ( llToUpper(msg) == STOP_MESSAGE) { reading = FALSE; } }
dataserver(key query_id, string data) { if (query_id == gQueryID) { if (data != EOF && reading) { llSay(0, (string)data); ++gLine; llSleep(3.0); gQueryID = llGetNotecardLine(gName, gLine); } } }
|