Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- integer playPause = TRUE;
- float sleepTime = 5.0;
- key gRequestID;
- integer numBookPages;
- integer gChannel;
- string gMenuText = "Select a card to read.";
- list gMenu;
- list gMenuShort;
- list gMenuControls = ["SLOWER", "FASTER", "RESET", "SHOUT TEXT"];
- integer gListener;
- string gName;
- integer gLine = 0; // current line number
- key gQueryID; // id used to identify dataserver queries
- key user;
- integer itemsContained;
- integer currentItem;
- string itemName;
- string itemShortName;
- CountItems()//makes a list of names of notecards in inventory and a list of shortened names for the dialog buttons.
- {
- itemsContained = llGetInventoryNumber( INVENTORY_NOTECARD);
- //--items_contained; //minus 1, the script itself isn't counted, since its used with the INVENTORY_ALL flag
- for(currentItem; currentItem < itemsContained; currentItem++)
- {
- itemName = llGetInventoryName(INVENTORY_NOTECARD, currentItem);
- itemShortName = llGetSubString(itemName, 0,10);
- gMenu += itemName;
- gMenuShort += itemShortName;
- llSay(0, (string)itemName);
- //llList2String(gMenu, itemName)):
- //currentItem++;
- }
- //llSay(0, llDumpList2String(gMenu, ","));
- }
- default
- {
- state_entry() {
- CountItems();//makes a list of names of notecards in inventory and a list of shortened names for the dialog buttons.
- }
- touch_start(integer touches)
- {
- llListenRemove(gListener);
- user = llDetectedKey(0);
- gChannel = llGetUnixTime();
- gListener = llListen(gChannel, "", user, "");
- llDialog(user, gName+ gMenuText, gMenuShort+gMenuControls, gChannel);
- }
- listen(integer chan, string name, key id, string msg)
- {
- playPause=TRUE;
- integer shortName = llListFindList(gMenuShort, [msg]);
- gName = llList2String(gMenu, shortName);
- llSay(0, (string)gName);
- //llListenRemove(gListener);
- // If the user clicked x button,
- if (msg == "RESET"){llOwnerSay("resetting"); llResetScript();}
- else if(msg == "STOP"){llSay(0, "Stop Reading line "+(string)gLine+" of "+(string)numBookPages); playPause = FALSE;}
- else if(msg == "FF"){gLine += 5; llSay(0, "Fast Fwd - Line "+(string)gLine+" of "+(string)numBookPages);}
- else if(msg == "FFF"){gLine += 25; llSay(0, "Fast Fast Fwd - Line "+(string)gLine+" of "+(string)numBookPages);}
- else if(msg == "PLAY"){llSay(0, "Now reading "+gName+" "+ " line "+(string)gLine+" of "+(string)numBookPages); playPause = TRUE;}
- else if(msg == "RW"){gLine -= 5; llSay(0, "Rewinding - Line "+(string)gLine+" of "+(string)numBookPages);}
- else if(msg == "RRW"){gLine -= 25; llSay(0, "Fast Rewind - Line "+(string)gLine+" of "+(string)numBookPages);}
- else if(msg == "SLOWER"){ sleepTime += 1; llOwnerSay("Slower: Delay is " + (string)sleepTime); playPause=FALSE;}
- else if(msg == "FASTER" && sleepTime>=1){ sleepTime -= 1; llOwnerSay("Faster: Delay is " + (string)sleepTime);playPause=FALSE;}
- //else if(msg == ""){ gName =; llSay(0, "Faster: Delay is " + (string)sleepTime);
- //}
- else
- {
- //if(playPause == TRUE)
- //{
- gQueryID = llGetNotecardLine(gName, gLine); // request first line
- }
- llDialog(user, gName+ gMenuText, gMenuShort+gMenuControls, gChannel);
- //}
- }
- dataserver(key query_id, string data)
- {
- if (query_id == gQueryID)
- {
- if (data != EOF)
- { // not at the end of the notecard
- //llSay(0, (string)gLine+": "+data); // output the line
- if(playPause == TRUE)
- {
- //send to chat
- llShout(0, (string)data); // output the line
- llSleep(sleepTime);
- ++gLine; // increase line count
- gQueryID = llGetNotecardLine(gName, gLine); // request next line
- }
- }
- }
- //if (query_id==gRequestID) {
- numBookPages = (integer)data;
- //}
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement